← Back to team overview

kicad-developers team mailing list archive

[PATCH] support "disable autopan" with gal canvas

 

This patch adds support for the "disable autopan" feature to the gal canvas.

I'm not entirely sure this is the best way to do it, there is already an "autopan setting" but it is actually used to indicate whether the current tool uses autopan.

fixes https://bugs.launchpad.net/kicad/+bug/1670712
From 8acf54a7ce1af8599f0fd818e916f9f3da2deb23 Mon Sep 17 00:00:00 2001
From: Julius Schmidt <aiju@xxxxxxxxxx>
Date: Thu, 23 Nov 2017 22:04:52 +0000
Subject: [PATCH] support "disable autopan" with gal canvas
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.10.2"

This is a multi-part message in MIME format.
--------------2.10.2
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 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(-)


--------------2.10.2
Content-Type: text/x-patch; name="0001-support-disable-autopan-with-gal-canvas.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-support-disable-autopan-with-gal-canvas.patch"

diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index db3a312..e1f79db 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 a438292..1273be8 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 46be594..2f9884b 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 e92d2b8..e34c8d3 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 2062f83..5983a76 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 c447010..21a2aed 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;
 
@@ -141,6 +144,16 @@ public:
     }
 
     /**
+     * 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.
      * @param aSpeed is a new speed for autopanning.

--------------2.10.2--



Follow ups