From 63d4afb3eef056968588eb96aafb5f418b6d8cc5 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 11 Dec 2018 17:49:28 +0100 Subject: [PATCH] Support autopanning in GALified eeschema Fixes: lp:1807234 * https://bugs.launchpad.net/kicad/+bug/1807234 --- common/legacy_wx/eda_draw_panel.cpp | 16 ++++++++-------- eeschema/sch_draw_panel.cpp | 24 +++++++++++++++--------- eeschema/sch_draw_panel.h | 1 + include/legacy_gal/class_drawpanel.h | 4 +--- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/common/legacy_wx/eda_draw_panel.cpp b/common/legacy_wx/eda_draw_panel.cpp index 585ba44693..c46a7482c3 100644 --- a/common/legacy_wx/eda_draw_panel.cpp +++ b/common/legacy_wx/eda_draw_panel.cpp @@ -920,7 +920,7 @@ void EDA_DRAW_PANEL::OnMouseEntering( wxMouseEvent& aEvent ) void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) { if( m_mouseCaptureCallback == NULL ) // No command in progress. - m_requestAutoPan = false; + SetAutoPanRequest( false ); if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents ) return; @@ -1094,7 +1094,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_canStartBlock = -1; if( !IsMouseCaptured() ) // No mouse capture in progress. - m_requestAutoPan = false; + SetAutoPanRequest( false ); if( GetParent()->IsActive() ) SetFocus(); @@ -1268,7 +1268,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { - m_requestAutoPan = false; + SetAutoPanRequest( false ); GetParent()->HandleBlockPlace( &DC ); m_ignoreNextLeftButtonRelease = true; } @@ -1298,7 +1298,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) } else { - m_requestAutoPan = true; + SetAutoPanRequest( true ); SetCursor( wxCURSOR_SIZING ); } } @@ -1324,19 +1324,19 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) if( m_endMouseCaptureCallback ) { m_endMouseCaptureCallback( this, &DC ); - m_requestAutoPan = false; + SetAutoPanRequest( false ); } SetCursor( (wxStockCursor) m_currentCursor ); } else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END ) { - m_requestAutoPan = false; + SetAutoPanRequest( false ); GetParent()->HandleBlockEnd( &DC ); SetCursor( (wxStockCursor) m_currentCursor ); if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { - m_requestAutoPan = true; + SetAutoPanRequest( true ); SetCursor( wxCURSOR_HAND ); } } @@ -1535,7 +1535,7 @@ void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title, m_mouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL; - m_requestAutoPan = false; + SetAutoPanRequest( false ); if( id != -1 && cursor != -1 ) { diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index d594af1e85..19259c7c4d 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -119,7 +119,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, m_mouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL; - m_requestAutoPan = false; m_enableBlockCommands = false; m_minDragEventCount = 0; @@ -216,13 +215,20 @@ void SCH_DRAW_PANEL::SetEnableMousewheelPan( bool aEnable ) void SCH_DRAW_PANEL::SetEnableAutoPan( bool aEnable ) { - m_enableAutoPan = aEnable; + EDA_DRAW_PANEL::SetEnableAutoPan( aEnable ); if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable ); } +void SCH_DRAW_PANEL::SetAutoPanRequest( bool aEnable ) +{ + wxCHECK( GetParent()->IsGalCanvasActive(), /*void*/ ); + GetParent()->GetGalCanvas()->GetViewControls()->SetAutoPan( aEnable ); +} + + void SCH_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable ) { m_enableZoomNoCenter = aEnable; @@ -293,7 +299,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_canStartBlock = -1; if( !IsMouseCaptured() ) // No mouse capture in progress. - m_requestAutoPan = false; + SetAutoPanRequest( false ); if( GetParent()->IsActive() ) SetFocus(); @@ -436,7 +442,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { - m_requestAutoPan = false; + SetAutoPanRequest( false ); GetParent()->HandleBlockPlace( nullptr ); m_ignoreNextLeftButtonRelease = true; } @@ -468,7 +474,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) } else { - m_requestAutoPan = true; + SetAutoPanRequest( true ); SetCursor( wxCURSOR_SIZING ); } } @@ -494,19 +500,19 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) if( m_endMouseCaptureCallback ) { m_endMouseCaptureCallback( this, nullptr ); - m_requestAutoPan = false; + SetAutoPanRequest( false ); } //SetCursor( (wxStockCursor) m_currentCursor ); } else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END ) { - m_requestAutoPan = false; + SetAutoPanRequest( false ); GetParent()->HandleBlockEnd( nullptr ); //SetCursor( (wxStockCursor) m_currentCursor ); if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { - m_requestAutoPan = true; + SetAutoPanRequest( true ); SetCursor( wxCURSOR_HAND ); } } @@ -575,7 +581,7 @@ void SCH_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title, m_mouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL; - m_requestAutoPan = false; + SetAutoPanRequest( false ); if( id != -1 && cursor != -1 ) { diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 5f26cfe41d..e5dc309f7d 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -66,6 +66,7 @@ public: void SetEnableMousewheelPan( bool aEnable ) override; void SetEnableZoomNoCenter( bool aEnable ) override; void SetEnableAutoPan( bool aEnable ) override; + void SetAutoPanRequest( bool aEnable ) override; BASE_SCREEN* GetScreen() override; virtual EDA_DRAW_FRAME* GetParent() const override; diff --git a/include/legacy_gal/class_drawpanel.h b/include/legacy_gal/class_drawpanel.h index c0564d04a5..e0917c1f01 100644 --- a/include/legacy_gal/class_drawpanel.h +++ b/include/legacy_gal/class_drawpanel.h @@ -46,8 +46,6 @@ protected: bool m_enableAutoPan; ///< True to enable automatic panning. - bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true. - bool m_ignoreMouseEvents; ///< Ignore mouse events when true. /* Used to inhibit a response to a mouse left button release, after a double click @@ -122,7 +120,7 @@ public: virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; }; - void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; } + virtual void SetAutoPanRequest( bool aEnable ) = 0; void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; }