Browse Source

Merge pull request #256 from sganz/dev-bgracontrols

Updated AutoScale functionality and Test Program
Leandro Oscar Ezequiel Diaz 4 months ago
parent
commit
8a6d486eda
3 changed files with 34 additions and 10 deletions
  1. 20 2
      supergauge.pas
  2. 5 3
      test/test_supergauge/sgtest.lfm
  3. 9 5
      test/test_supergauge/sgtest.pas

+ 20 - 2
supergauge.pas

@@ -34,6 +34,9 @@ v2.00 - Breaking Changes from V1 SuperGauge Sandy Ganz, [email protected]
         Removed unintended exposed property on RangeLED (OK to Remove from .lfm if warned)
         Removed unintended exposed property on RangeLED (OK to Remove from .lfm if warned)
         Changed RangeLED type of rcGaugeOutOfRange to rcGaugeOverload and events to
         Changed RangeLED type of rcGaugeOutOfRange to rcGaugeOverload and events to
         make it language different then RangeCheckLED.
         make it language different then RangeCheckLED.
+v2.03 - Changed AutoScale functionality when NOT auto scaling to preserve the size
+        of the original component, so really no changes based on zoom/resolution.
+        This will alow it to draw correctly but possibly at a larger size when AutoScale is disabled.
 
 
 ******************************* END CHANGE LOG *******************************}
 ******************************* END CHANGE LOG *******************************}
 
 
@@ -48,7 +51,7 @@ uses
   BGRABitmap, BGRABitmapTypes, BGRAVectorize, BGRAPath, math, bctypes, bctools;
   BGRABitmap, BGRABitmapTypes, BGRAVectorize, BGRAPath, math, bctypes, bctools;
 
 
 const
 const
-  VERSIONSTR = '2.02';            // SG version, Should ALWAYS show as a delta when merging!
+  VERSIONSTR = '2.03';            // SG version, Should ALWAYS show as a delta when merging!
   INTERNAL_GAUGE_MIN_VALUE = 0;   // internal lowest value
   INTERNAL_GAUGE_MIN_VALUE = 0;   // internal lowest value
   INTERNAL_GAUGE_MAX_VALUE = 270; // internal highest value
   INTERNAL_GAUGE_MAX_VALUE = 270; // internal highest value
   BASELINE_SIZE = 300;            // For ResolveSizes()
   BASELINE_SIZE = 300;            // For ResolveSizes()
@@ -206,7 +209,8 @@ type
 
 
   public
   public
     { Public declarations }
     { Public declarations }
-
+    procedure AutoAdjustLayout(AMode: TLayoutAdjustmentPolicy;
+          const AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth: Integer); override;
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
 
 
@@ -334,6 +338,20 @@ end;
 {$ENDIF}
 {$ENDIF}
 
 
 { TSGCustomSuperGauge }
 { TSGCustomSuperGauge }
+procedure TSGCustomSuperGauge.AutoAdjustLayout(AMode: TLayoutAdjustmentPolicy;
+  const AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth: Integer);
+begin
+  // If autoscaling then we will let the system mess with the component size
+  // otherwise it will just leave it along as the ACTUAL size in the designer
+  // as 1:1 with no scaling on anything. By not calling AutoAdjustLayout()
+  // Scaling will be 1:1
+  //
+  // Note - that toggling the AutoScale setting will cause a repaint
+  // but NOT a resize of the Components client area
+
+  if FAutoScale then
+    inherited AutoAdjustLayout(AMode, AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth);
+end;
 
 
 constructor TSGCustomSuperGauge.Create(AOwner: TComponent);
 constructor TSGCustomSuperGauge.Create(AOwner: TComponent);
 var
 var

+ 5 - 3
test/test_supergauge/sgtest.lfm

@@ -4433,8 +4433,8 @@ object SGTestFrm: TSGTestFrm
         Height = 32
         Height = 32
         Top = 32
         Top = 32
         Width = 32
         Width = 32
-        BorderColor = clBlack
         BorderThickness = 3
         BorderThickness = 3
+        AutoScale = True
       end
       end
       object TestLedShape: TBGRAShape
       object TestLedShape: TBGRAShape
         Left = 40
         Left = 40
@@ -5427,16 +5427,17 @@ object SGTestFrm: TSGTestFrm
       Font.Style = [fsBold]
       Font.Style = [fsBold]
       ParentFont = False
       ParentFont = False
     end
     end
-    object uELED2: TSuperLED
+    object SuperLED2: TSuperLED
       Left = 400
       Left = 400
       Height = 36
       Height = 36
       Hint = 'Gauge Overload/Underload Indicator'#13#10'Triggers if below min or above max value'
       Hint = 'Gauge Overload/Underload Indicator'#13#10'Triggers if below min or above max value'
       Top = 160
       Top = 160
       Width = 36
       Width = 36
       BorderThickness = 3
       BorderThickness = 3
+      AutoScale = True
       ShowHint = True
       ShowHint = True
     end
     end
