slightly optimize the proc that snap the top site to the menu

and prevent a double consecutive call in some cases
This commit is contained in:
Basile Burg 2019-04-04 10:04:30 +02:00
parent 8e4219f8b6
commit 46527beb88
2 changed files with 16 additions and 21 deletions

View File

@ -10,7 +10,6 @@ object MainForm: TMainForm
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnDropFiles = FormDropFiles OnDropFiles = FormDropFiles
OnResize = FormResize OnResize = FormResize
OnWindowStateChange = FormWindowStateChange
ShowHint = True ShowHint = True
LCLVersion = '2.0.0.4' LCLVersion = '2.0.0.4'
object mainMenu: TMainMenu object mainMenu: TMainMenu

View File

@ -331,7 +331,6 @@ type
procedure ApplicationProperties1Activate(Sender: TObject); procedure ApplicationProperties1Activate(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormResize(Sender: TObject); procedure FormResize(Sender: TObject);
procedure FormWindowStateChange(Sender: TObject);
procedure mnuItemAboutClick(Sender: TObject); procedure mnuItemAboutClick(Sender: TObject);
procedure mnuItemCheckUpdClick(Sender: TObject); procedure mnuItemCheckUpdClick(Sender: TObject);
procedure mnuItemManualClick(Sender: TObject); procedure mnuItemManualClick(Sender: TObject);
@ -2094,11 +2093,6 @@ begin
snapTopSplitterToMenu; snapTopSplitterToMenu;
end; end;
procedure TMainForm.FormWindowStateChange(Sender: TObject);
begin
snapTopSplitterToMenu;
end;
procedure TMainForm.mnuItemAboutClick(Sender: TObject); procedure TMainForm.mnuItemAboutClick(Sender: TObject);
begin begin
fInfoWidg.showWidget; fInfoWidg.showWidget;
@ -3687,8 +3681,9 @@ end;
procedure TMainForm.snapTopSplitterToMenu; procedure TMainForm.snapTopSplitterToMenu;
var var
topsplt: TAnchorDockSplitter; topSplt: TAnchorDockSplitter;
topsite: TControl; topHost: TAnchorDockHostSite = nil;
topSite: TControl;
edtSite: TControl; edtSite: TControl;
begin begin
if not fDockingIsInitialized then if not fDockingIsInitialized then
@ -3696,22 +3691,23 @@ begin
edtSite := DockMaster.GetSite(fEditWidg); edtSite := DockMaster.GetSite(fEditWidg);
if edtSite.isNil then if edtSite.isNil then
exit; exit;
if GetDockSplitterOrParent(edtSite, akTop, topsite) then if GetDockSplitterOrParent(edtSite, akTop, topSite) then
begin begin
if topsite is TAnchorDockHostSite and if topSite is TAnchorDockHostSite then
TAnchorDockHostSite(topsite).BoundSplitter.isNotNil and topHost := TAnchorDockHostSite(topSite);
(TAnchorDockHostSite(topsite).BoundSplitter.Top > 0) then if topHost.isNotNil and topHost.BoundSplitter.isNotNil and
(topHost.BoundSplitter.Top > 0) then
begin begin
TAnchorDockHostSite(topsite).BoundSplitter.OnCanOffset:=nil; topHost.BoundSplitter.OnCanOffset:=nil;
TAnchorDockHostSite(topsite).BoundSplitter.MoveSplitter(-3000); topHost.BoundSplitter.MoveSplitter(-topHost.BoundSplitter.Top);
TAnchorDockHostSite(topsite).BoundSplitter.OnCanOffset:= @LockTopWindow; topHost.BoundSplitter.OnCanOffset:= @LockTopWindow;
end; end;
end else if GetDockSplitter(DockMaster.GetSite(fEditWidg), akTop, topsplt) and end else if GetDockSplitter(DockMaster.GetSite(fEditWidg), akTop, topSplt) and
(topsplt.top > 0) then (topSplt.top > 0) then
begin begin
topsplt.OnCanOffset := nil; topSplt.OnCanOffset := nil;
topsplt.MoveSplitter(-3000); topSplt.MoveSplitter(-topSplt.top);
topsplt.OnCanOffset:= @LockTopWindow; topSplt.OnCanOffset:= @LockTopWindow;
end; end;
end; end;
{$ENDREGION} {$ENDREGION}