Forráskód Böngészése

Merge pull request #212 from melchiorrecaruso/dev-bgracontrols

Fix for issues "TShapeLineBGRA line centering" and "TBCLeaLed centering".
Leandro Oscar Ezequiel Diaz 11 hónapja
szülő
commit
cff94a35a8
3 módosított fájl, 23 hozzáadás és 27 törlés
  1. 2 2
      atshapelinebgra.pas
  2. 12 17
      bclealed.pas
  3. 9 8
      bclearingslider.pas

+ 2 - 2
atshapelinebgra.pas

@@ -210,7 +210,7 @@ begin
   case FLineDir of
   case FLineDir of
     drLeftRight:
     drLeftRight:
       begin
       begin
-        start := (Height - FLineWidth) div 2;
+        start := (Height -1) div 2;
         bgra.CanvasBGRA.Pen.Width:= FLineWidth;
         bgra.CanvasBGRA.Pen.Width:= FLineWidth;
         bgra.CanvasBGRA.MoveTo(IfThen(FArrow1, FArrowFactor), start);
         bgra.CanvasBGRA.MoveTo(IfThen(FArrow1, FArrowFactor), start);
         bgra.CanvasBGRA.LineTo(Width-IfThen(FArrow2, FArrowFactor), Start);
         bgra.CanvasBGRA.LineTo(Width-IfThen(FArrow2, FArrowFactor), Start);
@@ -235,7 +235,7 @@ begin
 
 
     drUpDown:
     drUpDown:
       begin
       begin
-        start := (Width - FLineWidth) div 2;
+        start := (Width -1) div 2;
         bgra.CanvasBGRA.Pen.Width:= FLineWidth;
         bgra.CanvasBGRA.Pen.Width:= FLineWidth;
         bgra.CanvasBGRA.MoveTo(start, IfThen(FArrow1, FArrowFactor));
         bgra.CanvasBGRA.MoveTo(start, IfThen(FArrow1, FArrowFactor));
         bgra.CanvasBGRA.LineTo(start, Height-IfThen(FArrow2, FArrowFactor));
         bgra.CanvasBGRA.LineTo(start, Height-IfThen(FArrow2, FArrowFactor));

+ 12 - 17
bclealed.pas

@@ -348,7 +348,6 @@ end;
 
 
 procedure TBCLeaLED.Redraw;
 procedure TBCLeaLED.Redraw;
 var
 var
-  EffectiveSize: integer;
   Blur: TBGRABitmap;
   Blur: TBGRABitmap;
   Mask, Mask2: TBGRABitmap;
   Mask, Mask2: TBGRABitmap;
   Phong: TPhongShading;
   Phong: TPhongShading;
@@ -357,23 +356,19 @@ begin
   FBitmap.SetSize(Width, Height);
   FBitmap.SetSize(Width, Height);
   FBitmap.Fill(FBkgColor);
   FBitmap.Fill(FBkgColor);
 
 
-  if Width < Height then
-    EffectiveSize := Width
-  else
-    EffectiveSize := Height;
-  if EffectiveSize < 2 then exit;
+  if (Width < 2) or (Height < 2) then exit;
   ScaledSize := Scale96ToForm(FSize);
   ScaledSize := Scale96ToForm(FSize);
   ScaledPhongSize := Scale96ToForm(5);
   ScaledPhongSize := Scale96ToForm(5);
 
 
   if Enabled then
   if Enabled then
   begin
   begin
     if FValue then
     if FValue then
-      FBitmap.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, FColorOn)
+      FBitmap.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, FColorOn)
     else
     else
-      FBitmap.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, FColorOff);
+      FBitmap.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, FColorOff);
   end
   end
   else
   else
-    FBitmap.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, clGray);
+    FBitmap.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, clGray);
 
 
   if (FStyle = zsRaised) or (FStyle = zsLowered) then
   if (FStyle = zsRaised) or (FStyle = zsLowered) then
   begin
   begin
@@ -405,9 +400,9 @@ begin
     Phong.Free;
     Phong.Free;
     Blur.Free;
     Blur.Free;
 
 
-    Mask := TBGRABitmap.Create(EffectiveSize, EffectiveSize, BGRABlack);
-    Mask.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, BGRAWhite);
-    Mask2 := TBGRABitmap.Create(EffectiveSize, EffectiveSize, ColorToBGRA(ColorToRGB(FBkgColor)));
+    Mask := TBGRABitmap.Create(Width, Height, BGRABlack);
+    Mask.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, BGRAWhite);
+    Mask2 := TBGRABitmap.Create(Width, Height, ColorToBGRA(ColorToRGB(FBkgColor)));
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.ApplyMask(Mask);
     Mask2.ApplyMask(Mask);
     Mask.Free;
     Mask.Free;
@@ -417,9 +412,9 @@ begin
   end
   end
   else
   else
   begin
   begin
-    Mask := TBGRABitmap.Create(EffectiveSize, EffectiveSize, BGRABlack);
-    Mask.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, BGRAWhite);
-    Mask2 := TBGRABitmap.Create(EffectiveSize, EffectiveSize, ColorToBGRA(ColorToRGB(FBkgColor)));
+    Mask := TBGRABitmap.Create(Width, Height, BGRABlack);
+    Mask.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, BGRAWhite);
+    Mask2 := TBGRABitmap.Create(Width, Height, ColorToBGRA(ColorToRGB(FBkgColor)));
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.ApplyMask(Mask);
     Mask2.ApplyMask(Mask);
     Mask.Free;
     Mask.Free;
@@ -430,8 +425,8 @@ begin
 
 
   if FValue then
   if FValue then
   begin
   begin
