mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 17:19:18 +01:00
LCL: fixed autosizing parent, when TLabel is anchored. bug #10557
git-svn-id: trunk@13630 -
This commit is contained in:
parent
0b84bcb377
commit
71b9a6d4c8
@ -93,24 +93,19 @@ begin
|
||||
|
||||
if AutoSizeDelayed then
|
||||
exit;
|
||||
BeginAutoSizing;
|
||||
try
|
||||
GetPreferredSize(NewWidth, NewHeight);
|
||||
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Nice ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight),' Caption="',dbgstr(Caption),'"');
|
||||
CurAnchors:=[];
|
||||
if Align in [alLeft,alRight,alBottom,alTop,alClient] then
|
||||
CurAnchors:=AnchorAlign[Align];
|
||||
CurAnchors:=Anchors+CurAnchors;
|
||||
if CurAnchors*[akLeft,akRight]=[akLeft,akRight] then
|
||||
NewWidth:=Width;
|
||||
if CurAnchors*[akTop,akBottom]=[akTop,akBottom] then
|
||||
NewHeight:=Height;
|
||||
GetPreferredSize(NewWidth, NewHeight);
|
||||
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Nice ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight),' Caption="',dbgstr(Caption),'"');
|
||||
CurAnchors:=[];
|
||||
if Align in [alLeft,alRight,alBottom,alTop,alClient] then
|
||||
CurAnchors:=AnchorAlign[Align];
|
||||
CurAnchors:=Anchors+CurAnchors;
|
||||
if CurAnchors*[akLeft,akRight]=[akLeft,akRight] then
|
||||
NewWidth:=Width;
|
||||
if CurAnchors*[akTop,akBottom]=[akTop,akBottom] then
|
||||
NewHeight:=Height;
|
||||
|
||||
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight));
|
||||
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
|
||||
finally
|
||||
EndAutoSizing;
|
||||
end;
|
||||
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight));
|
||||
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
|
||||
end;
|
||||
|
||||
procedure TCustomLabel.SetAlignment(Value : TAlignment);
|
||||
@ -169,6 +164,8 @@ procedure TCustomLabel.TextChanged;
|
||||
begin
|
||||
Invalidate;
|
||||
InvalidatePreferredSize;
|
||||
if (Parent<>nil) and Parent.AutoSize then
|
||||
Parent.AdjustSize;
|
||||
AdjustSize;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user