lcl: docking improvements

- change control DockOrientation if its parent zone changed
  - setup Zone.Splitter even if Zone does not has ChildControl
  - improve debug output so now visible to which splitter and to which sides controls are anchored

git-svn-id: trunk@17861 -
This commit is contained in:
paul 2008-12-19 08:26:56 +00:00
parent 0206260c62
commit 10b0890c9d

View File

@ -1061,7 +1061,7 @@ begin
else
CurControl := Zone.ChildControl;
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl=',DbgSName(CurControl),' DockSite=',DbgSName(DockSite)]);
if (CurControl <> nil) and (CurControl <> DockSite) then
if ((CurControl <> nil) and (CurControl <> DockSite)) or (Zone.Splitter <> nil) then
begin
// get outside anchor controls
NewAnchors := [akLeft, akRight, akTop, akBottom];
@ -1078,7 +1078,8 @@ begin
Zone.Splitter.AnchorSide[akLeft].Side := asrTop;
Zone.Splitter.AnchorSide[akRight].Side := asrBottom;
Zone.Splitter.Height := 5;
Zone.Splitter.Top := CurControl.Top - DefaultDockGrabberSize;
if Zone.PrevSibling <> nil then
Zone.Splitter.Top := (Zone.PrevSibling.Top + Zone.PrevSibling.Height) - DefaultDockGrabberSize;
Zone.Splitter.ResizeAnchor := akBottom;
end
else
@ -1088,7 +1089,8 @@ begin
Zone.Splitter.AnchorSide[akTop].Side := asrTop;
Zone.Splitter.AnchorSide[akBottom].Side := asrBottom;
Zone.Splitter.Width := 5;
Zone.Splitter.Left := CurControl.Left - DefaultDockGrabberSize;
if Zone.PrevSibling <> nil then
Zone.Splitter.Left := (Zone.PrevSibling.Left + Zone.PrevSibling.Width) - DefaultDockGrabberSize;
Zone.Splitter.ResizeAnchor := akRight;
end;
// IMPORTANT: first set the AnchorSide, then set the Anchors
@ -1104,6 +1106,8 @@ begin
AnchorControls[SplitterSide] := Zone.Splitter;
end;
if (CurControl <> nil) then
begin
// anchor pages
// IMPORTANT: first set the AnchorSide, then set the Anchors
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl.Parent=',DbgSName(CurControl.Parent),' ',CurControl.Visible]);
@ -1122,6 +1126,7 @@ begin
doVertical: CurControl.BorderSpacing.Left := DefaultDockGrabberSize;
end;
end;
end;
// anchor controls for childs and siblings
AnchorDockLayout(Zone.FirstChild as TLazDockZone);
@ -1236,10 +1241,10 @@ begin
// dock
// create a new zone for AControl
NewZone:=DockZoneClass.Create(Self,AControl) as TLazDockZone;
NewZone := DockZoneClass.Create(Self,AControl) as TLazDockZone;
// insert new zone into tree
if (DropZone=RootZone) and (RootZone.FirstChild=nil) then
if (DropZone = RootZone) and (RootZone.FirstChild = nil) then
begin
// this is the first child
debugln('TLazDockTree.InsertControl First Child');
@ -1293,6 +1298,12 @@ begin
if OldParentZone <> nil then
OldParentZone.ReplaceChild(DropZone, NewParentZone);
NewParentZone.AddAsFirstChild(DropZone);
// child control already had orientation but now we moved it to another parent
// which can take another orientation => change child control orientation
NewParentZone.Orientation := NewOrientation;
if DropZone.ChildControl <> nil then
DropZone.ChildControl.DockOrientation := NewOrientation;
end;
if DropZone.Parent = nil then
@ -1632,7 +1643,7 @@ var
procedure DumpAnchors(Title: String; AControl: TControl);
var
a: TAnchorKind;
S: String;
S, Name: String;
begin
S := Title;
if AControl.Anchors <> [] then
@ -1641,8 +1652,13 @@ var
for a := Low(TAnchorKind) to High(TAnchorKind) do
if a in AControl.Anchors then
begin
Name := DbgsName(AControl.AnchorSide[a].Control);
if (AControl.AnchorSide[a].Control <> nil) and (AControl.AnchorSide[a].Control.Name = '') then
Name := dbgs(AControl.AnchorSide[a].Control) + Name;
S := S + '<LI><b>' + GetEnumName(TypeInfo(TAnchorKind), Ord(a)) + '</b> = ' +
DbgsName(AControl.AnchorSide[a].Control) + '</LI>';
Name + ' (' +
GetEnumName(TypeInfo(TAnchorSideReference), Ord(AControl.AnchorSide[a].Side)) +
')' + '</LI>';
end;
S := S + '</UL>';
end
@ -1653,7 +1669,7 @@ var
procedure DumpZone(Zone: TDockZone);
const
DumpStr = 'Zone: Orientation = <b>%s</b>, ChildCount = <b>%d</b>, ChildControl = <b>%s</b>, %s, HasSplitter = <b>%s</b>';
DumpStr = 'Zone: Orientation = <b>%s</b>, ChildCount = <b>%d</b>, ChildControl = <b>%s</b>, %s, Splitter = <b>%s</b>';
StrOrientation: array[TDockOrientation] of String =
(
'doNoOrient',
@ -1664,7 +1680,7 @@ var
begin
WriteLn(Format(DumpStr, [StrOrientation[Zone.Orientation], Zone.ChildCount,
DbgSName(Zone.ChildControl), DbgS(Bounds(Zone.Left, Zone.Top, Zone.Width, Zone.Height)),
BoolToStr(TLazDockZone(Zone).Splitter <> nil, True)]));
dbgs(TLazDockZone(Zone).Splitter)]));
if TLazDockZone(Zone).Splitter <> nil then
DumpAnchors('<br>Splitter anchors: ', TLazDockZone(Zone).Splitter);
if Zone.ChildControl <> nil then