source: trunk/Packages/bgracontrols/testbgracontrols/uglassmenu.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 2.6 KB
Line 
1unit uglassmenu;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Forms, Dialogs, BGRAVirtualScreen, BGRAButton, BGRAKnob, BGRABitmap;
9
10type
11
12 { TfrmGlassMenu }
13
14 TfrmGlassMenu = class(TForm)
15 btnShowBkg: TBGRAButton;
16 knbButtonOpacity: TBGRAKnob;
17 btnTextOpacity: TBGRAButton;
18 btnBackground: TBGRAButton;
19 dlgOpenBackground: TOpenDialog;
20 vsBackground: TBGRAVirtualScreen;
21 procedure btnShowBkgClick(Sender: TObject);
22 procedure knbButtonOpacityValueChanged(Sender: TObject; Value: single);
23 procedure btnBackgroundClick(Sender: TObject);
24 procedure btnTextOpacityClick(Sender: TObject);
25 procedure FormCreate(Sender: TObject);
26 procedure FormDestroy(Sender: TObject);
27 procedure vsBackgroundRedraw(Sender: TObject; Bitmap: TBGRABitmap);
28 private
29 { private declarations }
30 theBackground: TBGRABitmap;
31 theBlur: integer;
32 theNiceOption: boolean;
33 public
34 { public declarations }
35 end;
36
37var
38 frmGlassMenu: TfrmGlassMenu;
39
40implementation
41
42{$R *.lfm}
43
44uses
45 bgrasamples;
46
47{ TfrmGlassMenu }
48
49procedure TfrmGlassMenu.btnBackgroundClick(Sender: TObject);
50begin
51 if dlgOpenBackground.Execute then
52 begin
53 theBackground.LoadFromFile(dlgOpenBackground.FileName);
54 vsBackground.RedrawBitmap;
55 end;
56end;
57
58procedure TfrmGlassMenu.knbButtonOpacityValueChanged(Sender: TObject; Value: single);
59begin
60 btnBackground.GlobalOpacity := trunc(Value - knbButtonOpacity.MinValue);
61end;
62
63procedure TfrmGlassMenu.btnShowBkgClick(Sender: TObject);
64begin
65 theNiceOption := not theNiceOption;
66 vsBackground.RedrawBitmap;
67end;
68
69procedure TfrmGlassMenu.btnTextOpacityClick(Sender: TObject);
70begin
71 btnBackground.TextApplyGlobalOpacity := not btnBackground.TextApplyGlobalOpacity;
72end;
73
74procedure TfrmGlassMenu.FormCreate(Sender: TObject);
75begin
76 theBlur := 10;
77 theBackground := TBGRABitmap.Create(Self.Width, Self.Height);
78 theNiceOption := True;
79
80 StyleButtonsSample(Self, ssMacOSXLion);
81
82 with btnBackground do
83 begin
84 GlobalOpacity := 100;
85 with BodyNormal do
86 begin
87 BorderColorOpacity := 200;
88 Gradient2.StartColorOpacity := 50;
89 end;
90 with BodyHover do
91 begin
92 BorderColorOpacity := 250;
93 Gradient1.StartColorOpacity := 100;
94 Gradient2.EndColorOpacity := 100;
95 end;
96 with BodyClicked do
97 begin
98 BorderColorOpacity := 100;
99 Gradient1.EndColorOpacity := 100;
100 Gradient2.StartColorOpacity := 100;
101 end;
102 end;
103end;
104
105procedure TfrmGlassMenu.FormDestroy(Sender: TObject);
106begin
107 theBackground.Free;
108end;
109
110procedure TfrmGlassMenu.vsBackgroundRedraw(Sender: TObject; Bitmap: TBGRABitmap);
111begin
112 Glass(vsBackground, theBackground, theBlur, theNiceOption);
113end;
114
115end.
Note: See TracBrowser for help on using the repository browser.