fix 252 - top splitter not automatically snap to main menu

This commit is contained in:
Basile Burg 2018-02-25 08:00:47 +01:00
parent 77c19ba1e5
commit d2df199d82
2 changed files with 41 additions and 18 deletions

View File

@ -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

View File

@ -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 ---------------------------------------------------------------}