mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-12 00:38:13 +02:00
lcl: docking
- delete empty parent zones when we delete control from the dock tree - optimize inserting and deleting of control into/from dock tree git-svn-id: trunk@17862 -
This commit is contained in:
parent
10b0890c9d
commit
7591410835
@ -1327,26 +1327,40 @@ begin
|
||||
end;
|
||||
|
||||
// Build dock layout (anchors, splitters, pages)
|
||||
BuildDockLayout(RootZone{NewZone.Parent} as TLazDockZone);
|
||||
if NewZone.Parent <> nil then
|
||||
BuildDockLayout(NewZone.Parent as TLazDockZone)
|
||||
else
|
||||
BuildDockLayout(RootZone as TLazDockZone);
|
||||
end;
|
||||
|
||||
procedure TLazDockTree.RemoveControl(AControl: TControl);
|
||||
var
|
||||
RemoveZone: TLazDockZone;
|
||||
RemoveZone, ParentZone: TLazDockZone;
|
||||
begin
|
||||
RemoveZone := RootZone.FindZone(AControl) as TLazDockZone;
|
||||
if RemoveZone <> nil then
|
||||
|
||||
if (RemoveZone <> nil) and (RemoveZone.ChildCount > 0) then
|
||||
raise Exception.Create('TLazDockTree.RemoveControl RemoveZone.ChildCount > 0');
|
||||
|
||||
// destroy child zone and all parents if they does not contain anything else
|
||||
while (RemoveZone <> RootZone) and
|
||||
(RemoveZone <> nil) and
|
||||
(RemoveZone.ChildCount = 0) do
|
||||
begin
|
||||
if RemoveZone.ChildCount>0 then
|
||||
raise Exception.Create('TLazDockTree.RemoveControl RemoveZone.ChildCount>0');
|
||||
ParentZone := RemoveZone.Parent as TLazDockZone;
|
||||
RemoveZone.FreeSubComponents;
|
||||
if RemoveZone.Parent<>nil then
|
||||
RemoveZone.Parent.Remove(RemoveZone);
|
||||
if ParentZone <> nil then
|
||||
ParentZone.Remove(RemoveZone);
|
||||
RemoveZone.Free;
|
||||
// try with ParentZone now
|
||||
RemoveZone := ParentZone;
|
||||
end;
|
||||
|
||||
// Build dock layout (anchors, splitters, pages)
|
||||
BuildDockLayout(RootZone as TLazDockZone);
|
||||
if (RemoveZone <> nil) and (RemoveZone <> RootZone) then
|
||||
BuildDockLayout(RemoveZone.Parent as TLazDockZone)
|
||||
else
|
||||
BuildDockLayout(RootZone as TLazDockZone);
|
||||
end;
|
||||
|
||||
procedure TLazDockTree.BuildDockLayout(Zone: TLazDockZone);
|
||||
|
Loading…
Reference in New Issue
Block a user