2
0
Эх сурвалжийг харах

add DisabledColor for text

Johann ELSASS 4 жил өмнө
parent
commit
af85ce8ec0
7 өөрчлөгдсөн 30 нэмэгдсэн , 14 устгасан
  1. 2 2
      bcbutton.pas
  2. 2 2
      bcbuttonfocus.pas
  3. 1 1
      bclabel.pas
  4. 1 1
      bcpanel.pas
  5. 6 3
      bctools.pas
  6. 17 4
      bctypes.pas
  7. 1 1
      bgrasvgtheme.pas

+ 2 - 2
bcbutton.pas

@@ -844,7 +844,7 @@ begin
   if FTextApplyGlobalOpacity then
   begin
     { Drawing text }
-    RenderText(r, scaledState.FontEx, actualCaption, ABGRA);
+    RenderText(r, scaledState.FontEx, actualCaption, ABGRA, Enabled);
     RenderGlyph(r_g, g);
     { Set global opacity }
     ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
@@ -854,7 +854,7 @@ begin
     { Set global opacity }
     ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
     { Drawing text }
-    RenderText(r, scaledState.FontEx, actualCaption, ABGRA);
+    RenderText(r, scaledState.FontEx, actualCaption, ABGRA, Enabled);
     RenderGlyph(r_g, g);
   end;
   if g <> FGlyph then g.Free;

+ 2 - 2
bcbuttonfocus.pas

@@ -775,7 +775,7 @@ begin
   if FTextApplyGlobalOpacity then
   begin
     { Drawing text }
-    RenderText(r, AState.FontEx, actualCaption, ABGRA);
+    RenderText(r, AState.FontEx, actualCaption, ABGRA, Enabled);
     RenderGlyph(r_g, g);
     { Set global opacity }
     ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
@@ -785,7 +785,7 @@ begin
     { Set global opacity }
     ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
     { Drawing text }
-    RenderText(r, AState.FontEx, actualCaption, ABGRA);
+    RenderText(r, AState.FontEx, actualCaption, ABGRA, Enabled);
     RenderGlyph(r_g, g);
   end;
   if g <> FGlyph then g.Free;

+ 1 - 1
bclabel.pas

@@ -156,7 +156,7 @@ begin
   CalculateBorderRect(FBorder,r);
 
   RenderBackgroundAndBorder(FBGRA.ClipRect, FBackground, TBGRABitmap(FBGRA), FRounding, FBorder, FInnerMargin);
-  RenderText(FBGRA.ClipRect, FFontEx, Caption, TBGRABitmap(FBGRA));
+  RenderText(FBGRA.ClipRect, FFontEx, Caption, TBGRABitmap(FBGRA), Enabled);
 
   {$IFDEF INDEBUG}
   FRenderCount := FRenderCount +1;

+ 1 - 1
bcpanel.pas

@@ -271,7 +271,7 @@ begin
   end;
 
   if Caption <> '' then
-    RenderText(r,FFontEx,Caption,TBGRABitmap(FBGRA));
+    RenderText(r,FFontEx,Caption,TBGRABitmap(FBGRA),Enabled);
 
   if Assigned(FOnAfterRenderBCPanel) then
     FOnAfterRenderBCPanel(Self, FBGRA, r);

+ 6 - 3
bctools.pas

@@ -68,7 +68,7 @@ procedure RenderBorderF(x1,y1,x2,y2: single; ABorder: TBCBorder;
   ATargetBGRA: TBGRABitmap; ARounding: TBCRounding = nil);
 // Render BCFont (used e.g. by TBCButton, TBCPanel, TBCLabel)
 procedure RenderText(const ARect: TRect; AFont: TBCFont;
-  const AText: String; ATargetBGRA: TBGRABitmap);
+  const AText: String; ATargetBGRA: TBGRABitmap; AEnabled: boolean);
 // Return LCL horizontal equivalent for BCAlignment
 function BCAlign2HAlign(AAlign: TBCAlignment): TAlignment;
 // Return LCL vertical equivalent for BCAlignment
@@ -202,13 +202,14 @@ begin
 end;
 
 procedure RenderText(const ARect: TRect; AFont: TBCFont;
-  const AText: String; ATargetBGRA: TBGRABitmap);
+  const AText: String; ATargetBGRA: TBGRABitmap; AEnabled: boolean);
 var
   shd: TBGRABitmap;
   hal: TAlignment;
   val: TTextLayout;
   st: TTextStyle;
   r: TRect;
