lcl TLabel: unbind Color and Transparent to fix ParentColor issues

This commit is contained in:
Ondrej Pokorny 2022-05-03 09:39:24 +02:00
parent 4d12a06af5
commit 4ffce1ec8f
2 changed files with 5 additions and 18 deletions

View File

@ -226,7 +226,6 @@ begin
SetInitialBounds(0, 0, CX, CY);
FShowAccelChar := True;
FInternalSetBounds := False;
Color := clNone;
AutoSize := True;
// Accessibility
AccessibleRole := larLabel;
@ -234,18 +233,7 @@ end;
function TCustomLabel.GetTransparent: boolean;
begin
Result := Color = clNone;
end;
procedure TCustomLabel.SetColor(NewColor: TColor);
begin
inherited;
// if color = clnone then transparent, so not opaque
if NewColor = clNone then
ControlStyle := ControlStyle - [csOpaque]
else
ControlStyle := ControlStyle + [csOpaque];
Result := not(csOpaque in ControlStyle);
end;
{------------------------------------------------------------------------------
@ -268,10 +256,10 @@ begin
if Transparent = NewTransparent then
exit;
if NewTransparent then
Color := clNone
ControlStyle := ControlStyle - [csOpaque]
else
if Color = clNone then
Color := clBackground;
ControlStyle := ControlStyle + [csOpaque];
Invalidate;
end;
{------------------------------------------------------------------------------

View File

@ -1586,7 +1586,6 @@ type
function GetLabelText: string; virtual;
function GetTransparent: boolean;
procedure SetColor(NewColor: TColor); override;
procedure SetFocusControl(Value: TWinControl);
procedure SetLayout(Value: TTextLayout);
procedure SetShowAccelChar(Value: Boolean);
@ -1612,7 +1611,7 @@ type
procedure Paint; override;
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
property AutoSize default True;
property Color default clNone;
property Color default clDefault;
end;