From 9df938484ae10462d7a2b9e61886ac9f5192b769 Mon Sep 17 00:00:00 2001 From: Julius Schmidt Date: Thu, 23 Nov 2017 22:04:52 +0000 Subject: [PATCH] support "disable autopan" with gal canvas Fixes: lp:1670712 * https://bugs.launchpad.net/kicad/+bug/1670712 --- common/draw_frame.cpp | 1 + common/draw_panel.cpp | 8 ++++++++ common/view/view_controls.cpp | 1 + common/view/wx_view_controls.cpp | 2 +- include/class_drawpanel.h | 2 +- include/view/view_controls.h | 13 +++++++++++++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index db3a31234f..e1f79db7b4 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -1155,6 +1155,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) // Transfer EDA_DRAW_PANEL settings GetGalCanvas()->GetViewControls()->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() ); GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() ); + GetGalCanvas()->GetViewControls()->EnableAutoPan( m_canvas->GetEnableAutoPan() ); } else if( m_galCanvasActive ) { diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index baf5e984f0..b8e579573d 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -652,6 +652,14 @@ void EDA_DRAW_PANEL::SetEnableMousewheelPan( bool aEnable ) GetParent()->GetGalCanvas()->GetViewControls()->EnableMousewheelPan( aEnable ); } +void EDA_DRAW_PANEL::SetEnableAutoPan( bool aEnable ) +{ + m_enableAutoPan = aEnable; + + if( GetParent()->IsGalCanvasActive() ) + GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable ); +} + void EDA_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable ) { diff --git a/common/view/view_controls.cpp b/common/view/view_controls.cpp index 46be594694..2f9884ba86 100644 --- a/common/view/view_controls.cpp +++ b/common/view/view_controls.cpp @@ -62,6 +62,7 @@ void VC_SETTINGS::Reset() m_snappingEnabled = true; m_grabMouse = false; m_autoPanEnabled = false; + m_autoPanSettingEnabled = false; m_autoPanMargin = 0.1; m_autoPanSpeed = 0.15; m_warpCursor = false; diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index e92d2b86f9..e34c8d34f9 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -87,7 +87,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) bool isAutoPanning = false; VECTOR2D mousePos( aEvent.GetX(), aEvent.GetY() ); - if( m_settings.m_autoPanEnabled ) + if( m_settings.m_autoPanEnabled && m_settings.m_autoPanSettingEnabled ) isAutoPanning = handleAutoPanning( aEvent ); if( !isAutoPanning && aEvent.Dragging() ) diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 2062f837de..5983a76656 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -149,7 +149,7 @@ public: bool GetEnableAutoPan() const { return m_enableAutoPan; } - void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; } + void SetEnableAutoPan( bool aEnable ); void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; } diff --git a/include/view/view_controls.h b/include/view/view_controls.h index c4470107df..21a2aed40e 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -72,6 +72,9 @@ struct VC_SETTINGS ///> Flag for turning on autopanning bool m_autoPanEnabled; + ///> Flag for turning on autopanning + bool m_autoPanSettingEnabled; + ///> Distance from cursor to VIEW edge when panning is active float m_autoPanMargin; @@ -140,6 +143,16 @@ public: m_settings.m_autoPanEnabled = aEnabled; } + /** + * Function EnableAutoPan + * Turns on/off auto panning (user setting to disable it entirely). + * @param aEnabled tells if the autopanning should be enabled. + */ + virtual void EnableAutoPan( bool aEnabled ) + { + m_settings.m_autoPanSettingEnabled = aEnabled; + } + /** * Function SetAutoPanSpeed() * Sets speed of autopanning.