mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 12:59:19 +02:00
anchordocking: save restore layouts
git-svn-id: trunk@26138 -
This commit is contained in:
parent
5325e801a8
commit
53ba0043d3
@ -453,10 +453,11 @@ type
|
||||
procedure CloseAll;
|
||||
|
||||
// save/restore layouts
|
||||
procedure SaveLayoutToConfig(Config: TConfigStorage);
|
||||
procedure SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree);
|
||||
procedure SaveSiteLayoutToTree(AForm: TCustomForm;
|
||||
LayoutTree: TAnchorDockLayoutTree);
|
||||
procedure SaveLayoutToConfig(Config: TConfigStorage);
|
||||
function CreateRestoreLayout(AControl: TControl): TAnchorDockRestoreLayout;
|
||||
function ConfigIsEmpty(Config: TConfigStorage): boolean;
|
||||
function LoadLayoutFromConfig(Config: TConfigStorage): boolean;
|
||||
property RestoreLayouts: TAnchorDockRestoreLayouts read FRestoreLayouts;
|
||||
@ -1430,7 +1431,8 @@ var
|
||||
i: Integer;
|
||||
Splitter: TAnchorDockSplitter;
|
||||
begin
|
||||
if AValue=SplitterWidth then exit;
|
||||
if (AValue<1) or (AValue=SplitterWidth) then exit;
|
||||
FSplitterWidth:=AValue;
|
||||
for i:=0 to ComponentCount-1 do begin
|
||||
Splitter:=TAnchorDockSplitter(Components[i]);
|
||||
if not (Splitter is TAnchorDockSplitter) then continue;
|
||||
@ -1868,6 +1870,37 @@ begin
|
||||
raise EAnchorDockLayoutError.Create('invalid root control for save: '+DbgSName(AForm));
|
||||
end;
|
||||
|
||||
function TAnchorDockMaster.CreateRestoreLayout(AControl: TControl
|
||||
): TAnchorDockRestoreLayout;
|
||||
{ Create a restore layout for AControl and its child controls.
|
||||
It contains the whole parent structure so that the restore knows where to
|
||||
put AControl.
|
||||
}
|
||||
|
||||
procedure AddControlNames(SubControl: TControl;
|
||||
RestoreLayout: TAnchorDockRestoreLayout);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if (FControls.IndexOf(SubControl)>=0)
|
||||
and not RestoreLayout.HasControlName(SubControl.Name) then
|
||||
RestoreLayout.ControlNames.Add(SubControl.Name);
|
||||
if SubControl is TWinControl then
|
||||
for i:=0 to TWinControl(SubControl).ControlCount-1 do
|
||||
AddControlNames(TWinControl(SubControl).Controls[i],RestoreLayout);
|
||||
end;
|
||||
|
||||
var
|
||||
AForm: TCustomForm;
|
||||
begin
|
||||
if not IsSite(AControl) then
|
||||
raise Exception.Create('TAnchorDockMaster.CreateRestoreLayout: not a site '+DbgSName(AControl));
|
||||
AForm:=GetParentForm(AControl);
|
||||
Result:=TAnchorDockRestoreLayout.Create(TAnchorDockLayoutTree.Create);
|
||||
SaveSiteLayoutToTree(AForm,Result.Layout);
|
||||
AddControlNames(AControl,Result);
|
||||
end;
|
||||
|
||||
procedure TAnchorDockMaster.SaveLayoutToConfig(Config: TConfigStorage);
|
||||
var
|
||||
Tree: TAnchorDockLayoutTree;
|
||||
@ -1878,6 +1911,9 @@ begin
|
||||
SaveMainLayoutToTree(Tree);
|
||||
Tree.SaveToConfig(Config);
|
||||
Config.UndoAppendBasePath;
|
||||
Config.AppendBasePath('Restores/');
|
||||
RestoreLayouts.SaveToConfig(Config);
|
||||
Config.UndoAppendBasePath;
|
||||
WriteDebugLayout('TAnchorDockMaster.SaveLayoutToConfig ',Tree.Root);
|
||||
DebugWriteChildAnchors(Tree.Root);
|
||||
finally
|
||||
@ -1904,6 +1940,9 @@ begin
|
||||
Config.AppendBasePath('MainConfig/');
|
||||
Tree.LoadFromConfig(Config);
|
||||
Config.UndoAppendBasePath;
|
||||
Config.AppendBasePath('Restores/');
|
||||
RestoreLayouts.LoadFromConfig(Config);
|
||||
Config.UndoAppendBasePath;
|
||||
|
||||
WriteDebugLayout('TAnchorDockMaster.LoadLayoutFromConfig ',Tree.Root);
|
||||
DebugWriteChildAnchors(Tree.Root);
|
||||
@ -3965,8 +4004,10 @@ end;
|
||||
|
||||
procedure TAnchorDockHeader.CloseButtonClick(Sender: TObject);
|
||||
begin
|
||||
if Parent is TAnchorDockHostSite then
|
||||
if Parent is TAnchorDockHostSite then begin
|
||||
DockMaster.RestoreLayouts.Add(DockMaster.CreateRestoreLayout(Parent),true);
|
||||
TAnchorDockHostSite(Parent).CloseSite;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAnchorDockHeader.HeaderPositionItemClick(Sender: TObject);
|
||||
@ -4747,6 +4788,7 @@ var
|
||||
begin
|
||||
Site:=GetActiveSite;
|
||||
if Site=nil then exit;
|
||||
DockMaster.RestoreLayouts.Add(DockMaster.CreateRestoreLayout(Site),true);
|
||||
Site.CloseSite;
|
||||
DockMaster.SimplifyPendingLayouts;
|
||||
end;
|
||||
|
@ -135,6 +135,7 @@ begin
|
||||
Master.HeaderAlignLeft := HeaderAlignLeftTrackBar.Position;
|
||||
Master.SplitterWidth := SplitterWidthTrackBar.Position;
|
||||
Master.ScaleOnResize := ScaleOnResizeCheckBox.Checked;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAnchorDockOptionsDialog.DragThresholdTrackBarChange(Sender: TObject);
|
||||
|
@ -1764,7 +1764,7 @@ end;
|
||||
|
||||
function TAnchorDockRestoreLayout.IndexOfControlName(AName: string): integer;
|
||||
begin
|
||||
Result:=fControlNames.Count;
|
||||
Result:=fControlNames.Count-1;
|
||||
while (Result>=0) and (CompareText(AName,FControlNames[Result])<>0) do
|
||||
dec(Result);
|
||||
end;
|
||||
@ -1890,6 +1890,7 @@ procedure TAnchorDockRestoreLayouts.Add(Layout: TAnchorDockRestoreLayout;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if Layout=nil then exit;
|
||||
if RemoveOther then begin
|
||||
for i:=0 to Layout.ControlNames.Count-1 do
|
||||
RemoveByName(Layout.ControlNames[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user