mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 15:56:10 +02:00
anchordocking: restore custom dock site: restore splitter position
git-svn-id: trunk@26205 -
This commit is contained in:
parent
0eb9153024
commit
22d9391ac8
@ -65,18 +65,17 @@
|
||||
- design time package for IDE
|
||||
- dnd move page index
|
||||
- dnd move page to another pagecontrol
|
||||
- on close button: save a restore layout
|
||||
|
||||
ToDo:
|
||||
- smaller header
|
||||
- restore custom dock site size
|
||||
- undock on hide
|
||||
- option: hide caption
|
||||
- list of default layouts
|
||||
- make options a frame
|
||||
- popup menu
|
||||
- shrink side left, top, right, bottom
|
||||
- simple way to make forms dockable at designtime
|
||||
- minimize button and Hide => show in header
|
||||
- on close button: save a default layout
|
||||
- on show again: restore a default layout
|
||||
- on show again: restore layout
|
||||
- close button for pages
|
||||
}
|
||||
unit AnchorDocking;
|
||||
@ -344,7 +343,7 @@ type
|
||||
procedure ResetBounds(Force: Boolean); override;
|
||||
procedure SaveToStream(Stream: TStream); override;
|
||||
function GetDockEdge(ADockObject: TDragDockObject): boolean; override;
|
||||
procedure RestoreSite;
|
||||
procedure RestoreSite(SplitterPos: integer);
|
||||
|
||||
property Site: TWinControl read FSite; // the associated TControl (a TAnchorDockHostSite or a custom dock site)
|
||||
property DockSite: TAnchorDockHostSite read FDockSite; // if Site is a TAnchorDockHostSite, this is it
|
||||
@ -1183,7 +1182,8 @@ function TAnchorDockMaster.RestoreLayout(Tree: TAnchorDockLayoutTree): boolean;
|
||||
Site.Parent:=Parent;
|
||||
if IsCustomSite(Parent) then begin
|
||||
Site.Align:=Node.Align;
|
||||
TAnchorDockManager(Parent.DockManager).RestoreSite;
|
||||
//debugln(['TAnchorDockMaster.RestoreLayout.SetupSite Site=',DbgSName(Site),' Site.Bounds=',dbgs(Site.BoundsRect),' BoundSplitterPos=',Node.BoundSplitterPos]);
|
||||
TAnchorDockManager(Parent.DockManager).RestoreSite(Node.BoundSplitterPos);
|
||||
Site.HostDockSite:=Parent;
|
||||
end;
|
||||
if Site is TAnchorDockHostSite then
|
||||
@ -1922,6 +1922,10 @@ begin
|
||||
if Site<>nil then begin
|
||||
LayoutNode:=LayoutTree.NewNode(LayoutNode);
|
||||
Site.SaveLayout(LayoutTree,LayoutNode);
|
||||
{if Site.BoundSplitter<>nil then begin
|
||||
LayoutNode:=LayoutTree.NewNode(LayoutNode);
|
||||
Site.BoundSplitter.SaveLayout(LayoutNode);
|
||||
end;}
|
||||
end;
|
||||
end else
|
||||
raise EAnchorDockLayoutError.Create('invalid root control for save: '+DbgSName(AControl));
|
||||
@ -4032,6 +4036,12 @@ begin
|
||||
LayoutNode.HeaderPosition:=Header.HeaderPosition;
|
||||
end else
|
||||
LayoutNode.NodeType:=adltnNone;
|
||||
if BoundSplitter<>nil then begin
|
||||
if Align in [alLeft,alRight] then
|
||||
LayoutNode.BoundSplitterPos:=BoundSplitter.Left
|
||||
else
|
||||
LayoutNode.BoundSplitterPos:=BoundSplitter.Top;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TAnchorDockHostSite.Create(AOwner: TComponent);
|
||||
@ -4617,7 +4627,7 @@ begin
|
||||
WidthDiff:=FSiteClientRect.Right-OldSiteClientRect.Right;
|
||||
HeightDiff:=FSiteClientRect.Bottom-OldSiteClientRect.Bottom;
|
||||
|
||||
//debugln(['TAnchorDockManager.ResetBounds ',dbgs(Child.BaseBounds),' ',WidthDiff,',',HeightDiff]);
|
||||
debugln(['TAnchorDockManager.ResetBounds ',DbgSName(Site),' ',dbgs(Child.BaseBounds),' ',WidthDiff,',',HeightDiff]);
|
||||
case ResizePolicy of
|
||||
admrpChild:
|
||||
begin
|
||||
@ -4710,7 +4720,7 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure TAnchorDockManager.RestoreSite;
|
||||
procedure TAnchorDockManager.RestoreSite(SplitterPos: integer);
|
||||
var
|
||||
ChildSite: TAnchorDockHostSite;
|
||||
begin
|
||||
@ -4721,6 +4731,19 @@ begin
|
||||
if ChildSite<>nil then begin
|
||||
ChildSite.CreateBoundSplitter;
|
||||
ChildSite.PositionBoundSplitter;
|
||||
if ChildSite.Align in [alLeft,alRight] then
|
||||
ChildSite.BoundSplitter.Left:=SplitterPos
|
||||
else
|
||||
ChildSite.BoundSplitter.Top:=SplitterPos;
|
||||
case ChildSite.Align of
|
||||
alTop: ChildSite.Height:=ChildSite.BoundSplitter.Top;
|
||||
alBottom: ChildSite.Height:=Site.ClientHeight
|
||||
-(ChildSite.BoundSplitter.Top+ChildSite.BoundSplitter.Height);
|
||||
alLeft: ChildSite.Width:=ChildSite.BoundSplitter.Left;
|
||||
alRight: ChildSite.Width:=Site.ClientWidth
|
||||
-(ChildSite.BoundSplitter.Left+ChildSite.BoundSplitter.Width);
|
||||
end;
|
||||
//debugln(['TAnchorDockManager.RestoreSite ',DbgSName(Site),' ChildSite=',DbgSName(ChildSite),' Site.Bounds=',dbgs(Site.BoundsRect),' Site.Client=',dbgs(Site.ClientRect),' ChildSite.Bounds=',dbgs(ChildSite.BoundsRect),' Splitter.Bounds=',dbgs(ChildSite.BoundSplitter.BoundsRect)]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -69,6 +69,7 @@ type
|
||||
private
|
||||
FAlign: TAlign;
|
||||
fAnchors: array[TAnchorKind] of string;
|
||||
FBoundSplitterPos: integer;
|
||||
FBoundsRect: TRect;
|
||||
FHeaderPosition: TADLHeaderPosition;
|
||||
FMonitor: integer;
|
||||
@ -89,6 +90,7 @@ type
|
||||
procedure SetAlign(const AValue: TAlign);
|
||||
procedure SetAnchors(Site: TAnchorKind; const AValue: string);
|
||||
procedure SetBottom(const AValue: integer);
|
||||
procedure SetBoundSplitterPos(const AValue: integer);
|
||||
procedure SetBoundsRect(const AValue: TRect);
|
||||
procedure SetHeaderPosition(const AValue: TADLHeaderPosition);
|
||||
procedure SetHeight(const AValue: integer);
|
||||
@ -143,6 +145,7 @@ type
|
||||
property Monitor: integer read FMonitor write SetMonitor;
|
||||
property HeaderPosition: TADLHeaderPosition read FHeaderPosition write SetHeaderPosition;
|
||||
property TabPosition: TTabPosition read FTabPosition write SetTabPosition;
|
||||
property BoundSplitterPos: integer read FBoundSplitterPos write SetBoundSplitterPos;
|
||||
function Count: integer;
|
||||
function IsSplitter: boolean;
|
||||
function IsRootWindow: boolean;
|
||||
@ -886,6 +889,13 @@ begin
|
||||
IncreaseChangeStamp;
|
||||
end;
|
||||
|
||||
procedure TAnchorDockLayoutTreeNode.SetBoundSplitterPos(const AValue: integer);
|
||||
begin
|
||||
if FBoundSplitterPos=AValue then exit;
|
||||
FBoundSplitterPos:=AValue;
|
||||
IncreaseChangeStamp;
|
||||
end;
|
||||
|
||||
procedure TAnchorDockLayoutTreeNode.SetBoundsRect(const AValue: TRect);
|
||||
begin
|
||||
if CompareRect(@FBoundsRect,@AValue) then exit;
|
||||
@ -1028,6 +1038,7 @@ begin
|
||||
or (WindowState<>Node.WindowState)
|
||||
or (HeaderPosition<>Node.HeaderPosition)
|
||||
or (TabPosition<>Node.TabPosition)
|
||||
or (BoundSplitterPos<>Node.BoundSplitterPos)
|
||||
then
|
||||
exit;
|
||||
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
||||
@ -1050,6 +1061,7 @@ begin
|
||||
WindowState:=Node.WindowState;
|
||||
HeaderPosition:=Node.HeaderPosition;
|
||||
TabPosition:=Node.TabPosition;
|
||||
BoundSplitterPos:=Node.BoundSplitterPos;
|
||||
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
||||
Anchors[a]:=Node.Anchors[a];
|
||||
while Count>Node.Count do Nodes[Count-1].Free;
|
||||
@ -1103,6 +1115,7 @@ begin
|
||||
Top:=Config.GetValue('Bounds/Top',0);
|
||||
Width:=Config.GetValue('Bounds/Width',0);
|
||||
Height:=Config.GetValue('Bounds/Height',0);
|
||||
BoundSplitterPos:=Config.GetValue('Bounds/SplitterPos',0);
|
||||
Anchors[akLeft]:=Config.GetValue('Anchors/Left','');
|
||||
Anchors[akTop]:=Config.GetValue('Anchors/Top','');
|
||||
Anchors[akRight]:=Config.GetValue('Anchors/Right','');
|
||||
@ -1133,6 +1146,7 @@ begin
|
||||
Config.SetDeleteValue('Bounds/Top',Top,0);
|
||||
Config.SetDeleteValue('Bounds/Width',Width,0);
|
||||
Config.SetDeleteValue('Bounds/Height',Height,0);
|
||||
Config.SetDeleteValue('Bounds/SplitterPos',BoundSplitterPos,0);
|
||||
Config.SetDeleteValue('Anchors/Left',Anchors[akLeft],'');
|
||||
Config.SetDeleteValue('Anchors/Top',Anchors[akTop],'');
|
||||
Config.SetDeleteValue('Anchors/Right',Anchors[akRight],'');
|
||||
|
Loading…
Reference in New Issue
Block a user