From 799230b882c38aae407bd3e6bfcb6fd8ff3e96a8 Mon Sep 17 00:00:00 2001 From: "james.k.crook@gmail.com" Date: Sun, 2 Nov 2014 17:39:50 +0000 Subject: [PATCH] Much easier to dock with an empty dock now. Overlapping a dock is now enough to trigger docking. Previously the top left corner had to be in the dock. --- src/toolbars/ToolDock.cpp | 5 +++++ src/toolbars/ToolDock.h | 7 +------ src/toolbars/ToolManager.cpp | 14 ++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/toolbars/ToolDock.cpp b/src/toolbars/ToolDock.cpp index cb199c0d0..9a3d1c185 100644 --- a/src/toolbars/ToolDock.cpp +++ b/src/toolbars/ToolDock.cpp @@ -115,6 +115,11 @@ void ToolDock::Undock( ToolBar *bar ) } } +int ToolDock::GetBarCount() +{ + return mDockedBars.GetCount(); +} + // // Handle ToolDock events // diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index 6f19d9e5f..ba3e03e87 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -54,17 +54,12 @@ class ToolDock:public wxPanel ~ToolDock(); void LayoutToolBars(); - void ShowHide( int type ); - void Expose( int type, bool show ); - int GetOrder( ToolBar *bar ); - + int GetBarCount(); void Dock( ToolBar *bar, int ndx = -1 ); - void Undock( ToolBar *bar ); - int PositionBar( ToolBar *t, wxPoint & pos, wxRect & rect ); protected: diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 3f76e2706..e048eab87 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -1033,16 +1033,15 @@ void ToolManager::OnMouse( wxMouseEvent & event ) // lands back where we started. pos += wxPoint( 5, 20 ); - // Is mouse pointer within either dock? + + // To find which dock, rather than test against pos, test against the whole dragger rect. + // This means it is enough to overlap the dock to dock with it. + wxRect barRect = mDragWindow->GetRect(); ToolDock *dock = NULL; - if( tr.Contains( pos ) ) - { + if( tr.Intersects( barRect ) ) dock = mTopDock; - } - else if( br.Contains( pos ) ) - { + else if( br.Intersects( barRect ) ) dock = mBotDock; - } // Looks like we have a winner... if( dock ) @@ -1050,7 +1049,6 @@ void ToolManager::OnMouse( wxMouseEvent & event ) wxPoint p; wxRect r; - // Calculate where the bar would be placed mDragBefore = dock->PositionBar( mDragBar, pos, r );