-
Notifications
You must be signed in to change notification settings - Fork 0
/
bgAniDemo.pas
284 lines (249 loc) · 8.27 KB
/
bgAniDemo.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
unit bgAniDemo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls,registry, sSkinProvider, sSkinManager, Buttons,
sBitBtn, sLabel, sPanel, sEdit, ImgList, acAlphaImageList, sRadioButton,
sGroupBox, ComCtrls, sTrackBar, sListBox, sCheckBox, sButton, acPNG;
type
TfrmLines = class(TForm)
Timer1: TTimer;
sSkinManager1: TsSkinManager;
sSkinProvider1: TsSkinProvider;
sPanel1: TsPanel;
sLabelFX1: TsLabelFX;
sPanel2: TsPanel;
sPanel3: TsPanel;
Image3: TImage;
sEdit1: TsEdit;
sEdit2: TsEdit;
sAlphaImageList1: TsAlphaImageList;
sAlphaImageList2: TsAlphaImageList;
sAlphaImageList3: TsAlphaImageList;
sAlphaImageList4: TsAlphaImageList;
sAlphaImageList5: TsAlphaImageList;
SkinsListBox: TsListBox;
HueTrackBar: TsTrackBar;
SaturationTrackBar: TsTrackBar;
HueLabel: TsStickyLabel;
SaturationLabel: TsStickyLabel;
sCheckBox1: TsCheckBox;
sPanel4: TsPanel;
sGroupBox1: TsGroupBox;
sRadioButton1: TsRadioButton;
sRadioButton2: TsRadioButton;
sRadioButton3: TsRadioButton;
sRadioButton4: TsRadioButton;
sRadioButton5: TsRadioButton;
sTrackBar1: TsTrackBar;
sStickyLabel1: TsStickyLabel;
sButton1: TsButton;
sPanel5: TsPanel;
sPanel6: TsPanel;
sPanel7: TsPanel;
sPanel8: TsPanel;
sLabel1: TsLabel;
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure sRadioButton1Click(Sender: TObject);
procedure sRadioButton2Click(Sender: TObject);
procedure sRadioButton3Click(Sender: TObject);
procedure sRadioButton4Click(Sender: TObject);
procedure sRadioButton5Click(Sender: TObject);
procedure SaturationTrackBarMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure HueTrackBarMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure SkinsListBoxClick(Sender: TObject);
procedure sSkinManager1AfterChange(Sender: TObject);
procedure sCheckBox1Click(Sender: TObject);
procedure sTrackBar1Change(Sender: TObject);
private
{ Private declarations }
UsedIMGList:TsAlphaImageList;
y:integer;
public
{ Public declarations }
end;
var frmLines: TfrmLines;
implementation
{$R *.DFM}
uses sSkinProps,sConst,sStyleSimply;
procedure TfrmLines.sRadioButton1Click(Sender: TObject);
begin
UsedIMGList := sAlphaImageList1;
end;
procedure TfrmLines.sRadioButton2Click(Sender: TObject);
begin
UsedIMGList := sAlphaImageList2;
end;
procedure TfrmLines.sRadioButton3Click(Sender: TObject);
begin
UsedIMGList := sAlphaImageList3;
end;
procedure TfrmLines.sRadioButton4Click(Sender: TObject);
begin
UsedIMGList := sAlphaImageList4;
end;
procedure TfrmLines.sRadioButton5Click(Sender: TObject);
begin
UsedIMGList := sAlphaImageList5;
end;
procedure TfrmLines.Timer1Timer(Sender: TObject);
var
i : integer;
foundPattern,foundHotPattern :boolean;
begin
Timer1.Enabled := False;
try
//-----------------
for i := Length(sSkinManager1.ma)-1 downto 0 do
begin
if (((UpperCase(sSkinManager1.ma[i].PropertyName) = UpperCase(s_Pattern))
or (UpperCase(sSkinManager1.ma[i].PropertyName) = UpperCase(s_HotPattern)))
and (UpperCase(sSkinManager1.ma[i].ClassName) = UpperCase(s_Form))) then
begin
// If found then we must define new Bmp
if (sSkinManager1.ma[i].Bmp = nil) then
sSkinManager1.ma[i].Bmp := TBitmap.Create();
// set Bmp size and clear it
if (sSkinManager1.ma[i].Bmp.Width <> UsedIMGList.Width) then
begin
sSkinManager1.ma[i].R := Rect(0,0,0,0);
sSkinManager1.ma[i].Bmp.SetSize(UsedIMGList.Height,UsedIMGList.Width);
sSkinManager1.ma[i].Bmp.canvas.brush.color := clblack;
sSkinManager1.ma[i].Bmp.Canvas.FillRect(rect(0,0,UsedIMGList.Height,UsedIMGList.Width));
end;
// draw next frame
UsedIMGList.GetBitmap32(y,sSkinManager1.ma[i].Bmp);
if (UpperCase(sSkinManager1.ma[i].PropertyName) = UpperCase(s_Pattern)) then foundPattern := true;
if (UpperCase(sSkinManager1.ma[i].PropertyName) = UpperCase(s_HotPattern)) then foundHotPattern := true;
if (foundPattern and foundHotPattern) then // some skins uses s_Pattern, bun some uses s_HotPattern - let's fill both
break;
end
end;
// Update of all controls
sSkinManager1.UpdateSkin();
//
Inc(y);
if (y > UsedIMGList.Items.Count-1) then
y := 0;
finally
Timer1.Enabled := True;
end;
end;
function AddBGInSkin(const SkinSection, PropName:string; sm : TsSkinManager) : boolean;
var
i, l : integer;
s : string;
begin
with sm do begin
Result := False;
if not SkinData.Active then Exit;
s := UpperCase(PropName);
l := Length(ma);
// ma - is array of records with image description
if l > 0 then begin
// search of the required image in the massive
for i := 0 to l - 1 do begin
if (UpperCase(ma[i].PropertyName) = s) and (UpperCase(ma[i].ClassName) = UpperCase(skinSection)) then begin
Result := True;
Break;
end;
end;
end;
// If not found we must to add new image
if not Result then begin
l := Length(ma) + 1;
SetLength(ma, l);
ma[l - 1].PropertyName := '';
ma[l - 1].ClassName := '';
try
ma[l - 1].Bmp := TBitmap.Create;
ma[l - 1].Bmp.SetSize(256,256);
finally
ma[l - 1].PropertyName := s;
ma[l - 1].ClassName := UpperCase(skinSection);
ma[l - 1].Manager := sm;
ma[l - 1].R := Rect(0, 0, ma[l - 1].Bmp.Width, ma[l - 1].Bmp.Height);
ma[l - 1].ImageCount := 1;
ma[l - 1].ImgType := itisaTexture;
end;
if ma[l - 1].Bmp.Width < 1 then begin
FreeAndNil(ma[l - 1].Bmp);
SetLength(ma, l - 1);
end;
l := Length(pa);
if l > 0 then for i := 0 to l - 1 do if (pa[i].PropertyName = s) and (pa[i].ClassName = UpperCase(skinSection)) then begin
FreeAndNil(pa[i].Img);
l := Length(pa) - 1;
if l <> i then begin
pa[i].Img := pa[l].Img ;
pa[i].ClassName := pa[l].ClassName ;
pa[i].PropertyName := pa[l].PropertyName;
end;
SetLength(pa, l);
Break;
end;
Result := True;
end;
end
end;
procedure TfrmLines.HueTrackBarMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (not aSkinChanging) then
sSkinManager1.HueOffset := HueTrackBar.Position;
end;
procedure TfrmLines.SaturationTrackBarMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ( not aSkinChanging) then
sSkinManager1.Saturation := SaturationTrackBar.Position;
end;
procedure TfrmLines.sSkinManager1AfterChange(Sender: TObject);
var
SkinIndex : integer;
begin
AddBGInSkin('FORM', 'PATTERN', sSkinManager1);
AddBGInSkin('FORM', 'HOTPATTERN', sSkinManager1);
//Receive an index of the FORM section
SkinIndex := sSkinManager1.GetSkinIndex('FORM');
sSkinManager1.gd[SkinIndex].Props[0].ImagePercent := 100;
sSkinManager1.gd[SkinIndex].Props[0].GradientPercent := 0;
sSkinManager1.gd[SkinIndex].Props[0].Transparency := 0;
sSkinManager1.gd[SkinIndex].Props[1].ImagePercent := 100;
sSkinManager1.gd[SkinIndex].Props[1].GradientPercent := 0;
sSkinManager1.gd[SkinIndex].Props[1].Transparency := 0;
sSkinManager1.gd[SkinIndex].GradientPercent := 0;
sSkinManager1.gd[SkinIndex].ImagePercent := 100;
sSkinManager1.gd[SkinIndex].HotGradientPercent := 0;
sSkinManager1.gd[SkinIndex].HotImagePercent := 100;
sSkinProvider1.SkinData.CtrlSkinState := 0;
sSkinProvider1.SkinData.Invalidate;
end;
procedure TfrmLines.sTrackBar1Change(Sender: TObject);
var i:integer;
begin
i := sTrackBar1.Position * 50;
if (i = 0) then
i := 1;
Timer1.Interval := i;
end;
procedure TfrmLines.FormActivate(Sender: TObject);
begin
y := 0;
UsedIMGList := sAlphaImageList5;
sSkinManager1.GetSkinNames(SkinsListBox.Items);
sSkinManager1AfterChange(nil);
end;
procedure TfrmLines.sCheckBox1Click(Sender: TObject);
begin
Timer1.Enabled := not Timer1.Enabled;
end;
procedure TfrmLines.SkinsListBoxClick(Sender: TObject);
begin
sSkinManager1.SkinName := SkinsListBox.Items.Strings[SkinsListBox.ItemIndex];
Invalidate();
end;
end.