mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 13:17:03 +02:00
anchordocking: fixed manualdock to custom site
git-svn-id: trunk@26184 -
This commit is contained in:
parent
22523185f7
commit
7698dd40d4
@ -435,7 +435,8 @@ type
|
|||||||
function IsSite(AControl: TControl): boolean;
|
function IsSite(AControl: TControl): boolean;
|
||||||
function IsAnchorSite(AControl: TControl): boolean;
|
function IsAnchorSite(AControl: TControl): boolean;
|
||||||
function IsCustomSite(AControl: TControl): boolean;
|
function IsCustomSite(AControl: TControl): boolean;
|
||||||
function GetSite(AControl: TControl): TAnchorDockHostSite;
|
function GetSite(AControl: TControl): TCustomForm;
|
||||||
|
function GetAnchorSite(AControl: TControl): TAnchorDockHostSite;
|
||||||
function GetControl(Site: TControl): TControl;
|
function GetControl(Site: TControl): TControl;
|
||||||
function IsFloating(AControl: TControl): Boolean;
|
function IsFloating(AControl: TControl): Boolean;
|
||||||
function GetPopupMenu: TPopupMenu;
|
function GetPopupMenu: TPopupMenu;
|
||||||
@ -1635,14 +1636,28 @@ begin
|
|||||||
and (TCustomForm(AControl).DockManager is TAnchorDockManager);
|
and (TCustomForm(AControl).DockManager is TAnchorDockManager);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAnchorDockMaster.GetSite(AControl: TControl): TAnchorDockHostSite;
|
function TAnchorDockMaster.GetSite(AControl: TControl): TCustomForm;
|
||||||
begin
|
begin
|
||||||
if AControl is TAnchorDockHostSite then
|
Result:=nil;
|
||||||
|
if AControl=nil then
|
||||||
|
exit
|
||||||
|
else if IsCustomSite(AControl) then
|
||||||
|
Result:=TCustomForm(AControl)
|
||||||
|
else if AControl is TAnchorDockHostSite then
|
||||||
Result:=TAnchorDockHostSite(AControl)
|
Result:=TAnchorDockHostSite(AControl)
|
||||||
else if (AControl.HostDockSite is TAnchorDockHostSite) then
|
else if (AControl.HostDockSite is TAnchorDockHostSite) then
|
||||||
Result:=TAnchorDockHostSite(AControl.HostDockSite)
|
Result:=TAnchorDockHostSite(AControl.HostDockSite);
|
||||||
else
|
end;
|
||||||
Result:=nil;
|
|
||||||
|
function TAnchorDockMaster.GetAnchorSite(AControl: TControl): TAnchorDockHostSite;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if AControl=nil then
|
||||||
|
Result:=nil
|
||||||
|
else if AControl is TAnchorDockHostSite then
|
||||||
|
Result:=TAnchorDockHostSite(AControl)
|
||||||
|
else if (AControl.HostDockSite is TAnchorDockHostSite) then
|
||||||
|
Result:=TAnchorDockHostSite(AControl.HostDockSite);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAnchorDockMaster.GetControl(Site: TControl): TControl;
|
function TAnchorDockMaster.GetControl(Site: TControl): TControl;
|
||||||
@ -1663,11 +1678,13 @@ end;
|
|||||||
|
|
||||||
function TAnchorDockMaster.IsFloating(AControl: TControl): Boolean;
|
function TAnchorDockMaster.IsFloating(AControl: TControl): Boolean;
|
||||||
begin
|
begin
|
||||||
if AControl is TAnchorDockHostSite then
|
if AControl is TAnchorDockHostSite then begin
|
||||||
Result:=TAnchorDockHostSite(AControl).SiteType=adhstOneControl
|
Result:=(TAnchorDockHostSite(AControl).SiteType=adhstOneControl)
|
||||||
else if (AControl.HostDockSite is TAnchorDockHostSite) then
|
and (AControl.Parent=nil);
|
||||||
Result:=TAnchorDockHostSite(AControl.HostDockSite).SiteType=adhstOneControl
|
end else if (AControl.HostDockSite is TAnchorDockHostSite) then begin
|
||||||
else
|
Result:=(TAnchorDockHostSite(AControl.HostDockSite).SiteType=adhstOneControl)
|
||||||
|
and (AControl.HostDockSite.Parent=nil);
|
||||||
|
end else
|
||||||
Result:=AControl.Parent=nil;
|
Result:=AControl.Parent=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2043,7 +2060,7 @@ procedure TAnchorDockMaster.ManualFloat(AControl: TControl);
|
|||||||
var
|
var
|
||||||
Site: TAnchorDockHostSite;
|
Site: TAnchorDockHostSite;
|
||||||
begin
|
begin
|
||||||
Site:=GetSite(AControl);
|
Site:=GetAnchorSite(AControl);
|
||||||
if Site=nil then exit;
|
if Site=nil then exit;
|
||||||
Site.Undock;
|
Site.Undock;
|
||||||
end;
|
end;
|
||||||
@ -4390,50 +4407,63 @@ begin
|
|||||||
// handled by TAnchorDockHostSite
|
// handled by TAnchorDockHostSite
|
||||||
debugln(['TAnchorDockManager.InsertControl DockSite="',DockSite.Caption,'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign)])
|
debugln(['TAnchorDockManager.InsertControl DockSite="',DockSite.Caption,'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign)])
|
||||||
end else begin
|
end else begin
|
||||||
debugln(['TAnchorDockManager.InsertControl DockSite=nil Site="',DbgSName(Site),'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign),' Site.Bounds=',dbgs(Site.BoundsRect),' Control.Client=',dbgs(ADockObject.Control.ClientRect)]);
|
debugln(['TAnchorDockManager.InsertControl DockSite=nil Site="',DbgSName(Site),'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign),' Site.Bounds=',dbgs(Site.BoundsRect),' Control.Client=',dbgs(ADockObject.Control.ClientRect),' Parent=',DbgSName(ADockObject.Control.Parent)]);
|
||||||
// align dragged Control
|
Site.DisableAutoSizing;
|
||||||
Child:=ADockObject.Control;
|
try
|
||||||
Child.Align:=ADockObject.DropAlign;
|
|
||||||
Child.Width:=ADockObject.DockRect.Right-ADockObject.DockRect.Left;
|
|
||||||
Child.Height:=ADockObject.DockRect.Bottom-ADockObject.DockRect.Top;
|
|
||||||
|
|
||||||
SplitterWidth:=0;
|
// align dragged Control
|
||||||
ChildSite:=nil;
|
Child:=ADockObject.Control;
|
||||||
if Child is TAnchorDockHostSite then begin
|
Child.Parent:=Site;
|
||||||
ChildSite:=TAnchorDockHostSite(Child);
|
Child.Align:=ADockObject.DropAlign;
|
||||||
ChildSite.CreateBoundSplitter;
|
Child.Width:=ADockObject.DockRect.Right-ADockObject.DockRect.Left;
|
||||||
SplitterWidth:=DockMaster.SplitterWidth;
|
Child.Height:=ADockObject.DockRect.Bottom-ADockObject.DockRect.Top;
|
||||||
|
|
||||||
|
SplitterWidth:=0;
|
||||||
|
ChildSite:=nil;
|
||||||
|
if Child is TAnchorDockHostSite then begin
|
||||||
|
ChildSite:=TAnchorDockHostSite(Child);
|
||||||
|
ChildSite.CreateBoundSplitter;
|
||||||
|
SplitterWidth:=DockMaster.SplitterWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// resize Site
|
||||||
|
NewSiteBounds:=Site.BoundsRect;
|
||||||
|
case ADockObject.DropAlign of
|
||||||
|
alLeft: dec(NewSiteBounds.Left,Child.ClientWidth+SplitterWidth);
|
||||||
|
alRight: dec(NewSiteBounds.Right,Child.ClientWidth+SplitterWidth);
|
||||||
|
alTop: dec(NewSiteBounds.Top,Child.ClientHeight+SplitterWidth);
|
||||||
|
alBottom: inc(NewSiteBounds.Bottom,Child.ClientHeight+SplitterWidth);
|
||||||
|
end;
|
||||||
|
if ADockObject.DropAlign in [alLeft,alRight] then
|
||||||
|
Site.Constraints.MaxWidth:=0
|
||||||
|
else
|
||||||
|
Site.Constraints.MaxHeight:=0;
|
||||||
|
Site.BoundsRect:=NewSiteBounds;
|
||||||
|
debugln(['TAnchorDockManager.InsertControl Site.BoundsRect=',dbgs(Site.BoundsRect),' NewSiteBounds=',dbgs(NewSiteBounds),' Child.ClientRect=',dbgs(Child.ClientRect)]);
|
||||||
|
FSiteClientRect:=Site.ClientRect;
|
||||||
|
|
||||||
|
// resize child
|
||||||
|
NewChildBounds:=Child.BoundsRect;
|
||||||
|
case ADockObject.DropAlign of
|
||||||
|
alTop: NewChildBounds:=Bounds(0,0,Site.ClientWidth,Child.ClientHeight);
|
||||||
|
alBottom: NewChildBounds:=Bounds(0,Site.ClientHeight-Child.ClientHeight,
|
||||||
|
Site.ClientWidth,Child.ClientHeight);
|
||||||
|
alLeft: NewChildBounds:=Bounds(0,0,Child.ClientWidth,Site.ClientHeight);
|
||||||
|
alRight: NewChildBounds:=Bounds(Site.ClientWidth-Child.ClientWidth,0,
|
||||||
|
Child.ClientWidth,Site.ClientHeight);
|
||||||
|
end;
|
||||||
|
Child.BoundsRect:=NewChildBounds;
|
||||||
|
|
||||||
|
if ChildSite<>nil then
|
||||||
|
ChildSite.PositionBoundSplitter;
|
||||||
|
|
||||||
|
// only allow to dock one control
|
||||||
|
DragManager.RegisterDockSite(Site,false);
|
||||||
|
debugln(['TAnchorDockManager.InsertControl AFTER Site="',DbgSName(Site),'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign),' Site.Bounds=',dbgs(Site.BoundsRect),' Control.ClientRect=',dbgs(ADockObject.Control.ClientRect)]);
|
||||||
|
|
||||||
|
finally
|
||||||
|
Site.EnableAutoSizing;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// resize Site
|
|
||||||
NewSiteBounds:=Site.BoundsRect;
|
|
||||||
case ADockObject.DropAlign of
|
|
||||||
alLeft: dec(NewSiteBounds.Left,Child.ClientWidth+SplitterWidth);
|
|
||||||
alRight: dec(NewSiteBounds.Right,Child.ClientWidth+SplitterWidth);
|
|
||||||
alTop: dec(NewSiteBounds.Top,Child.ClientHeight+SplitterWidth);
|
|
||||||
alBottom: inc(NewSiteBounds.Bottom,Child.ClientHeight+SplitterWidth);
|
|
||||||
end;
|
|
||||||
Site.BoundsRect:=NewSiteBounds;
|
|
||||||
FSiteClientRect:=Site.ClientRect;
|
|
||||||
|
|
||||||
// resize child
|
|
||||||
NewChildBounds:=Child.BoundsRect;
|
|
||||||
case ADockObject.DropAlign of
|
|
||||||
alTop: NewChildBounds:=Bounds(0,0,Site.ClientWidth,Child.ClientHeight);
|
|
||||||
alBottom: NewChildBounds:=Bounds(0,Site.ClientHeight-Child.ClientHeight,
|
|
||||||
Site.ClientWidth,Child.ClientHeight);
|
|
||||||
alLeft: NewChildBounds:=Bounds(0,0,Child.ClientWidth,Site.ClientHeight);
|
|
||||||
alRight: NewChildBounds:=Bounds(Site.ClientWidth-Child.ClientWidth,0,
|
|
||||||
Child.ClientWidth,Site.ClientHeight);
|
|
||||||
end;
|
|
||||||
Child.BoundsRect:=NewChildBounds;
|
|
||||||
|
|
||||||
if ChildSite<>nil then
|
|
||||||
ChildSite.PositionBoundSplitter;
|
|
||||||
|
|
||||||
// only allow to dock one control
|
|
||||||
DragManager.RegisterDockSite(Site,false);
|
|
||||||
debugln(['TAnchorDockManager.InsertControl AFTER Site="',DbgSName(Site),'" Control=',DbgSName(ADockObject.Control),' InsertAt=',dbgs(ADockObject.DropAlign),' Site.Bounds=',dbgs(Site.BoundsRect),' Control.Client=',dbgs(ADockObject.Control.ClientRect)]);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ begin
|
|||||||
|
|
||||||
Creator:=IDEWindowCreators.FindWithName(AForm.Name);
|
Creator:=IDEWindowCreators.FindWithName(AForm.Name);
|
||||||
if Creator=nil then exit;
|
if Creator=nil then exit;
|
||||||
|
debugln(['TIDEAnchorDockMaster.GetDefaultBounds AAA1 ',AForm.Name,' ',Creator.DockSibling,' ',dbgs(Creator.DockAlign)]);
|
||||||
if Creator.OnGetLayout<>nil then
|
if Creator.OnGetLayout<>nil then
|
||||||
Creator.OnGetLayout(Self,AForm.Name,NewBounds,DockSiblingName,DockAlign)
|
Creator.OnGetLayout(Self,AForm.Name,NewBounds,DockSiblingName,DockAlign)
|
||||||
else begin
|
else begin
|
||||||
@ -212,13 +213,14 @@ var
|
|||||||
DockSiblingName: string;
|
DockSiblingName: string;
|
||||||
DockAlign: TAlign;
|
DockAlign: TAlign;
|
||||||
DockSibling: TCustomForm;
|
DockSibling: TCustomForm;
|
||||||
NewDockSite: TAnchorDockHostSite;
|
NewDockSite: TCustomForm;
|
||||||
Site: TAnchorDockHostSite;
|
Site: TAnchorDockHostSite;
|
||||||
AControl: TControl;
|
AControl: TControl;
|
||||||
NeedPlacing: Boolean;
|
NeedPlacing: Boolean;
|
||||||
SiteForm: TCustomForm;
|
SiteForm: TCustomForm;
|
||||||
begin
|
begin
|
||||||
debugln(['TIDEAnchorDockMaster.ShowForm START ',DbgSName(AForm),' BringToFront=',BringToFront,' IsSite=',DockMaster.IsSite(AForm),' IsCustomSite=',DockMaster.IsCustomSite(AForm)]);
|
debugln(['TIDEAnchorDockMaster.ShowForm START ',DbgSName(AForm),' BringToFront=',BringToFront,' IsSite=',DockMaster.IsSite(AForm),' IsCustomSite=',DockMaster.IsCustomSite(AForm)]);
|
||||||
|
DumpStack;
|
||||||
try
|
try
|
||||||
AForm.DisableAlign;
|
AForm.DisableAlign;
|
||||||
|
|
||||||
@ -246,20 +248,24 @@ begin
|
|||||||
SiteForm.UndockWidth:=NewBounds.Right-NewBounds.Left;
|
SiteForm.UndockWidth:=NewBounds.Right-NewBounds.Left;
|
||||||
SiteForm.UndockHeight:=NewBounds.Bottom-NewBounds.Top;
|
SiteForm.UndockHeight:=NewBounds.Bottom-NewBounds.Top;
|
||||||
debugln(['TIDEAnchorDockMaster.ShowForm creator for ',DbgSName(AControl),' found: Left=',Creator.Left,' Top=',Creator.Top,' Width=',Creator.Width,' Height=',Creator.Height,' DockSiblingName=',DockSiblingName,' DockAlign=',dbgs(DockAlign)]);
|
debugln(['TIDEAnchorDockMaster.ShowForm creator for ',DbgSName(AControl),' found: Left=',Creator.Left,' Top=',Creator.Top,' Width=',Creator.Width,' Height=',Creator.Height,' DockSiblingName=',DockSiblingName,' DockAlign=',dbgs(DockAlign)]);
|
||||||
Site:=DockMaster.GetSite(SiteForm);
|
Site:=DockMaster.GetAnchorSite(SiteForm);
|
||||||
if DockMaster.IsAnchorSite(Site) and (DockSiblingName<>'') then begin
|
if (Site<>nil) and (DockSiblingName<>'') then begin
|
||||||
DockSibling:=Screen.FindForm(DockSiblingName);
|
DockSibling:=Screen.FindForm(DockSiblingName);
|
||||||
debugln(['TIDEAnchorDockMaster.ShowForm DockSiblingName="',DockSiblingName,'" DockSibling=',DbgSName(DockSibling)]);
|
debugln(['TIDEAnchorDockMaster.ShowForm DockSiblingName="',DockSiblingName,'" DockSibling=',DbgSName(DockSibling)]);
|
||||||
if DockSibling<>nil then begin
|
if DockSibling<>nil then begin
|
||||||
NewDockSite:=DockMaster.GetSite(DockSibling);
|
NewDockSite:=DockMaster.GetSite(DockSibling);
|
||||||
debugln(['TIDEAnchorDockMaster.ShowForm NewDockSite=',DbgSName(NewDockSite),'="',NewDockSite.Caption,'"']);
|
if NewDockSite<>nil then begin
|
||||||
DockMaster.ManualDock(Site,NewDockSite,DockAlign);
|
debugln(['TIDEAnchorDockMaster.ShowForm NewDockSite=',DbgSName(NewDockSite),'="',NewDockSite.Caption,'"']);
|
||||||
|
DockMaster.ManualDock(Site,NewDockSite,DockAlign);
|
||||||
|
debugln(['TIDEAnchorDockMaster.ShowForm after docking: ',DbgSName(AControl),' Floating=',DockMaster.IsFloating(AControl)]);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
debugln(['TIDEAnchorDockMaster.ShowForm MakeVisible ',DbgSName(AForm),' ',dbgs(AForm.BoundsRect),' Floating=',DockMaster.IsFloating(AForm)]);
|
||||||
DockMaster.MakeVisible(AForm,BringToFront);
|
DockMaster.MakeVisible(AForm,BringToFront);
|
||||||
AForm.EnableAlign;
|
AForm.EnableAlign;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user