-
Notifications
You must be signed in to change notification settings - Fork 9
/
GBETimeLine.pas
113 lines (95 loc) · 2.65 KB
/
GBETimeLine.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
unit GBETimeLine;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Ani, system.Generics.Collections;
type
TGBEStep = record
duration, delay : single;
propertyName : string;
startValue, stopValue : single;
autoReverse, inverse, startFromCurrent : boolean;
interpolation : TInterpolationType;
AnimationType : TAnimationType;
end;
TGBETimeline = class(TFloatAnimation)
private
{ Déclarations privées }
fListeAnimation : TList<TGBEStep>;
fLoopSteps : boolean;
function getCount: integer;
procedure RunAnimation(indice: integer);
procedure Finish(Sender: TObject);
protected
{ Déclarations protégées }
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure clear;
procedure addStep(aStep : TGBEStep);
procedure run;
published
{ Déclarations publiées }
property count : integer read getCount;
property loopSteps : boolean read fLoopSteps write fLoopSteps;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('GBE3D', [TGBETimeline]);
end;
{ TGBETimeline }
procedure TGBETimeline.addStep(aStep: TGBEStep);
begin
fListeAnimation.Add(aStep);
end;
procedure TGBETimeline.clear;
begin
fListeAnimation.Clear;
end;
constructor TGBETimeline.Create(AOwner: TComponent);
begin
inherited;
fListeAnimation := TList<TGBEStep>.create;
fLoopSteps := false;
end;
destructor TGBETimeline.Destroy;
begin
fListeAnimation.Free;
inherited;
end;
function TGBETimeline.getCount: integer;
begin
result := fListeAnimation.Count;
end;
procedure TGBETimeline.run;
begin
if fListeAnimation.Count > 0 then
RunAnimation(0);
end;
procedure TGBETimeLine.RunAnimation(indice: integer);
begin
if indice < fListeAnimation.count then begin
self.duration := fListeAnimation[indice].duration;
self.delay := fListeAnimation[indice].delay;
self.propertyName := fListeAnimation[indice].propertyName;
self.startValue := fListeAnimation[indice].startValue;
self.stopValue := fListeAnimation[indice].stopValue;
self.autoReverse := fListeAnimation[indice].autoReverse;
self.inverse := fListeAnimation[indice].inverse;
self.startFromCurrent := fListeAnimation[indice].startFromCurrent;
self.interpolation := fListeAnimation[indice].interpolation;
self.AnimationType := fListeAnimation[indice].AnimationType;
self.Tag := indice;
self.OnFinish := Finish;
self.Start;
end else begin
if fLoopSteps then RunAnimation(0);
end;
end;
procedure TGBETimeLine.Finish(Sender: TObject);
begin
RunAnimation((sender as TFloatAnimation).Tag + 1);
end;
end.