mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +02:00
lcl: label: change left when making label visible for right-aligned autosized label. issue #21898
This commit is contained in:
parent
316d8c1de0
commit
369b6b255e
@ -262,6 +262,29 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomLabel.SetVisible(Value: Boolean);
|
||||||
|
var
|
||||||
|
OldWidth, OldLeft: Integer;
|
||||||
|
begin
|
||||||
|
// when changing to Visible, the width gets updated, check for right aligment and change left just like it is done in UpdateSize
|
||||||
|
// see issue #21898
|
||||||
|
if Value and not Visible then
|
||||||
|
begin
|
||||||
|
OldWidth := Width;
|
||||||
|
OldLeft := Left;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
OldWidth := -1;
|
||||||
|
OldLeft := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
inherited SetVisible(Value);
|
||||||
|
|
||||||
|
if (OldWidth>=0) and (AutoSize or OptimalFill) and (Alignment=taRightJustify)
|
||||||
|
and (OldWidth<>Width) and (OldLeft=Left) then
|
||||||
|
Left := Left-Width+OldWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomLabel.SetWordWrap
|
Method: TCustomLabel.SetWordWrap
|
||||||
Params: None
|
Params: None
|
||||||
|
@ -1598,6 +1598,7 @@ type
|
|||||||
procedure SetWordWrap(Value: Boolean);
|
procedure SetWordWrap(Value: Boolean);
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
procedure UpdateSize;
|
procedure UpdateSize;
|
||||||
|
procedure SetVisible(Value: Boolean); override;
|
||||||
|
|
||||||
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
|
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
|
||||||
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
|
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
|
||||||
|
Loading…
Reference in New Issue
Block a user