瀏覽代碼

Added Material Design animation test

lainz 9 年之前
父節點
當前提交
0eda006229

+ 1 - 1
test/test_extra/Plugins/TestPlugins/unit1.pas

@@ -16,7 +16,7 @@ const
   LIBRARYEXT = '*.so';
   {$ENDIF}
   {$IFDEF DARWIN}
-  LIBRARYEXT = '*.dylib'
+  LIBRARYEXT = '*.dylib';
   {$ENDIF}
 
 type

+ 86 - 0
test/test_extra/material_design_animation/circleanimation.lpi

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <ProjectOptions>
+    <Version Value="9"/>
+    <PathDelim Value="\"/>
+    <General>
+      <SessionStorage Value="InProjectDir"/>
+      <MainUnit Value="0"/>
+      <Title Value="circleanimation"/>
+      <ResourceType Value="res"/>
+      <UseXPManifest Value="True"/>
+      <XPManifest>
+        <DpiAware Value="True"/>
+      </XPManifest>
+      <Icon Value="0"/>
+    </General>
+    <i18n>
+      <EnableI18N LFM="False"/>
+    </i18n>
+    <VersionInfo>
+      <StringTable ProductVersion=""/>
+    </VersionInfo>
+    <BuildModes Count="1">
+      <Item1 Name="Default" Default="True"/>
+    </BuildModes>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+    <RunParams>
+      <local>
+        <FormatVersion Value="1"/>
+      </local>
+    </RunParams>
+    <RequiredPackages Count="2">
+      <Item1>
+        <PackageName Value="bgracontrols"/>
+      </Item1>
+      <Item2>
+        <PackageName Value="LCL"/>
+      </Item2>
+    </RequiredPackages>
+    <Units Count="2">
+      <Unit0>
+        <Filename Value="circleanimation.lpr"/>
+        <IsPartOfProject Value="True"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="umain.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="Form1"/>
+        <ResourceBaseClass Value="Form"/>
+      </Unit1>
+    </Units>
+  </ProjectOptions>
+  <CompilerOptions>
+    <Version Value="11"/>
+    <PathDelim Value="\"/>
+    <Target>
+      <Filename Value="circleanimation"/>
+    </Target>
+    <SearchPaths>
+      <IncludeFiles Value="$(ProjOutDir)"/>
+      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+    </SearchPaths>
+    <Linking>
+      <Options>
+        <Win32>
+          <GraphicApplication Value="True"/>
+        </Win32>
+      </Options>
+    </Linking>
+  </CompilerOptions>
+  <Debugging>
+    <Exceptions Count="3">
+      <Item1>
+        <Name Value="EAbort"/>
+      </Item1>
+      <Item2>
+        <Name Value="ECodetoolError"/>
+      </Item2>
+      <Item3>
+        <Name Value="EFOpenError"/>
+      </Item3>
+    </Exceptions>
+  </Debugging>
+</CONFIG>

+ 21 - 0
test/test_extra/material_design_animation/circleanimation.lpr

@@ -0,0 +1,21 @@
+program circleanimation;
+
+{$mode objfpc}{$H+}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Interfaces, // this includes the LCL widgetset
+  Forms, umain
+  { you can add units after this };
+
+{$R *.res}
+
+begin
+  RequireDerivedFormResource:=True;
+  Application.Initialize;
+  Application.CreateForm(TForm1, Form1);
+  Application.Run;
+end.
+

+ 29 - 0
test/test_extra/material_design_animation/umain.lfm

@@ -0,0 +1,29 @@
+object Form1: TForm1
+  Left = 465
+  Height = 240
+  Top = 182
+  Width = 320
+  Caption = 'Form1'
+  ClientHeight = 240
+  ClientWidth = 320
+  LCLVersion = '1.6.0.4'
+  object Button1: TBGRAGraphicControl
+    Left = 48
+    Height = 57
+    Top = 48
+    Width = 196
+    OnRedraw = Button1Redraw
+    Color = clWhite
+    ColorOpacity = 128
+    Alignment = taCenter
+    OnMouseDown = Button1MouseDown
+  end
+  object Timer1: TTimer
+    Enabled = False
+    Interval = 15
+    OnTimer = Timer1Timer
+    OnStartTimer = Timer1StartTimer
+    left = 28
+    top = 14
+  end
+end

+ 95 - 0
test/test_extra/material_design_animation/umain.pas

@@ -0,0 +1,95 @@
+unit umain;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
+  BGRAGraphicControl, BGRABitmap, BCTypes, BGRAVirtualScreen, BGRABitmapTypes,
+  BGRATextFX;
+
+type
+
+  { TForm1 }
+
+  TForm1 = class(TForm)
+    Button1: TBGRAGraphicControl;
+    Timer1: TTimer;
+    procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: integer);
+    procedure Button1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+    procedure Timer1StartTimer(Sender: TObject);
+    procedure Timer1Timer(Sender: TObject);
+  private
+    { private declarations }
+  public
+    { public declarations }
+    MouseP: TPoint;
+    CircleX: single;
+    CircleAlpha: byte;
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
+  Shift: TShiftState; X, Y: integer);
+begin
+  Timer1.Enabled := False;
+  MouseP := Point(X, Y);
+  Timer1.Enabled := True;
+end;
+
+procedure TForm1.Button1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+var
+  temp: TBGRABitmap;
+begin
+  { Shadow }
+  Bitmap.Fill(BGRAPixelTransparent);
+  Bitmap.RoundRect(5, 5, Button1.Width - 5, Button1.Height - 5, 5, 5,
+    BGRA(100, 100, 100), BGRA(100, 100, 100));
+
+  temp := Bitmap.FilterBlurRadial(5, 5, rbFast) as TBGRABitmap;
+  Bitmap.Fill(BGRAPixelTransparent);
+  Bitmap.PutImage(0, 0, temp, dmDrawWithTransparency);
+  temp.Free;
+
+  { Round Rectangle }
+  temp := TBGRABitmap.Create(Button1.Width, Button1.Height, BGRAWhite);
+  { Circle Effect }
+  temp.EllipseAntialias(MouseP.X, MouseP.Y, CircleX, CircleX,
+    BGRA(100, 100, 100, CircleAlpha), 1, BGRA(100, 100, 100, CircleAlpha));
+  Bitmap.FillRoundRectAntialias(5, 0, Button1.Width - 5, Button1.Height -
+    5, 5, 5, temp, [rrDefault], False);
+  temp.Free;
+
+  { Text }
+  temp := TextShadow(Button1.Width, Button1.Height, 'Material Design',
+    20, BGRABlack, BGRABlack, 2, 2, 2) as TBGRABitmap;
+  Bitmap.PutImage(0, 0, temp, dmDrawWithTransparency);
+  temp.Free;
+end;
+
+procedure TForm1.Timer1StartTimer(Sender: TObject);
+begin
+  CircleAlpha := 255;
+  CircleX := 5;
+end;
+
+procedure TForm1.Timer1Timer(Sender: TObject);
+begin
+  CircleX := CircleX + 4;
+  CircleAlpha := CircleAlpha - 5;
+  if CircleAlpha <= 0 then
+    Timer1.Enabled := False;
+  Button1.DiscardBitmap;
+end;
+
+end.