Browse Source

Changes to BCMDButton by Fritz. Added global to change the position of the checkmark in tab mode. Added a global to change the color of the checkmark.

lainz 5 years ago
parent
commit
12174cffb0

+ 32 - 3
bcmdbutton.pas

@@ -21,6 +21,9 @@ uses
   Forms, Controls, Graphics, Dialogs,
   BCBaseCtrls, BGRABitmap, BGRABitmapTypes, ExtCtrls, Math, BGRABlend;
 
+type
+  TBCMDButtonCheckMarkPosition = (cmpBottom,cmpTop,cmpLeft,cmpRight);
+
 var
   // Default icons for Check Box
   {BCMDBUTTONBALLOTBOX: string = '☐'; // '✗'
@@ -47,6 +50,11 @@ var
   // Global enable/disable animations
   BCMDBUTTONANIMATION: boolean = True;
 
+  // Global posiotn of checkmarks 0=bottom, 1=top, 2=left, 3=right
+  BCMDBUTTONCHECKMARKPOSITION : TBCMDButtonCheckMarkPosition = cmpBottom;
+
+  BCMDBUTTONCHECKMARKCOLOR : TColor = $00BB513F;
+
 const
   // Timer speed: default 15 (a bit more than 60 fps)
   // Other values: 16 (60 fps) 20 (50 fps) 25 (40 fps) 33 (30 fps)
@@ -569,13 +577,34 @@ begin
     if FTimer.Enabled then
     begin
       iTemp := round((bmp.Width div 2) * easeInOutQuad(FPercent));
-      bmp.Rectangle((bmp.Width div 2) - iTemp, bmp.Height - 2,
-        (bmp.Width div 2) + iTemp, bmp.Height, $00BB513F, dmSet);
+      case BCMDBUTTONCHECKMARKPOSITION of
+      cmpBottom : begin
+             iTemp := round((bmp.Width div 2) * easeInOutQuad(FPercent));
+             bmp.Rectangle((bmp.Width div 2) - iTemp, bmp.Height - 2,(bmp.Width div 2) + iTemp, bmp.Height, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+          end;
+      cmpTop : begin
+            iTemp := round((bmp.Width div 2) * easeInOutQuad(FPercent));
+            bmp.Rectangle((bmp.Width div 2) - iTemp, 0,(bmp.Width div 2) + iTemp, 2, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+          end;
+      cmpLeft : begin
+            iTemp := round((bmp.Height div 2) * easeInOutQuad(FPercent));
+            bmp.Rectangle(0, (bmp.Height div 2) - iTemp, 2, (bmp.Height div 2) + iTemp, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+          end;
+      cmpRight : begin
+            iTemp := round((bmp.Height div 2) * easeInOutQuad(FPercent));
+            bmp.Rectangle(bmp.width-2, (bmp.Height div 2) - iTemp, bmp.width, (bmp.Height div 2) + iTemp, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+          end;
+      end; // case
     end
     else
     begin
       if FChecked then
-        bmp.Rectangle(0, bmp.Height - 2, bmp.Width, bmp.Height, $00BB513F, dmSet);
+        case BCMDBUTTONCHECKMARKPOSITION of
+        cmpBottom : bmp.Rectangle(0, bmp.Height - 2, bmp.Width, bmp.Height, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+        cmpTop : bmp.Rectangle(0, 0, bmp.Width, 2, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+        cmpLeft : bmp.Rectangle(0, 0, 2, bmp.Height, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+        cmpRight : bmp.Rectangle(bmp.Width - 2, 0, bmp.Width, bmp.Height, BCMDBUTTONCHECKMARKCOLOR, dmSet);
+        end; // case
     end;
   end;
 

+ 5 - 4
test/test_materialdesign/mdbutton_tab/test.lpi

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="10"/>
+    <Version Value="11"/>
     <PathDelim Value="\"/>
     <General>
       <SessionStorage Value="InProjectDir"/>
@@ -52,9 +52,10 @@
       <Version Value="2"/>
     </PublishOptions>
     <RunParams>
-      <local>
-        <FormatVersion Value="1"/>
-      </local>
+      <FormatVersion Value="2"/>
+      <Modes Count="1">
+        <Mode0 Name="default"/>
+      </Modes>
     </RunParams>
     <RequiredPackages Count="2">
       <Item1>

+ 88 - 55
test/test_materialdesign/mdbutton_tab/umain.lfm

@@ -1,36 +1,37 @@
 object Form1: TForm1
   Left = 438
-  Height = 400
+  Height = 320
   Top = 174
-  Width = 640
+  Width = 512
   Caption = 'Tabs'
-  ClientHeight = 400
-  ClientWidth = 640
+  ClientHeight = 320
+  ClientWidth = 512
   Color = clWhite
-  DesignTimePPI = 120
   OnCreate = FormCreate
   Position = poScreenCenter
-  LCLVersion = '1.8.4.0'
+  LCLVersion = '2.0.10.0'
   object PageControl1: TPageControl
-    Left = 10
-    Height = 320
-    Top = 70
-    Width = 620
+    Left = 8
+    Height = 255
+    Top = 57
+    Width = 496
     ActivePage = TabSheet1
     Align = alClient
-    BorderSpacing.Around = 10
+    BorderSpacing.Around = 8
+    ParentFont = False
     ShowTabs = False
     TabIndex = 0
     TabOrder = 0
     object TabSheet1: TTabSheet
       Caption = 'TabSheet1'
-      ClientHeight = 312
-      ClientWidth = 612
+      ClientHeight = 247
+      ClientWidth = 488
+      ParentFont = False
       object BCMDButton4: TBCMDButton
-        Left = 8
-        Height = 30
-        Top = 16
-        Width = 120
+        Left = 6
+        Height = 25
+        Top = 13
+        Width = 101
         Animation = True
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -46,12 +47,13 @@ object Form1: TForm1
         AutoSize = True
         Caption = 'Change to left'
         OnClick = BCMDButton4Click
+        ParentFont = False
       end
       object BCMDButton10: TBCMDButton
-        Left = 8
-        Height = 30
-        Top = 56
-        Width = 121
+        Left = 6
+        Height = 25
+        Top = 45
+        Width = 102
         Animation = True
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -67,12 +69,13 @@ object Form1: TForm1
         AutoSize = True
         Caption = 'Change to top'
         OnClick = BCMDButton10Click
+        ParentFont = False
       end
       object BCMDButton11: TBCMDButton
-        Left = 8
-        Height = 30
-        Top = 96
-        Width = 129
+        Left = 6
+        Height = 25
+        Top = 77
+        Width = 109
         Animation = True
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -88,12 +91,13 @@ object Form1: TForm1
         AutoSize = True
         Caption = 'Change to right'
         OnClick = BCMDButton11Click
+        ParentFont = False
       end
       object BCMDButton12: TBCMDButton
-        Left = 8
-        Height = 30
-        Top = 136
-        Width = 148
+        Left = 6
+        Height = 25
+        Top = 109
+        Width = 124
         Animation = True
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -109,12 +113,13 @@ object Form1: TForm1
         AutoSize = True
         Caption = 'Change to bottom'
         OnClick = BCMDButton12Click
+        ParentFont = False
       end
       object BCMDButton13: TBCMDButton
-        Left = 8
-        Height = 30
-        Top = 176
-        Width = 112
+        Left = 6
+        Height = 25
+        Top = 141
+        Width = 100
         Animation = True
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -132,16 +137,37 @@ object Form1: TForm1
         AutoSize = True
         Caption = 'Animation'
         OnClick = BCMDButton13Click
+        ParentFont = False
+      end
+      object ColorBox1: TColorBox
+        Left = 168
+        Height = 22
+        Top = 40
+        Width = 100
+        Selected = clBlue
+        ItemHeight = 16
+        OnChange = ColorBox1Change
+        TabOrder = 0
+      end
+      object StaticText1: TStaticText
+        Left = 168
+        Height = 16
+        Top = 16
+        Width = 89
+        AutoSize = True
+        Caption = 'CheckmarkColor'
+        TabOrder = 1
       end
     end
     object TabSheet2: TTabSheet
       Caption = 'TabSheet2'
       ClientHeight = 312
       ClientWidth = 612
+      ParentFont = False
       object BCMDButton5: TBCMDButton
-        Left = 8
+        Left = 6
         Height = 30
-        Top = 16
+        Top = 13
         Width = 139
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -156,16 +182,18 @@ object Form1: TForm1
         TextProportionalRatio = 0.5
         AutoSize = True
         Caption = 'Hello from Page 2'
+        ParentFont = False
       end
     end
     object TabSheet3: TTabSheet
       Caption = 'TabSheet3'
       ClientHeight = 312
       ClientWidth = 612
+      ParentFont = False
       object BCMDButton6: TBCMDButton
-        Left = 8
+        Left = 6
         Height = 30
-        Top = 16
+        Top = 13
         Width = 139
         StyleNormal.Color = clWhite
         StyleNormal.TextColor = clBlack
@@ -180,31 +208,33 @@ object Form1: TForm1
         TextProportionalRatio = 0.5
         AutoSize = True
         Caption = 'Hello from Page 3'
+        ParentFont = False
       end
     end
   end
   object Panel2: TPanel
-    Left = 10
-    Height = 50
-    Top = 10
-    Width = 620
+    Left = 8
+    Height = 41
+    Top = 8
+    Width = 496
     Align = alTop
     AutoSize = True
-    BorderSpacing.Around = 10
+    BorderSpacing.Around = 8
     BevelOuter = bvNone
     ChildSizing.Layout = cclLeftToRightThenTopToBottom
     ChildSizing.ControlsPerLine = 3
-    ClientHeight = 50
-    ClientWidth = 620
+    ClientHeight = 41
+    ClientWidth = 496
     Color = clWhite
     ParentColor = False
+    ParentFont = False
     TabOrder = 1
     object BCMDButton7: TBCMDButton
       Cursor = crHandPoint
       Left = 0
-      Height = 50
+      Height = 41
       Top = 0
-      Width = 91
+      Width = 77
       Animation = True
       StyleNormal.Color = clWhite
       StyleNormal.TextColor = clBlack
@@ -220,16 +250,17 @@ object Form1: TForm1
       TextProportional = False
       TextProportionalRatio = 0.5
       AutoSize = True
-      BorderSpacing.InnerBorder = 20
+      BorderSpacing.InnerBorder = 16
       Caption = 'Page 1'
       OnClick = BCMDButton1Click
+      ParentFont = False
     end
     object BCMDButton8: TBCMDButton
       Cursor = crHandPoint
-      Left = 91
-      Height = 50
+      Left = 77
+      Height = 41
       Top = 0
-      Width = 91
+      Width = 77
       Animation = True
       StyleNormal.Color = clWhite
       StyleNormal.TextColor = clBlack
@@ -244,16 +275,17 @@ object Form1: TForm1
       TextProportional = False
       TextProportionalRatio = 0.5
       AutoSize = True
-      BorderSpacing.InnerBorder = 20
+      BorderSpacing.InnerBorder = 16
       Caption = 'Page 2'
       OnClick = BCMDButton2Click
+      ParentFont = False
     end
     object BCMDButton9: TBCMDButton
       Cursor = crHandPoint
-      Left = 182
-      Height = 50
+      Left = 154
+      Height = 41
       Top = 0
-      Width = 91
+      Width = 77
       Animation = True
       StyleNormal.Color = clWhite
       StyleNormal.TextColor = clBlack
@@ -268,9 +300,10 @@ object Form1: TForm1
       TextProportional = False
       TextProportionalRatio = 0.5
       AutoSize = True
-      BorderSpacing.InnerBorder = 20
+      BorderSpacing.InnerBorder = 16
       Caption = 'Page 3'
       OnClick = BCMDButton3Click
+      ParentFont = False
     end
   end
 end

+ 20 - 1
test/test_materialdesign/mdbutton_tab/umain.pas

@@ -6,7 +6,7 @@ interface
 
 uses
   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
-  BCMDButton;
+  ColorBox, StdCtrls, BCMDButton;
 
 type
 
@@ -23,11 +23,14 @@ type
     BCMDButton7: TBCMDButton;
     BCMDButton8: TBCMDButton;
     BCMDButton9: TBCMDButton;
+    ColorBox1: TColorBox;
     PageControl1: TPageControl;
     Panel2: TPanel;
+    StaticText1: TStaticText;
     TabSheet1: TTabSheet;
     TabSheet2: TTabSheet;
     TabSheet3: TTabSheet;
+    procedure ColorBox1Change(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure BCMDButton10Click(Sender: TObject);
     procedure BCMDButton11Click(Sender: TObject);
@@ -60,24 +63,38 @@ end;
 procedure TForm1.FormCreate(Sender: TObject);
 begin
   PageControl1.ActivePageIndex := 0;
+  BCMDBUTTONCHECKMARKPOSITION := cmpBottom;
+  BCMDBUTTONCHECKMARKCOLOR    := ColorBox1.Selected;
+end;
+
+procedure TForm1.ColorBox1Change(Sender: TObject);
+begin
+  BCMDBUTTONCHECKMARKCOLOR    := ColorBox1.Selected;
+  Panel2.Invalidate;
 end;
 
 procedure TForm1.BCMDButton10Click(Sender: TObject);
 begin
+  BCMDBUTTONCHECKMARKPOSITION := cmpBottom;
   Panel2.ChildSizing.Layout := cclLeftToRightThenTopToBottom;
   Panel2.Align := alTop;
+  Panel2.Invalidate;
 end;
 
 procedure TForm1.BCMDButton11Click(Sender: TObject);
 begin
+  BCMDBUTTONCHECKMARKPOSITION := cmpRight;
   Panel2.ChildSizing.Layout := cclTopToBottomThenLeftToRight;
   Panel2.Align := alRight;
+  Panel2.Invalidate;
 end;
 
 procedure TForm1.BCMDButton12Click(Sender: TObject);
 begin
+  BCMDBUTTONCHECKMARKPOSITION := cmpTop;
   Panel2.ChildSizing.Layout := cclLeftToRightThenTopToBottom;
   Panel2.Align := alBottom;
+  Panel2.Invalidate;
 end;
 
 procedure TForm1.BCMDButton13Click(Sender: TObject);
@@ -97,8 +114,10 @@ end;
 
 procedure TForm1.BCMDButton4Click(Sender: TObject);
 begin
+  BCMDBUTTONCHECKMARKPOSITION := cmpLeft;
   Panel2.ChildSizing.Layout := cclTopToBottomThenLeftToRight;
   Panel2.Align := alLeft;
+  Panel2.Invalidate;
 end;
 
 end.