From d2df199d82a8be14f02a31175c1ddb6bb8c06ce5 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 25 Feb 2018 08:00:47 +0100 Subject: [PATCH] fix 252 - top splitter not automatically snap to main menu --- src/ce_main.lfm | 4 +++- src/ce_main.pas | 55 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/ce_main.lfm b/src/ce_main.lfm index b6f655c4..47ec57fe 100644 --- a/src/ce_main.lfm +++ b/src/ce_main.lfm @@ -1,7 +1,7 @@ object CEMainForm: TCEMainForm Left = 383 Height = 54 - Top = 609 + Top = 610 Width = 687 AllowDropFiles = True Caption = 'Coedit' @@ -1467,6 +1467,8 @@ object CEMainForm: TCEMainForm OnClose = FormClose OnCloseQuery = FormCloseQuery OnDropFiles = FormDropFiles + OnResize = FormResize + OnWindowStateChange = FormWindowStateChange ShowHint = True LCLVersion = '1.8.0.6' object mainMenu: TMainMenu diff --git a/src/ce_main.pas b/src/ce_main.pas index d20296e3..241507ed 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -289,6 +289,8 @@ type procedure actSetRunnableSwExecute(Sender: TObject); procedure ApplicationProperties1Activate(Sender: TObject); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); + procedure FormResize(Sender: TObject); + procedure FormWindowStateChange(Sender: TObject); procedure updateDocumentBasedAction(sender: TObject); procedure updateProjectBasedAction(sender: TObject); procedure updateDocEditBasedAction(sender: TObject); @@ -442,6 +444,7 @@ type // widget interfaces subroutines procedure updateWidgetMenuEntry(sender: TObject); procedure widgetShowFromAction(sender: TObject); + procedure snapTopSplitterToMenu; // run & exec sub routines function runnableExename: string; @@ -1561,8 +1564,7 @@ procedure TCEMainForm.InitDocking(reset: boolean = false); var i: Integer; widg: TCEWidget; - topsite : TControl; - topsplt : TAnchorDockSplitter; + topsplt: TAnchorDockSplitter; begin if not reset then @@ -1656,21 +1658,6 @@ begin end; WindowState:= wsMaximized; end; - - // lock space between the menu and the widgets - if GetDockSplitterOrParent(DockMaster.GetSite(fEditWidg), akTop, topsite) then - begin - if topsite is TAnchorDockHostSite then - if TAnchorDockHostSite(topsite).BoundSplitter.isNotNil then - begin - TAnchorDockHostSite(topsite).BoundSplitter.MoveSplitter(-500); - TAnchorDockHostSite(topsite).BoundSplitter.OnCanOffset:= @LockTopWindow; - end; - end else if GetDockSplitter(DockMaster.GetSite(fEditWidg), akTop, topsplt) then - begin - topsplt.MoveSplitter(-500); - topsplt.OnCanOffset:= @LockTopWindow; - end; end; procedure TCEMainForm.LoadSettings; @@ -2001,6 +1988,16 @@ begin SaveDocking; end; +procedure TCEMainForm.FormResize(Sender: TObject); +begin + snapTopSplitterToMenu; +end; + +procedure TCEMainForm.FormWindowStateChange(Sender: TObject); +begin + snapTopSplitterToMenu; +end; + destructor TCEMainForm.destroy; begin SaveSettings; @@ -3514,6 +3511,30 @@ begin TForm(widg.Parent).SendToBack; end; end; + +procedure TCEMainForm.snapTopSplitterToMenu; +var + topsplt: TAnchorDockSplitter; + topsite: TControl; +begin + if GetDockSplitterOrParent(DockMaster.GetSite(fEditWidg), akTop, topsite) then + begin + if topsite is TAnchorDockHostSite and + TAnchorDockHostSite(topsite).BoundSplitter.isNotNil and + (TAnchorDockHostSite(topsite).BoundSplitter.Top > 0) then + begin + TAnchorDockHostSite(topsite).BoundSplitter.OnCanOffset:=nil; + TAnchorDockHostSite(topsite).BoundSplitter.MoveSplitter(-3000); + TAnchorDockHostSite(topsite).BoundSplitter.OnCanOffset:= @LockTopWindow; + end; + end else if GetDockSplitter(DockMaster.GetSite(fEditWidg), akTop, topsplt) and + (topsplt.top > 0) then + begin + topsplt.OnCanOffset := nil; + topsplt.MoveSplitter(-3000); + topsplt.OnCanOffset:= @LockTopWindow; + end; +end; {$ENDREGION} {$REGION project ---------------------------------------------------------------}