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