MainUnit.pas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. end;
  19. var
  20. FresnelForm1: TFresnelForm1;
  21. implementation
  22. {$R *.lfm}
  23. { TFresnelForm1 }
  24. procedure TFresnelForm1.FresnelForm1Create(Sender: TObject);
  25. begin
  26. Stylesheet.Add('#ButtonDiv {'
  27. +'background:#44c767;'
  28. +'border-width:1px;'
  29. +'border-color:#18ab29;'
  30. +'border-radius:28px;'
  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: 100px';
  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: 100px';
  54. ValueFormat:='%.0fpx';
  55. MinPosition:=0;
  56. MaxPosition:=10;
  57. Position:=1;
  58. Parent:=Self;
  59. OnChange:=@OnPropChange;
  60. end;
  61. ButtonDiv:=TDiv.Create(Self);
  62. with ButtonDiv do begin
  63. Name:='ButtonDiv';
  64. Parent:=Self;
  65. end;
  66. ButtonLabel:=TLabel.Create(Self);
  67. with ButtonLabel do begin
  68. Name:='ButtonLabel';
  69. Parent:=ButtonDiv;
  70. end;
  71. end;
  72. procedure TFresnelForm1.OnPropChange(Sender: TObject);
  73. begin
  74. UpdateButton;
  75. end;
  76. procedure TFresnelForm1.UpdateButton;
  77. begin
  78. if ButtonDiv=nil then exit;
  79. ButtonDiv.Style:=
  80. 'font-size:'+FloatToStr(FontSizeSlider.Position)+'px;'
  81. +'border-width:'+FloatToStr(BorderWidthSlider.Position)+'px;'
  82. end;
  83. end.