AnchorDocking fixes by Andrey Zubarev (approved by Željan).

Merge request !111
This commit is contained in:
Maxim Ganetsky 2022-11-15 04:15:06 +03:00
commit e3b1f91028
3 changed files with 37 additions and 0 deletions

View File

@ -489,6 +489,7 @@ type
procedure StoreConstraints; procedure StoreConstraints;
function GetSitePreferredClientSize: TPoint; function GetSitePreferredClientSize: TPoint;
function IsEnabledControl(Control: TControl):Boolean; override; function IsEnabledControl(Control: TControl):Boolean; override;
function CanBeDoubleDocked:Boolean; override;
property Site: TWinControl read FSite; // the associated TControl (a TAnchorDockHostSite or a custom dock site) 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 property DockSite: TAnchorDockHostSite read FDockSite; // if Site is a TAnchorDockHostSite, this is it
@ -4460,6 +4461,8 @@ begin
OldControl:=GetOneControl; OldControl:=GetOneControl;
OldSite:=MakeSite(OldControl); OldSite:=MakeSite(OldControl);
AddCleanControl(OldSite); AddCleanControl(OldSite);
if not(OldControl is TAnchorDockHostSite) then
OldSite.Header.FHeaderPosition:=Header.FHeaderPosition;
OldSite.AnchorClient(0); OldSite.AnchorClient(0);
// the LCL will compute the bounds later after EnableAutoSizing // the LCL will compute the bounds later after EnableAutoSizing
// but the bounds are needed now => set them manually // but the bounds are needed now => set them manually
@ -5184,6 +5187,7 @@ begin
// header // header
Header.Align:=Site.Header.Align; Header.Align:=Site.Header.Align;
Header.HeaderPosition:=Site.Header.HeaderPosition;
Header.Caption:=Site.Header.Caption; Header.Caption:=Site.Header.Caption;
UpdateHeaderShowing; UpdateHeaderShowing;
Caption:=Site.Caption; Caption:=Site.Caption;
@ -7560,6 +7564,11 @@ begin
Result := (DockMaster <> nil) and DockMaster.IsSite(Control); Result := (DockMaster <> nil) and DockMaster.IsSite(Control);
end; end;
function TAnchorDockManager.CanBeDoubleDocked:Boolean;
begin
Result := False;
end;
{ TAnchorDockSplitter } { TAnchorDockSplitter }
procedure TAnchorDockSplitter.SetResizeAnchor(const AValue: TAnchorKind); procedure TAnchorDockSplitter.SetResizeAnchor(const AValue: TAnchorKind);

View File

@ -624,6 +624,7 @@ type
procedure SetReplacingControl(Control: TControl); virtual; procedure SetReplacingControl(Control: TControl); virtual;
function AutoFreeByControl: Boolean; virtual; function AutoFreeByControl: Boolean; virtual;
function IsEnabledControl(Control: TControl):Boolean; virtual; function IsEnabledControl(Control: TControl):Boolean; virtual;
function CanBeDoubleDocked:Boolean; virtual;
end; end;
TDockManagerClass = class of TDockManager; TDockManagerClass = class of TDockManager;
@ -4638,6 +4639,11 @@ begin
end; end;
function TDockManager.CanBeDoubleDocked:Boolean;
begin
result:=true;
end;
function TDockManager.IsEnabledControl(Control: TControl):Boolean; function TDockManager.IsEnabledControl(Control: TControl):Boolean;
begin begin
Result := true; Result := true;

View File

@ -367,6 +367,25 @@ procedure TDockPerformer.DragMove(APosition: TPoint);
end; end;
end; end;
function IsClientChildOfControl(AControl:TWinControl): Boolean;
var
Client:TControl;
begin
Result := False;
Client := FDockObject.Control;
if Assigned(AControl) then
while Assigned(Client) do
begin
if AControl=Client then
begin
Result := True;
exit;
end;
Client := Client.Parent;
end;
end;
function FindDockSiteAtPosition: TWinControl; function FindDockSiteAtPosition: TWinControl;
//Replace with lookup in Screen.Zorder(?) //Replace with lookup in Screen.Zorder(?)
var var
@ -416,6 +435,9 @@ procedure TDockPerformer.DragMove(APosition: TPoint);
if not AControl.IsVisible then continue; if not AControl.IsVisible then continue;
if AControl=FDockObject.Control then continue; if AControl=FDockObject.Control then continue;
if IsControlChildOfClient(AControl) then continue; if IsControlChildOfClient(AControl) then continue;
if AControl.DockManager<>nil then
if not AControl.DockManager.CanBeDoubleDocked then
if IsClientChildOfControl(AControl) then continue;
if ItCanBeHostSite then if ItCanBeHostSite then
begin begin