mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 15:21:48 +02:00
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:
parent
0206260c62
commit
10b0890c9d
@ -1061,7 +1061,7 @@ begin
|
|||||||
else
|
else
|
||||||
CurControl := Zone.ChildControl;
|
CurControl := Zone.ChildControl;
|
||||||
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl=',DbgSName(CurControl),' DockSite=',DbgSName(DockSite)]);
|
//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
|
begin
|
||||||
// get outside anchor controls
|
// get outside anchor controls
|
||||||
NewAnchors := [akLeft, akRight, akTop, akBottom];
|
NewAnchors := [akLeft, akRight, akTop, akBottom];
|
||||||
@ -1078,7 +1078,8 @@ begin
|
|||||||
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 := 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;
|
Zone.Splitter.ResizeAnchor := akBottom;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1088,7 +1089,8 @@ begin
|
|||||||
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 := 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;
|
Zone.Splitter.ResizeAnchor := akRight;
|
||||||
end;
|
end;
|
||||||
// IMPORTANT: first set the AnchorSide, then set the Anchors
|
// IMPORTANT: first set the AnchorSide, then set the Anchors
|
||||||
@ -1104,22 +1106,25 @@ begin
|
|||||||
AnchorControls[SplitterSide] := Zone.Splitter;
|
AnchorControls[SplitterSide] := Zone.Splitter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// anchor pages
|
if (CurControl <> nil) then
|
||||||
// IMPORTANT: first set the AnchorSide, then set the Anchors
|
|
||||||
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl.Parent=',DbgSName(CurControl.Parent),' ',CurControl.Visible]);
|
|
||||||
for a := Low(TAnchorKind) to High(TAnchorKind) do
|
|
||||||
begin
|
begin
|
||||||
CurControl.AnchorSide[a].Control := AnchorControls[a];
|
// anchor pages
|
||||||
if (AnchorControls[a] <> nil) and (AnchorControls[a].Parent = CurControl.Parent) then
|
// IMPORTANT: first set the AnchorSide, then set the Anchors
|
||||||
CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[a]
|
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl.Parent=',DbgSName(CurControl.Parent),' ',CurControl.Visible]);
|
||||||
else
|
for a := Low(TAnchorKind) to High(TAnchorKind) do
|
||||||
CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[OppositeAnchor[a]];
|
begin
|
||||||
end;
|
CurControl.AnchorSide[a].Control := AnchorControls[a];
|
||||||
CurControl.Anchors := NewAnchors;
|
if (AnchorControls[a] <> nil) and (AnchorControls[a].Parent = CurControl.Parent) then
|
||||||
// set space for header
|
CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[a]
|
||||||
case CurControl.DockOrientation of
|
else
|
||||||
doHorizontal: CurControl.BorderSpacing.Top := DefaultDockGrabberSize;
|
CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[OppositeAnchor[a]];
|
||||||
doVertical: CurControl.BorderSpacing.Left := DefaultDockGrabberSize;
|
end;
|
||||||
|
CurControl.Anchors := NewAnchors;
|
||||||
|
// set space for header
|
||||||
|
case CurControl.DockOrientation of
|
||||||
|
doHorizontal: CurControl.BorderSpacing.Top := DefaultDockGrabberSize;
|
||||||
|
doVertical: CurControl.BorderSpacing.Left := DefaultDockGrabberSize;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1236,10 +1241,10 @@ begin
|
|||||||
|
|
||||||
// dock
|
// dock
|
||||||
// create a new zone for AControl
|
// 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
|
// insert new zone into tree
|
||||||
if (DropZone=RootZone) and (RootZone.FirstChild=nil) then
|
if (DropZone = RootZone) and (RootZone.FirstChild = nil) then
|
||||||
begin
|
begin
|
||||||
// this is the first child
|
// this is the first child
|
||||||
debugln('TLazDockTree.InsertControl First Child');
|
debugln('TLazDockTree.InsertControl First Child');
|
||||||
@ -1293,6 +1298,12 @@ begin
|
|||||||
if OldParentZone <> nil then
|
if OldParentZone <> nil then
|
||||||
OldParentZone.ReplaceChild(DropZone, NewParentZone);
|
OldParentZone.ReplaceChild(DropZone, NewParentZone);
|
||||||
NewParentZone.AddAsFirstChild(DropZone);
|
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;
|
end;
|
||||||
|
|
||||||
if DropZone.Parent = nil then
|
if DropZone.Parent = nil then
|
||||||
@ -1632,7 +1643,7 @@ var
|
|||||||
procedure DumpAnchors(Title: String; AControl: TControl);
|
procedure DumpAnchors(Title: String; AControl: TControl);
|
||||||
var
|
var
|
||||||
a: TAnchorKind;
|
a: TAnchorKind;
|
||||||
S: String;
|
S, Name: String;
|
||||||
begin
|
begin
|
||||||
S := Title;
|
S := Title;
|
||||||
if AControl.Anchors <> [] then
|
if AControl.Anchors <> [] then
|
||||||
@ -1641,8 +1652,13 @@ var
|
|||||||
for a := Low(TAnchorKind) to High(TAnchorKind) do
|
for a := Low(TAnchorKind) to High(TAnchorKind) do
|
||||||
if a in AControl.Anchors then
|
if a in AControl.Anchors then
|
||||||
begin
|
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> = ' +
|
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;
|
end;
|
||||||
S := S + '</UL>';
|
S := S + '</UL>';
|
||||||
end
|
end
|
||||||
@ -1653,7 +1669,7 @@ var
|
|||||||
|
|
||||||
procedure DumpZone(Zone: TDockZone);
|
procedure DumpZone(Zone: TDockZone);
|
||||||
const
|
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 =
|
StrOrientation: array[TDockOrientation] of String =
|
||||||
(
|
(
|
||||||
'doNoOrient',
|
'doNoOrient',
|
||||||
@ -1664,7 +1680,7 @@ var
|
|||||||
begin
|
begin
|
||||||
WriteLn(Format(DumpStr, [StrOrientation[Zone.Orientation], Zone.ChildCount,
|
WriteLn(Format(DumpStr, [StrOrientation[Zone.Orientation], Zone.ChildCount,
|
||||||
DbgSName(Zone.ChildControl), DbgS(Bounds(Zone.Left, Zone.Top, Zone.Width, Zone.Height)),
|
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
|
if TLazDockZone(Zone).Splitter <> nil then
|
||||||
DumpAnchors('<br>Splitter anchors: ', TLazDockZone(Zone).Splitter);
|
DumpAnchors('<br>Splitter anchors: ', TLazDockZone(Zone).Splitter);
|
||||||
if Zone.ChildControl <> nil then
|
if Zone.ChildControl <> nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user