-    Mask := TBGRABitmap.Create(EffectiveSize, EffectiveSize);
-    Mask.FillEllipseAntialias((EffectiveSize - 1) / 2, (EffectiveSize - 1) / 2, ScaledSize, ScaledSize, FColorOn);
+    Mask := TBGRABitmap.Create(Width, Height);
+    Mask.FillEllipseAntialias((Width-1)/2, (Height-1)/2, ScaledSize, ScaledSize, FColorOn);
     Mask := Mask.FilterBlurRadial(ScaledPhongSize * 2, ScaledPhongSize * 2, rbFast);
     Mask := Mask.FilterBlurRadial(ScaledPhongSize * 2, ScaledPhongSize * 2, rbFast);
     FBitmap.BlendImageOver(0, 0, Mask, boGlow);
     FBitmap.BlendImageOver(0, 0, Mask, boGlow);
     Mask.Free;
     Mask.Free;

+ 9 - 8
bclearingslider.pas

@@ -135,6 +135,7 @@ type
 
 
   published
   published
     property Align;
     property Align;
+    property BorderSpacing;
     property Caption;
     property Caption;
     property Color;
     property Color;
     property Cursor;
     property Cursor;
@@ -402,7 +403,7 @@ begin
 
 
 
 
   FBitmap.Canvas2D.resetTransform;
   FBitmap.Canvas2D.resetTransform;
-  FBitmap.Canvas2D.translate(FBitmap.Width / 2, FBitmap.Height / 2);
+  FBitmap.Canvas2D.translate((FBitmap.Width-1)/2, (FBitmap.Height-1)/2);
   FBitmap.Canvas2D.rotate(pi15);
   FBitmap.Canvas2D.rotate(pi15);
 
 
   if FLineWidth = 0 then
   if FLineWidth = 0 then
@@ -437,7 +438,7 @@ begin
   if FDrawText and FDrawTextPhong then
   if FDrawText and FDrawTextPhong then
   begin
   begin
     TextStr := IntToStr(FValue);
     TextStr := IntToStr(FValue);
-    TextBmp := TextShadow(EffectiveSize, EffectiveSize, TextStr, Font.Height,
+    TextBmp := TextShadow(FBitmap.Width, FBitmap.Height, TextStr, Font.Height,
       Font.Color, FontShadowColor, FontShadowOffsetX,
       Font.Color, FontShadowColor, FontShadowOffsetX,
       FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
       FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
     TextSize:= TextBmp.TextSize(TextStr);
     TextSize:= TextBmp.TextSize(TextStr);
@@ -456,7 +457,7 @@ begin
 
 
   if rDrawCaption and rDrawCaptionPhong then
   if rDrawCaption and rDrawCaptionPhong then
   begin
   begin
-    TextBmp := TextShadow(EffectiveSize, EffectiveSize, Caption, Font.Height,
+    TextBmp := TextShadow(FBitmap.Width, FBitmap.Height, Caption, Font.Height,
                           Font.Color, FontShadowColor, FontShadowOffsetX,
                           Font.Color, FontShadowColor, FontShadowOffsetX,
                           FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
                           FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
     TextSize:= TextBmp.TextSize(Caption);
     TextSize:= TextBmp.TextSize(Caption);
@@ -504,9 +505,9 @@ begin
     Phong.Free;
     Phong.Free;
     Blur.Free;
     Blur.Free;
 
 
-    Mask := TBGRABitmap.Create(EffectiveSize, EffectiveSize, BGRABlack);
-    Mask.FillEllipseAntialias(EffectiveSize div 2, EffectiveSize div 2, EffectiveSize div 2, EffectiveSize div 2, BGRAWhite);
-    Mask2 := TBGRABitmap.Create(EffectiveSize, EffectiveSize, ColorToBGRA(ColorToRGB(FBkgColor)));
+    Mask := TBGRABitmap.Create(FBitmap.Width, FBitmap.Height, BGRABlack);
+    Mask.FillEllipseAntialias((FBitmap.Width-1)/2, (FBitmap.Height-1)/2, EffectiveSize div 2, EffectiveSize div 2, BGRAWhite);
+    Mask2 := TBGRABitmap.Create(FBitmap.Width, FBitmap.Height, ColorToBGRA(ColorToRGB(FBkgColor)));
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.PutImage(0, 0, FBitmap, dmSet);
     Mask2.ApplyMask(Mask);
     Mask2.ApplyMask(Mask);
     Mask.Free;
     Mask.Free;
@@ -518,7 +519,7 @@ begin
   if FDrawText and not FDrawTextPhong then
   if FDrawText and not FDrawTextPhong then
   begin
   begin
     TextStr := IntToStr(FValue);
     TextStr := IntToStr(FValue);
-    TextBmp := TextShadow(EffectiveSize, EffectiveSize, TextStr, Font.Height,
+    TextBmp := TextShadow(FBitmap.Width, FBitmap.Height, TextStr, Font.Height,
       Font.Color, FontShadowColor, FontShadowOffsetX,
       Font.Color, FontShadowColor, FontShadowOffsetX,
       FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
       FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
     TextSize:= TextBmp.TextSize(TextStr);
     TextSize:= TextBmp.TextSize(TextStr);
@@ -537,7 +538,7 @@ begin
 
 
   if rDrawCaption and not(rDrawCaptionPhong) then
   if rDrawCaption and not(rDrawCaptionPhong) then
   begin
   begin
-    TextBmp := TextShadow(EffectiveSize, EffectiveSize, Caption, Font.Height,
+    TextBmp := TextShadow(FBitmap.Width, FBitmap.Height, Caption, Font.Height,
                           Font.Color, FontShadowColor, FontShadowOffsetX,
                           Font.Color, FontShadowColor, FontShadowOffsetX,
                           FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
                           FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
     TextSize:= TextBmp.TextSize(Caption);
     TextSize:= TextBmp.TextSize(Caption);