mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
lcl: docking
- don't crash if in InserControl DockControl = AControl - improve RemoveControl a bit git-svn-id: trunk@17863 -
This commit is contained in:
parent
7591410835
commit
1b2398da45
@ -1045,6 +1045,9 @@ end;
|
|||||||
|
|
||||||
procedure TLazDockTree.AnchorDockLayout(Zone: TLazDockZone);
|
procedure TLazDockTree.AnchorDockLayout(Zone: TLazDockZone);
|
||||||
// setup all anchors between all docked controls and helper controls
|
// setup all anchors between all docked controls and helper controls
|
||||||
|
const
|
||||||
|
SplitterWidth = 5;
|
||||||
|
SplitterHeight = 5;
|
||||||
var
|
var
|
||||||
AnchorControls: array[TAnchorKind] of TControl;
|
AnchorControls: array[TAnchorKind] of TControl;
|
||||||
a: TAnchorKind;
|
a: TAnchorKind;
|
||||||
@ -1077,7 +1080,7 @@ begin
|
|||||||
NewSplitterAnchors := [akLeft, akRight];
|
NewSplitterAnchors := [akLeft, akRight];
|
||||||
Zone.Splitter.AnchorSide[akLeft].Side := asrTop;
|
Zone.Splitter.AnchorSide[akLeft].Side := asrTop;
|
||||||
Zone.Splitter.AnchorSide[akRight].Side := asrBottom;
|
Zone.Splitter.AnchorSide[akRight].Side := asrBottom;
|
||||||
Zone.Splitter.Height := 5;
|
Zone.Splitter.Height := SplitterHeight;
|
||||||
if Zone.PrevSibling <> nil then
|
if Zone.PrevSibling <> nil then
|
||||||
Zone.Splitter.Top := (Zone.PrevSibling.Top + Zone.PrevSibling.Height) - DefaultDockGrabberSize;
|
Zone.Splitter.Top := (Zone.PrevSibling.Top + Zone.PrevSibling.Height) - DefaultDockGrabberSize;
|
||||||
Zone.Splitter.ResizeAnchor := akBottom;
|
Zone.Splitter.ResizeAnchor := akBottom;
|
||||||
@ -1088,7 +1091,7 @@ begin
|
|||||||
NewSplitterAnchors := [akTop, akBottom];
|
NewSplitterAnchors := [akTop, akBottom];
|
||||||
Zone.Splitter.AnchorSide[akTop].Side := asrTop;
|
Zone.Splitter.AnchorSide[akTop].Side := asrTop;
|
||||||
Zone.Splitter.AnchorSide[akBottom].Side := asrBottom;
|
Zone.Splitter.AnchorSide[akBottom].Side := asrBottom;
|
||||||
Zone.Splitter.Width := 5;
|
Zone.Splitter.Width := SplitterWidth;
|
||||||
if Zone.PrevSibling <> nil then
|
if Zone.PrevSibling <> nil then
|
||||||
Zone.Splitter.Left := (Zone.PrevSibling.Left + Zone.PrevSibling.Width) - DefaultDockGrabberSize;
|
Zone.Splitter.Left := (Zone.PrevSibling.Left + Zone.PrevSibling.Width) - DefaultDockGrabberSize;
|
||||||
Zone.Splitter.ResizeAnchor := akRight;
|
Zone.Splitter.ResizeAnchor := akRight;
|
||||||
@ -1216,25 +1219,21 @@ procedure TLazDockTree.InsertControl(AControl: TControl; InsertAt: TAlign;
|
|||||||
AControl.AutoSize := False;
|
AControl.AutoSize := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
SplitterWidth = 5;
|
|
||||||
SplitterHeight = 5;
|
|
||||||
var
|
var
|
||||||
DropZone: TDockZone;
|
DropZone, OldParentZone, NewParentZone: TDockZone;
|
||||||
NewZone: TLazDockZone;
|
NewZone: TLazDockZone;
|
||||||
NewOrientation: TDockOrientation;
|
NewOrientation: TDockOrientation;
|
||||||
NeedNewParentZone: Boolean;
|
NeedNewParentZone: Boolean;
|
||||||
NewParentZone: TDockZone;
|
|
||||||
OldParentZone: TDockZone;
|
|
||||||
NewBounds: TRect;
|
NewBounds: TRect;
|
||||||
begin
|
begin
|
||||||
if DropControl=nil then
|
if (DropControl = nil) or (DropControl = AControl) then
|
||||||
DropControl:=DockSite;
|
DropControl := DockSite;
|
||||||
DropZone:=RootZone.FindZone(DropControl);
|
|
||||||
if DropZone=nil then
|
DropZone := RootZone.FindZone(DropControl);
|
||||||
|
if DropZone = nil then
|
||||||
raise Exception.Create('TLazDockTree.InsertControl DropControl is not part of this TDockTree');
|
raise Exception.Create('TLazDockTree.InsertControl DropControl is not part of this TDockTree');
|
||||||
|
|
||||||
NewOrientation:=DockAlignOrientations[InsertAt];
|
NewOrientation := DockAlignOrientations[InsertAt];
|
||||||
|
|
||||||
// undock
|
// undock
|
||||||
UndockControlForDocking(AControl);
|
UndockControlForDocking(AControl);
|
||||||
@ -1339,12 +1338,16 @@ var
|
|||||||
begin
|
begin
|
||||||
RemoveZone := RootZone.FindZone(AControl) as TLazDockZone;
|
RemoveZone := RootZone.FindZone(AControl) as TLazDockZone;
|
||||||
|
|
||||||
if (RemoveZone <> nil) and (RemoveZone.ChildCount > 0) then
|
// no such control => exit
|
||||||
|
if RemoveZone = nil then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
// has children
|
||||||
|
if (RemoveZone.ChildCount > 0) then
|
||||||
raise Exception.Create('TLazDockTree.RemoveControl RemoveZone.ChildCount > 0');
|
raise Exception.Create('TLazDockTree.RemoveControl RemoveZone.ChildCount > 0');
|
||||||
|
|
||||||
// destroy child zone and all parents if they does not contain anything else
|
// destroy child zone and all parents if they does not contain anything else
|
||||||
while (RemoveZone <> RootZone) and
|
while (RemoveZone <> RootZone) and
|
||||||
(RemoveZone <> nil) and
|
|
||||||
(RemoveZone.ChildCount = 0) do
|
(RemoveZone.ChildCount = 0) do
|
||||||
begin
|
begin
|
||||||
ParentZone := RemoveZone.Parent as TLazDockZone;
|
ParentZone := RemoveZone.Parent as TLazDockZone;
|
||||||
@ -1357,7 +1360,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Build dock layout (anchors, splitters, pages)
|
// Build dock layout (anchors, splitters, pages)
|
||||||
if (RemoveZone <> nil) and (RemoveZone <> RootZone) then
|
if (RemoveZone.Parent <> nil) then
|
||||||
BuildDockLayout(RemoveZone.Parent as TLazDockZone)
|
BuildDockLayout(RemoveZone.Parent as TLazDockZone)
|
||||||
else
|
else
|
||||||
BuildDockLayout(RootZone as TLazDockZone);
|
BuildDockLayout(RootZone as TLazDockZone);
|
||||||
|
Loading…
Reference in New Issue
Block a user