LCL: Fix ChildSizing ignoring adjusted client rectangle. Issue #40838, patch by Henner Drewes.

This commit is contained in:
wp_xyz 2024-03-14 23:24:44 +01:00
parent 4c4c9631aa
commit 3aaae1a6a8

View File

@ -124,13 +124,14 @@ type
// Commented in revision 55209 // Commented in revision 55209
// procedure AlignToRight(TargetWidth: integer); // procedure AlignToRight(TargetWidth: integer);
procedure ComputeTableControlBounds(ChildSizing: TControlChildSizing; procedure ComputeTableControlBounds(ChildSizing: TControlChildSizing;
BiDiMode: TBiDiMode); BiDiMode: TBiDiMode;
const Ofs: TPoint);
function SetTableControlBounds(ChildSizing: TControlChildSizing function SetTableControlBounds(ChildSizing: TControlChildSizing
): boolean;// true if changed ): boolean;// true if changed
function AlignControlsInTable(ListOfControls: TFPList; function AlignControlsInTable(ListOfControls: TFPList;
ChildSizing: TControlChildSizing; ChildSizing: TControlChildSizing;
BiDiMode: TBiDiMode; BiDiMode: TBiDiMode;
TargetWidth, TargetHeight: integer; const TargetRect: TRect;
Apply: boolean): boolean;// true if changed Apply: boolean): boolean;// true if changed
// debugging // debugging
@ -939,9 +940,9 @@ begin
ChildSizing.ShrinkVertical:=crsAnchorAligning; ChildSizing.ShrinkVertical:=crsAnchorAligning;
ChildSizing.EnlargeVertical:=crsAnchorAligning; ChildSizing.EnlargeVertical:=crsAnchorAligning;
// compute static layout // compute static layout
r:=WinControl.GetLogicalClientRect; WinControl.GetAdjustedLogicalClientRect(r);
Box.AlignControlsInTable(AlignList,ChildSizing,WinControl.BiDiMode, Box.AlignControlsInTable(AlignList,ChildSizing,WinControl.BiDiMode,
r.Right,r.Bottom,false); r,false);
//Box.WriteDebugReport('TAutoSizeCtrlData.SetupNonAlignedChilds'); //Box.WriteDebugReport('TAutoSizeCtrlData.SetupNonAlignedChilds');
// transfer the coords of the layout // transfer the coords of the layout
for y:=0 to Box.ChildCount[asboVertical]-1 do begin for y:=0 to Box.ChildCount[asboVertical]-1 do begin
@ -2176,7 +2177,7 @@ begin
end; end;
} }
procedure TAutoSizeBox.ComputeTableControlBounds( procedure TAutoSizeBox.ComputeTableControlBounds(
ChildSizing: TControlChildSizing; BiDiMode: TBiDiMode); ChildSizing: TControlChildSizing; BiDiMode: TBiDiMode; const Ofs: TPoint);
var var
y: Integer; y: Integer;
RowBox: TAutoSizeBox; RowBox: TAutoSizeBox;
@ -2244,6 +2245,7 @@ begin
NewBounds.Right:=NewBounds.Left+NewWidth; NewBounds.Right:=NewBounds.Left+NewWidth;
NewBounds.Bottom:=NewBounds.Top+NewHeight; NewBounds.Bottom:=NewBounds.Top+NewHeight;
NewBounds.Offset(Ofs);
ControlBox.NewControlBounds:=NewBounds; ControlBox.NewControlBounds:=NewBounds;
{$IFDEF CHECK_POSITION} {$IFDEF CHECK_POSITION}
if CheckPosition(CurControl) then if CheckPosition(CurControl) then
@ -2290,15 +2292,14 @@ end;
function TAutoSizeBox.AlignControlsInTable(ListOfControls: TFPList; function TAutoSizeBox.AlignControlsInTable(ListOfControls: TFPList;
ChildSizing: TControlChildSizing; BiDiMode: TBiDiMode; ChildSizing: TControlChildSizing; BiDiMode: TBiDiMode;
TargetWidth, TargetHeight: integer; const TargetRect: TRect; Apply: boolean): boolean;
Apply: boolean): boolean;
// true if a control was modified // true if a control was modified
begin begin
SetTableControls(ListOfControls,ChildSizing,BiDiMode); SetTableControls(ListOfControls,ChildSizing,BiDiMode);
//WriteDebugReport('after SetTableControls'); //WriteDebugReport('after SetTableControls');
SumTable; SumTable;
//WriteDebugReport('after SumTable'); //WriteDebugReport('after SumTable');
ResizeTable(ChildSizing,TargetWidth,TargetHeight); ResizeTable(ChildSizing,TargetRect.Width,TargetRect.Height);
//WriteDebugReport('after ResizeTable'); //WriteDebugReport('after ResizeTable');
// Michl: Commented procedure AlignToRight because of issue #28483, afaics // Michl: Commented procedure AlignToRight because of issue #28483, afaics
@ -2308,7 +2309,7 @@ begin
// AlignToRight(TargetWidth); // AlignToRight(TargetWidth);
//WriteDebugReport('after AlignToRight'); //WriteDebugReport('after AlignToRight');
ComputeTableControlBounds(ChildSizing,BiDiMode); ComputeTableControlBounds(ChildSizing,BiDiMode, TargetRect.TopLeft);
//WriteDebugReport('after ComputeTableControlBounds'); //WriteDebugReport('after ComputeTableControlBounds');
Result:=Apply and SetTableControlBounds(ChildSizing); Result:=Apply and SetTableControlBounds(ChildSizing);
end; end;
@ -6263,9 +6264,9 @@ begin
Box:=TAutoSizeBox.Create; Box:=TAutoSizeBox.Create;
try try
r:=GetLogicalClientRect; GetAdjustedLogicalClientRect(r);
BoundsModified:=Box.AlignControlsInTable(ListOfControls,ChildSizing,BiDiMode, BoundsModified:=Box.AlignControlsInTable(ListOfControls,ChildSizing,BiDiMode,
r.Right,r.Bottom,true); r,true);
finally finally
Box.Free; Box.Free;
end; end;