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

View File

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

View File

@ -367,6 +367,25 @@ procedure TDockPerformer.DragMove(APosition: TPoint);
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;
//Replace with lookup in Screen.Zorder(?)
var
@ -416,6 +435,9 @@ procedure TDockPerformer.DragMove(APosition: TPoint);
if not AControl.IsVisible then continue;
if AControl=FDockObject.Control 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
begin