+  c: TColor;
 begin
   if AText = '' then exit;
 
@@ -245,7 +246,9 @@ begin
     shd.Free;
   end;
 
-  ATargetBGRA.TextRect(r,r.Left,r.Top,AText,st,AFont.Color);
+  if AEnabled or (AFont.DisabledColor = clNone) then
+     c := AFont.Color else c := AFont.DisabledColor;
+  ATargetBGRA.TextRect(r,r.Left,r.Top,AText,st,c);
 
 end;
 

+ 17 - 4
bctypes.pas

@@ -166,7 +166,7 @@ type
 
   TBCFont = class(TBCProperty)
   private
-    FColor: TColor;
+    FColor, FDisabledColor: TColor;
     FEndEllipsis: boolean;
     FFontQuality: TBGRAFontQuality;
     FHeight: integer;
@@ -185,8 +185,9 @@ type
     FStyle: TFontStyles;
     FTextAlignment: TBCAlignment;
     FWordBreak: boolean;
-    function IsNamStored: boolean;
+    function IsNameStored: boolean;
     procedure SetColor(AValue: TColor);
+    procedure SetDisabledColor(AValue: TColor);
     procedure SetEndEllipsis(AValue: boolean);
     procedure SetFontQuality(AValue: TBGRAFontQuality);
     procedure SetHeight(AValue: integer);
@@ -211,10 +212,11 @@ type
     procedure Scale(AScale: single; APreserveDefaultHeight: boolean = true);
   published
     property Color: TColor read FColor write SetColor;
+    property DisabledColor: TColor read FDisabledColor write SetDisabledColor default clNone;
     property EndEllipsis: boolean read FEndEllipsis write SetEndEllipsis default false;
     property FontQuality: TBGRAFontQuality read FFontQuality write SetFontQuality;
     property Height: integer read FHeight write SetHeight default 0;
-    property Name: string read FName write SetName stored IsNamStored;
+    property Name: string read FName write SetName stored IsNameStored;
     property SingleLine: boolean read FSingleLine write SetSingleLine default true;
     property Shadow: boolean read FShadow write SetShadow;
     property ShadowColor: TColor read FShadowColor write SetShadowColor default clBlack;
@@ -641,7 +643,7 @@ end;
 
 { TBCFont }
 
-function TBCFont.IsNamStored: boolean;
+function TBCFont.IsNameStored: boolean;
 begin
   Result := DefFontData.Name <> Name;
 end;
@@ -655,6 +657,15 @@ begin
   Change;
 end;
 
+procedure TBCFont.SetDisabledColor(AValue: TColor);
+begin
+  if FDisabledColor = AValue then
+    Exit;
+  FDisabledColor := AValue;
+
+  Change;
+end;
+
 procedure TBCFont.SetEndEllipsis(AValue: boolean);
 begin
   if FEndEllipsis = AValue then
@@ -842,6 +853,7 @@ begin
   FStyle := [];
   FName := DefFontData.Name;
   FColor := clDefault;
+  FDisabledColor := clNone;
   FWordBreak := False;
   FSingleLine := True;
   FEndEllipsis := False;
@@ -852,6 +864,7 @@ begin
   if Source is TBCFont then
   begin
     FColor := TBCFont(Source).FColor;
+    FDisabledColor := TBCFont(Source).FDisabledColor;
     FEndEllipsis := TBCFont(Source).FEndEllipsis;
     FFontQuality := TBCFont(Source).FFontQuality;
     FHeight := TBCFont(Source).FHeight;

+ 1 - 1
bgrasvgtheme.pas

@@ -698,7 +698,7 @@ begin
       ScaleForBitmap(GlyphTextSpacing), actualCaption, bcFont);
     if not rGlyph.IsEmpty then
       AImageList.Draw(AImageIndex, Bitmap, RectF(rGlyph));
-    RenderText(r, bcFont, actualCaption, Bitmap);
+    RenderText(r, bcFont, actualCaption, Bitmap, State <> btbsDisabled);
 
     ColorizeSurface(ASurface, State);
     DrawBitmap;