mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-25 15:17:15 +01:00
LCL: TToolBar: prevent endless loop if not enough space, bug #16194
git-svn-id: trunk@24412 -
This commit is contained in:
parent
e34d138307
commit
8e09f3c8dd
@ -570,10 +570,15 @@ var
|
|||||||
var
|
var
|
||||||
AlignedControl: TControl;
|
AlignedControl: TControl;
|
||||||
NewBounds: TRect;
|
NewBounds: TRect;
|
||||||
CurBounds: TRect;
|
SiblingBounds: TRect;
|
||||||
j: Integer;
|
j: Integer;
|
||||||
PreferredBtnWidth: Integer;
|
PreferredBtnWidth: Integer;
|
||||||
PreferredBtnHeight: Integer;
|
PreferredBtnHeight: Integer;
|
||||||
|
Intersects: Boolean;
|
||||||
|
IntersectsWithLimitedHeightControl: Boolean;
|
||||||
|
AnchorControl: TControl;
|
||||||
|
AnchorSide: TAnchorSideReference;
|
||||||
|
p: integer;
|
||||||
begin
|
begin
|
||||||
if (CurControl is TToolButton) and (not CurControl.AutoSize) then
|
if (CurControl is TToolButton) and (not CurControl.AutoSize) then
|
||||||
begin
|
begin
|
||||||
@ -588,37 +593,50 @@ var
|
|||||||
else
|
else
|
||||||
NewControlWidth := CurControl.Width;
|
NewControlWidth := CurControl.Width;
|
||||||
NewBounds := Bounds(x, y, NewControlWidth, ButtonHeight);
|
NewBounds := Bounds(x, y, NewControlWidth, ButtonHeight);
|
||||||
|
|
||||||
|
//DebugLn(['CalculatePosition ',DbgSName(CurControl)]);
|
||||||
repeat
|
repeat
|
||||||
// move control to the right, until it does not overlap
|
// move control to the right, until it does not overlap
|
||||||
|
IntersectsWithLimitedHeightControl:=false;
|
||||||
for j := 0 to AlignedControls.Count - 1 do
|
for j := 0 to AlignedControls.Count - 1 do
|
||||||
begin
|
begin
|
||||||
AlignedControl := TControl(AlignedControls[j]);
|
AlignedControl := TControl(AlignedControls[j]);
|
||||||
CurBounds := Bounds(AlignedControl.Left, AlignedControl.Top,
|
SiblingBounds := Bounds(AlignedControl.Left, AlignedControl.Top,
|
||||||
AlignedControl.Width, AlignedControl.Height);
|
AlignedControl.Width, AlignedControl.Height);
|
||||||
if (CurBounds.Right > NewBounds.Left) and
|
Intersects:=(SiblingBounds.Right > NewBounds.Left) and
|
||||||
(CurBounds.Left < NewBounds.Right) and
|
(SiblingBounds.Left < NewBounds.Right) and
|
||||||
(CurBounds.Bottom > NewBounds.Top) and
|
(SiblingBounds.Bottom > NewBounds.Top) and
|
||||||
(CurBounds.Top < NewBounds.Bottom) then
|
(SiblingBounds.Top < NewBounds.Bottom);
|
||||||
begin
|
if Intersects then begin
|
||||||
//DebugLn('CalculatePosition Move ',NewBounds.Left,'->',CurBounds.Right);
|
//DebugLn('CalculatePosition Move ',NewBounds.Left,'->',SiblingBounds.Right);
|
||||||
NewBounds.Left := CurBounds.Right;
|
NewBounds.Left := SiblingBounds.Right;
|
||||||
NewBounds.Right := NewBounds.Left + NewControlWidth;
|
NewBounds.Right := NewBounds.Left + NewControlWidth;
|
||||||
|
AnchorControl:=nil;
|
||||||
|
// check if bottom is anchored tp parent
|
||||||
|
if (akBottom in AlignedControl.Anchors) then
|
||||||
|
AlignedControl.AnchorSideBottom.GetSidePosition(AnchorControl,AnchorSide,P);
|
||||||
|
if AnchorControl=nil then
|
||||||
|
AnchorControl:=AlignedControl;
|
||||||
|
if not (akBottom in AnchorControl.Anchors) then
|
||||||
|
IntersectsWithLimitedHeightControl:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (not Wrapable) or (NewBounds.Right <= ARect.Right) or (NewBounds.Left = StartX) then
|
if (not Wrapable)
|
||||||
|
or (NewBounds.Right <= ARect.Right) or (NewBounds.Left = StartX)
|
||||||
|
or (not IntersectsWithLimitedHeightControl) then
|
||||||
begin
|
begin
|
||||||
// control fits into the row
|
// control fits into the row (or does not fit in the client area)
|
||||||
x := NewBounds.Left;
|
x := NewBounds.Left;
|
||||||
y := NewBounds.Top;
|
y := NewBounds.Top;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// try next row
|
// try next row
|
||||||
NewBounds.Left := StartX;
|
NewBounds.Left := StartX;
|
||||||
NewBounds.Right := NewBounds.Left + NewControlWidth;
|
NewBounds.Right := NewBounds.Left + NewControlWidth;
|
||||||
inc(NewBounds.Top, ButtonHeight);
|
inc(NewBounds.Top, ButtonHeight);
|
||||||
inc(NewBounds.Bottom, ButtonHeight);
|
inc(NewBounds.Bottom, ButtonHeight);
|
||||||
//DebugLn('CalculatePosition Next Row ',NewBounds.Left,',',NewBounds.Top);
|
//DebugLn('CalculatePosition Next Row ',DbgSName(CurControl),' ',dbgs(NewBounds));
|
||||||
until False;
|
until False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user