-    object uELED1: TSuperLED
+    object SuperLED1: TSuperLED
       Left = 400
       Left = 400
       Height = 36
       Height = 36
       Hint = 'Random Mode Indicator'
       Hint = 'Random Mode Indicator'
@@ -5444,6 +5445,7 @@ object SGTestFrm: TSGTestFrm
       Width = 36
       Width = 36
       ActiveColor = clLime
       ActiveColor = clLime
       BorderThickness = 3
       BorderThickness = 3
+      AutoScale = True
       ShowHint = True
       ShowHint = True
     end
     end
   end
   end

+ 9 - 5
test/test_supergauge/sgtest.pas

@@ -14,6 +14,8 @@
 ***************************** END CONTRIBUTOR(S) *****************************}
 ***************************** END CONTRIBUTOR(S) *****************************}
 {******************************** CHANGE LOG *********************************
 {******************************** CHANGE LOG *********************************
 v2.01 - Swapped uELED component with SuperLED component
 v2.01 - Swapped uELED component with SuperLED component
+v2.02 - Updated LED component names, set LED's to use AutoScale, Minor other
+        fixes.
 ******************************* END CHANGE LOG *******************************}
 ******************************* END CHANGE LOG *******************************}
 
 
 unit sgtest;
 unit sgtest;
@@ -29,7 +31,7 @@ uses
   SuperGauge, SuperLED, about;
   SuperGauge, SuperLED, about;
 
 
 const
 const
-  VERSIONSTR = '2.01';            // SG TEST version, Should ALWAYS show as a delta when merging!
+  VERSIONSTR = '2.02';            // SG TEST version, Should ALWAYS show as a delta when merging!
 
 
 type
 type
   { TSGTestFrm }
   { TSGTestFrm }
@@ -225,8 +227,8 @@ type
     Label3: TLabel;
     Label3: TLabel;
     DispMinLbl: TLabel;
     DispMinLbl: TLabel;
     DispMinValLbl: TLabel;
     DispMinValLbl: TLabel;
-    uELED1: TSuperLED;
-    uELED2: TSuperLED;
+    SuperLED1: TSuperLED;
+    SuperLED2: TSuperLED;
     ValuePlus1Btn: TBitBtn;
     ValuePlus1Btn: TBitBtn;
     ValueMinus1Btn: TBitBtn;
     ValueMinus1Btn: TBitBtn;
     ValuePlus10Btn: TBitBtn;
     ValuePlus10Btn: TBitBtn;
@@ -1220,6 +1222,7 @@ end;
 procedure TSGTestFrm.UpdateBasicStats;
 procedure TSGTestFrm.UpdateBasicStats;
 begin
 begin
   BackgroundColorCb.Selected := SuperGauge.Color;
   BackgroundColorCb.Selected := SuperGauge.Color;
+  AutoScaleCb.Checked := SuperGauge.AutoScale;
 end;
 end;
 
 
 procedure TSGTestFrm.UpdateLTStats;
 procedure TSGTestFrm.UpdateLTStats;
@@ -1258,6 +1261,7 @@ begin
   // LED for testings.
   // LED for testings.
   // Be Fancy and if setting LED as shaded do the same for the test
   // Be Fancy and if setting LED as shaded do the same for the test
 
 
+  TestLedShape.Visible := not (SuperGauge.RangeLEDSettings.Style = lsNone);
   TestLEDShape.UseFillGradient := (SuperGauge.RangeLEDSettings.Style = lsShaded);
   TestLEDShape.UseFillGradient := (SuperGauge.RangeLEDSettings.Style = lsShaded);
 
 
   case SuperGauge.RangeLEDSettings.Shape of
   case SuperGauge.RangeLEDSettings.Shape of
@@ -3040,7 +3044,7 @@ begin
   ResetLoTics := 10;                    // 10 forces update now unless timer stopped
   ResetLoTics := 10;                    // 10 forces update now unless timer stopped
   ResetHiTics := 10;
   ResetHiTics := 10;
   Timer2.Enabled := not Timer2.Enabled; // toggle timer
   Timer2.Enabled := not Timer2.Enabled; // toggle timer
-  uELED1.Active:=Timer2.Enabled;
+  SuperLED1.Active:=Timer2.Enabled;
 end;
 end;
 
 
 procedure TSGTestFrm.MarkerRandomTestBtnClick(Sender: TObject);
 procedure TSGTestFrm.MarkerRandomTestBtnClick(Sender: TObject);
@@ -4066,7 +4070,7 @@ end;
 procedure TSGTestFrm.Timer1Timer(Sender: TObject);
 procedure TSGTestFrm.Timer1Timer(Sender: TObject);
 begin
 begin
   TimerState := not TimerState;
   TimerState := not TimerState;
-  uELED2.Active := TimerState;
+  SuperLED2.Active := TimerState;
 
 
   if TimerState then
   if TimerState then
     begin
     begin