MainUnit.pas 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. unit MainUnit;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Fresnel.Forms, Fresnel.DOM, Fresnel.Controls, DemoSlider;
  6. type
  7. { TFresnelForm1 }
  8. TFresnelForm1 = class(TFresnelForm)
  9. procedure FresnelForm1Create(Sender: TObject);
  10. private
  11. procedure OnPropChange(Sender: TObject);
  12. procedure UpdateButton;
  13. public
  14. ButtonDiv: TDiv;
  15. ButtonLabel: TLabel;
  16. FontSizeSlider: TDemoSlider;
  17. BorderWidthSlider: TDemoSlider;
  18. BorderRadiusSlider: TDemoSlider;
  19. end;
  20. var
  21. FresnelForm1: TFresnelForm1;
  22. implementation
  23. {$R *.lfm}
  24. { TFresnelForm1 }
  25. procedure TFresnelForm1.FresnelForm1Create(Sender: TObject);
  26. begin
  27. Stylesheet.Add('#ButtonDiv {'
  28. +'background:#44c767;'
  29. +'border:1px solid #18ab29;'
  30. +'border-radius:16px;'
  31. +'padding:16px 31px;'
  32. +'font-size:15px; font-family:Arial; font-weight:bold;'
  33. +'color:#fff;'
  34. +'text-shadow: 1px 1px 0px #2f6627;'
  35. +'}');
  36. Stylesheet.Add(TDemoSlider.cStyle);
  37. FontSizeSlider:=TDemoSlider.Create(Self);
  38. with FontSizeSlider do begin
  39. Name:='FontSizeSlider';
  40. Caption:='Font Size:';
  41. Style:='width: 150px';
  42. ValueFormat:='%.0fpx';
  43. MinPosition:=5;
  44. MaxPosition:=40;
  45. Position:=12;
  46. Parent:=Self;
  47. OnChange:=@OnPropChange;
  48. end;
  49. BorderWidthSlider:=TDemoSlider.Create(Self);
  50. with BorderWidthSlider do begin
  51. Name:='BorderWidthSlider';
  52. Caption:='Border Width:';
  53. Style:='width: 150px';
  54. ValueFormat:='%.0fpx';
  55. MinPosition:=0;
  56. MaxPosition:=10;
  57. Position:=1;
  58. Parent:=Self;
  59. OnChange:=@OnPropChange;
  60. end;
  61. BorderRadiusSlider:=TDemoSlider.Create(Self);
  62. with BorderRadiusSlider do begin
  63. Name:='BorderRadiusSlider';
  64. Caption:='Border Radius:';
  65. Style:='width: 150px';
  66. ValueFormat:='%.0fpx';
  67. MinPosition:=0;
  68. MaxPosition:=50;
  69. Position:=16;
  70. Parent:=Self;
  71. OnChange:=@OnPropChange;
  72. end;
  73. ButtonDiv:=TDiv.Create(Self);
  74. with ButtonDiv do begin
  75. Name:='ButtonDiv';
  76. Parent:=Self;
  77. end;
  78. ButtonLabel:=TLabel.Create(Self);
  79. with ButtonLabel do begin
  80. Name:='ButtonLabel';
  81. Caption:='Button Text';
  82. Parent:=ButtonDiv;
  83. end;
  84. UpdateButton;
  85. end;
  86. procedure TFresnelForm1.OnPropChange(Sender: TObject);
  87. begin
  88. UpdateButton;
  89. end;
  90. procedure TFresnelForm1.UpdateButton;
  91. begin
  92. if ButtonDiv=nil then exit;
  93. ButtonDiv.Style:=
  94. 'font-size:'+FloatToStr(FontSizeSlider.Position)+'px;'
  95. +'border-width:'+FloatToStr(BorderWidthSlider.Position)+'px;'
  96. +'border-radius:'+FloatToStr(BorderRadiusSlider.Position)+'px;'
  97. ;
  98. end;
  99. end.