anchordocking: less debugging, check Show and BringToFront, apply DisableAutoSizing=false

git-svn-id: trunk@46498 -
This commit is contained in:
mattias 2014-10-09 16:28:12 +00:00
parent ca1096a2e4
commit 3def8dc318
2 changed files with 37 additions and 17 deletions

View File

@ -1432,18 +1432,26 @@ function TAnchorDockMaster.CreateNeededControls(Tree: TAnchorDockLayoutTree;
AControl:=FindControl(Node.Name); AControl:=FindControl(Node.Name);
if AControl<>nil then begin if AControl<>nil then begin
//debugln(['CreateControlsForNode ',Node.Name,' already exists']); //debugln(['CreateControlsForNode ',Node.Name,' already exists']);
DisableControlAutoSizing(AControl); if DisableAutoSizing then
DisableControlAutoSizing(AControl);
end else begin end else begin
//debugln(['CreateControlsForNode ',Node.Name,' needs creation']); //debugln(['CreateControlsForNode ',Node.Name,' needs creation']);
AControl:=DoCreateControl(Node.Name,DisableAutoSizing); AControl:=DoCreateControl(Node.Name,true);
if AControl<>nil then begin if AControl<>nil then begin
//debugln(['CreateControlsForNode ',AControl.Name,' created']); try
if fDisabledAutosizing.IndexOf(AControl)<0 then if DisableAutoSizing and (fDisabledAutosizing.IndexOf(AControl)<0)
fDisabledAutosizing.Add(AControl); then begin
if Node.NodeType=adltnControl then fDisabledAutosizing.Add(AControl);
MakeDockable(AControl,false) AControl.FreeNotification(Self);
else if not IsCustomSite(AControl) then end;
raise EAnchorDockLayoutError.Create('not a docksite: '+DbgSName(AControl)); if Node.NodeType=adltnControl then
MakeDockable(AControl,false)
else if not IsCustomSite(AControl) then
raise EAnchorDockLayoutError.Create('not a docksite: '+DbgSName(AControl));
finally
if not DisableAutoSizing then
AControl.EnableAutoSizing;
end;
end else begin end else begin
debugln(['CreateControlsForNode ',Node.Name,' failed to create']); debugln(['CreateControlsForNode ',Node.Name,' failed to create']);
end; end;
@ -1662,9 +1670,14 @@ var
var var
aManager: TAnchorDockManager; aManager: TAnchorDockManager;
NewBounds: TRect; NewBounds: TRect;
aMonitor: TMonitor;
begin begin
if Parent=nil then begin if Parent=nil then begin
WorkArea:=Site.Monitor.WorkareaRect; if (Node.Monitor>=0) and (Node.Monitor<Screen.MonitorCount) then
aMonitor:=Screen.Monitors[Node.Monitor]
else
aMonitor:=Site.Monitor;
WorkArea:=aMonitor.WorkareaRect;
{$IFDEF VerboseAnchorDockRestore} {$IFDEF VerboseAnchorDockRestore}
debugln(['TAnchorDockMaster.RestoreLayout.SetupSite WorkArea=',dbgs(WorkArea)]); debugln(['TAnchorDockMaster.RestoreLayout.SetupSite WorkArea=',dbgs(WorkArea)]);
{$ENDIF} {$ENDIF}
@ -1688,7 +1701,7 @@ var
end; end;
{$IFDEF VerboseAnchorDockRestore} {$IFDEF VerboseAnchorDockRestore}
if Scale then if Scale then
debugln(['TAnchorDockMaster.RestoreLayout.SetupSite scale Site=',DbgSName(Site),' OldWorkArea=',dbgs(SrcWorkArea),' CurWorkArea=',dbgs(WorkArea),' OldBounds=',dbgs(Node.BoundsRect),' NewBounds=',dbgs(NewBounds)]); debugln(['TAnchorDockMaster.RestoreLayout.SetupSite scale Site=',DbgSName(Site),' Caption="',Site.Caption,'" OldWorkArea=',dbgs(SrcWorkArea),' CurWorkArea=',dbgs(WorkArea),' OldBounds=',dbgs(Node.BoundsRect),' NewBounds=',dbgs(NewBounds)]);
{$ENDIF} {$ENDIF}
Site.BoundsRect:=NewBounds; Site.BoundsRect:=NewBounds;
Site.Visible:=true; Site.Visible:=true;
@ -1708,10 +1721,6 @@ var
end; end;
if Parent=nil then begin if Parent=nil then begin
Site.WindowState:=Node.WindowState; Site.WindowState:=Node.WindowState;
if (Node.Monitor>=0) and (Node.Monitor<Screen.MonitorCount) then
begin
// ToDo: move to monitor
end;
end; end;
end; end;
@ -2296,7 +2305,9 @@ end;
destructor TAnchorDockMaster.Destroy; destructor TAnchorDockMaster.Destroy;
var var
AControl: TControl; AControl: TControl;
{$IFDEF VerboseAnchorDocking}
i: Integer; i: Integer;
{$ENDIF}
begin begin
QueueSimplify:=false; QueueSimplify:=false;
FreeAndNil(FRestoreLayouts); FreeAndNil(FRestoreLayouts);
@ -2313,9 +2324,11 @@ begin
FreeAndNil(FControls); FreeAndNil(FControls);
FreeAndNil(fNeedFree); FreeAndNil(fNeedFree);
FreeAndNil(fDisabledAutosizing); FreeAndNil(fDisabledAutosizing);
{$IFDEF VerboseAnchorDocking}
for i:=0 to ComponentCount-1 do begin for i:=0 to ComponentCount-1 do begin
debugln(['TAnchorDockMaster.Destroy ',i,'/',ComponentCount,' ',DbgSName(Components[i])]); debugln(['TAnchorDockMaster.Destroy ',i,'/',ComponentCount,' ',DbgSName(Components[i])]);
end; end;
{$ENDIF}
inherited Destroy; inherited Destroy;
end; end;
@ -2509,7 +2522,7 @@ begin
AControl.EnableAutoSizing; AControl.EnableAutoSizing;
end; end;
// BringToFront // BringToFront
if BringToFront and (Site<>nil) then begin if Show and BringToFront and (Site<>nil) then begin
GetParentForm(Site).BringToFront; GetParentForm(Site).BringToFront;
Site.SetFocus; Site.SetFocus;
end; end;
@ -5484,9 +5497,13 @@ var
SplitterWidth: Integer; SplitterWidth: Integer;
begin begin
if DockSite<>nil then if DockSite<>nil then
{$IFDEF VerboseAnchorDocking}
debugln(['TAnchorDockManager.RemoveControl DockSite="',DockSite.Caption,'" Control=',DbgSName(Control)]) debugln(['TAnchorDockManager.RemoveControl DockSite="',DockSite.Caption,'" Control=',DbgSName(Control)])
{$ENDIF}
else begin else begin
{$IFDEF VerboseAnchorDocking}
debugln(['TAnchorDockManager.RemoveControl Site="',DbgSName(Site),'" Control=',DbgSName(Control)]); debugln(['TAnchorDockManager.RemoveControl Site="',DbgSName(Site),'" Control=',DbgSName(Control)]);
{$ENDIF}
if Control is TAnchorDockHostSite then begin if Control is TAnchorDockHostSite then begin
SplitterWidth:=0; SplitterWidth:=0;
if Control is TAnchorDockHostSite then begin if Control is TAnchorDockHostSite then begin
@ -5514,7 +5531,9 @@ begin
FStoredConstraints:=Rect(0,0,0,0); FStoredConstraints:=Rect(0,0,0,0);
end; end;
Site.BoundsRect:=NewBounds; Site.BoundsRect:=NewBounds;
{$IFDEF VerboseAnchorDocking}
debugln(['TAnchorDockManager.RemoveControl Site=',DbgSName(Site),' ',dbgs(Site.BoundsRect)]); debugln(['TAnchorDockManager.RemoveControl Site=',DbgSName(Site),' ',dbgs(Site.BoundsRect)]);
{$ENDIF}
// Site can dock a control again // Site can dock a control again
DragManager.RegisterDockSite(Site,true); DragManager.RegisterDockSite(Site,true);

View File

@ -31,7 +31,7 @@ unit RegisterAnchorDocking;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$DEFINE VerboseAnchorDocking} { $DEFINE VerboseAnchorDocking}
interface interface
@ -328,6 +328,7 @@ begin
DockMaster.LoadLayoutFromConfig(Config,true); DockMaster.LoadLayoutFromConfig(Config,true);
UserLayoutLoaded:=true; UserLayoutLoaded:=true;
end else begin end else begin
// loading defaults
{$IF defined(VerboseAnchorDocking) or defined(VerboseAnchorDockRestore)} {$IF defined(VerboseAnchorDocking) or defined(VerboseAnchorDockRestore)}
debugln(['TIDEAnchorDockMaster.LoadUserLayout loading default layout ...']); debugln(['TIDEAnchorDockMaster.LoadUserLayout loading default layout ...']);
{$ENDIF} {$ENDIF}