123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- unit MainUnit;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, Fresnel.Forms, Fresnel.DOM, Fresnel.Controls, DemoSlider;
- type
- { TFresnelForm1 }
- TFresnelForm1 = class(TFresnelForm)
- procedure FresnelForm1Create(Sender: TObject);
- private
- procedure OnPropChange(Sender: TObject);
- procedure UpdateButton;
- public
- ButtonDiv: TDiv;
- ButtonLabel: TLabel;
- FontSizeSlider: TDemoSlider;
- BorderWidthSlider: TDemoSlider;
- BorderRadiusSlider: TDemoSlider;
- end;
- var
- FresnelForm1: TFresnelForm1;
- implementation
- {$R *.lfm}
- { TFresnelForm1 }
- procedure TFresnelForm1.FresnelForm1Create(Sender: TObject);
- begin
- Stylesheet.Add('#ButtonDiv {'
- +'background:#44c767;'
- +'border:1px solid #18ab29;'
- +'border-radius:16px;'
- +'padding:16px 31px;'
- +'font-size:15px; font-family:Arial; font-weight:bold;'
- +'color:#fff;'
- +'text-shadow: 1px 1px 0px #2f6627;'
- +'}');
- Stylesheet.Add(TDemoSlider.cStyle);
- FontSizeSlider:=TDemoSlider.Create(Self);
- with FontSizeSlider do begin
- Name:='FontSizeSlider';
- Caption:='Font Size:';
- Style:='width: 150px';
- ValueFormat:='%.0fpx';
- MinPosition:=5;
- MaxPosition:=40;
- Position:=12;
- Parent:=Self;
- OnChange:=@OnPropChange;
- end;
- BorderWidthSlider:=TDemoSlider.Create(Self);
- with BorderWidthSlider do begin
- Name:='BorderWidthSlider';
- Caption:='Border Width:';
- Style:='width: 150px';
- ValueFormat:='%.0fpx';
- MinPosition:=0;
- MaxPosition:=10;
- Position:=1;
- Parent:=Self;
- OnChange:=@OnPropChange;
- end;
- BorderRadiusSlider:=TDemoSlider.Create(Self);
- with BorderRadiusSlider do begin
- Name:='BorderRadiusSlider';
- Caption:='Border Radius:';
- Style:='width: 150px';
- ValueFormat:='%.0fpx';
- MinPosition:=0;
- MaxPosition:=50;
- Position:=16;
- Parent:=Self;
- OnChange:=@OnPropChange;
- end;
- ButtonDiv:=TDiv.Create(Self);
- with ButtonDiv do begin
- Name:='ButtonDiv';
- Parent:=Self;
- end;
- ButtonLabel:=TLabel.Create(Self);
- with ButtonLabel do begin
- Name:='ButtonLabel';
- Caption:='Button Text';
- Parent:=ButtonDiv;
- end;
- UpdateButton;
- end;
- procedure TFresnelForm1.OnPropChange(Sender: TObject);
- begin
- UpdateButton;
- end;
- procedure TFresnelForm1.UpdateButton;
- begin
- if ButtonDiv=nil then exit;
- ButtonDiv.Style:=
- 'font-size:'+FloatToStr(FontSizeSlider.Position)+'px;'
- +'border-width:'+FloatToStr(BorderWidthSlider.Position)+'px;'
- +'border-radius:'+FloatToStr(BorderRadiusSlider.Position)+'px;'
- ;
- end;
- end.
|