mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 08:09:34 +02:00
IDEIntf: improved default window position handling. Issue #28995
git-svn-id: trunk@50509 -
This commit is contained in:
parent
6dbbab636b
commit
54ec800040
@ -1727,18 +1727,26 @@ end;
|
|||||||
procedure TSimpleWindowLayoutList.ApplyAndShow(Sender: TObject; AForm: TCustomForm;
|
procedure TSimpleWindowLayoutList.ApplyAndShow(Sender: TObject; AForm: TCustomForm;
|
||||||
BringToFront: boolean; AMoveToVisbleMode: TLayoutMoveToVisbleMode);
|
BringToFront: boolean; AMoveToVisbleMode: TLayoutMoveToVisbleMode);
|
||||||
|
|
||||||
function IsAnyCornerVisible(AForm: TCustomForm; AThreshold: Integer = 50): Boolean;
|
function IsFormMovable(AForm: TCustomForm; BorderX: Integer = 100;
|
||||||
|
BorderTop: Integer = 0; BorderBottom: Integer = 50): Boolean;
|
||||||
var
|
var
|
||||||
Overlap: TRect;
|
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
xFormRect, xWA, xRectLT, xRectRT, xRectCT: TRect;
|
||||||
begin
|
begin
|
||||||
|
xFormRect := AForm.BoundsRect;
|
||||||
Result := False;
|
Result := False;
|
||||||
for I := 0 to Screen.MonitorCount-1 do
|
for I := 0 to Screen.MonitorCount-1 do
|
||||||
begin
|
begin
|
||||||
Overlap:=Rect(0,0,0,0);
|
xWA := Screen.Monitors[I].WorkareaRect;
|
||||||
IntersectRect(Overlap, AForm.BoundsRect, Screen.Monitors[I].WorkareaRect);
|
//the user must be able to move the window
|
||||||
if (Overlap.Bottom > Overlap.Top + Min(AForm.Height, AThreshold)) and
|
// - that means we check the topleft, topcenter and topright coordinates of the form
|
||||||
(Overlap.Right > Overlap.Left + Min(AForm.Width, AThreshold))
|
// if they are movable
|
||||||
|
xRectLT := Rect(xWA.Left-BorderX, xWA.Top-BorderTop, xWA.Right-BorderX, xWA.Bottom-BorderBottom);
|
||||||
|
xRectCT := Rect(xWA.Left, xWA.Top-BorderTop, xWA.Right, xWA.Bottom-BorderBottom);
|
||||||
|
xRectRT := Rect(xWA.Left+BorderX, xWA.Top-BorderTop, BorderX, xWA.Bottom-BorderBottom);
|
||||||
|
if PtInRect(xRectLT, xFormRect.TopLeft)
|
||||||
|
or PtInRect(xRectCT, Point((xFormRect.Left+xFormRect.Right) div 2, AForm.Top))
|
||||||
|
or PtInRect(xRectRT, Point(xFormRect.Right, AForm.Top))
|
||||||
then
|
then
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
@ -1836,7 +1844,7 @@ begin
|
|||||||
NewBounds.Right:=Max(NewBounds.Left+100,NewBounds.Right);
|
NewBounds.Right:=Max(NewBounds.Left+100,NewBounds.Right);
|
||||||
NewBounds.Bottom:=Max(NewBounds.Top+100,NewBounds.Bottom);
|
NewBounds.Bottom:=Max(NewBounds.Top+100,NewBounds.Bottom);
|
||||||
AForm.BoundsRect:=NewBounds;
|
AForm.BoundsRect:=NewBounds;
|
||||||
AMoveToVisbleMode := vmAlwaysMoveToVisible;
|
AMoveToVisbleMode := vmOnlyMoveOffScreenToVisible;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
if (AForm.WindowState in [wsNormal,wsMaximized]) and BringToFront then
|
if (AForm.WindowState in [wsNormal,wsMaximized]) and BringToFront then
|
||||||
@ -1848,7 +1856,7 @@ begin
|
|||||||
|
|
||||||
if (AMoveToVisbleMode = vmAlwaysMoveToVisible) or
|
if (AMoveToVisbleMode = vmAlwaysMoveToVisible) or
|
||||||
( (AMoveToVisbleMode = vmOnlyMoveOffScreenToVisible) and
|
( (AMoveToVisbleMode = vmOnlyMoveOffScreenToVisible) and
|
||||||
(not IsAnyCornerVisible(AForm)) )
|
(not IsFormMovable(AForm)) )
|
||||||
then
|
then
|
||||||
AForm.EnsureVisible(true)
|
AForm.EnsureVisible(true)
|
||||||
else
|
else
|
||||||
@ -1871,7 +1879,7 @@ begin
|
|||||||
AForm.Visible := False;
|
AForm.Visible := False;
|
||||||
if (AMoveToVisbleMode = vmAlwaysMoveToVisible) or
|
if (AMoveToVisbleMode = vmAlwaysMoveToVisible) or
|
||||||
( (AMoveToVisbleMode = vmOnlyMoveOffScreenToVisible) and
|
( (AMoveToVisbleMode = vmOnlyMoveOffScreenToVisible) and
|
||||||
(not IsAnyCornerVisible(AForm)) )
|
(not IsFormMovable(AForm)) )
|
||||||
then
|
then
|
||||||
AForm.EnsureVisible(true)
|
AForm.EnsureVisible(true)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user