diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index ff09ced869..8bee7c668a 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -571,6 +571,7 @@ void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg ) m_canvas->SetAnimationEnabled( cfg->m_Camera.animation_enabled ); m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier ); m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode ); + m_canvas->LoadSettings(); if( cfg->m_CurrentPreset == LEGACY_PRESET_FLAG ) { diff --git a/common/gal/hidpi_gl_3D_canvas.cpp b/common/gal/hidpi_gl_3D_canvas.cpp index a98c7cf324..3cb3c4ff6f 100644 --- a/common/gal/hidpi_gl_3D_canvas.cpp +++ b/common/gal/hidpi_gl_3D_canvas.cpp @@ -23,6 +23,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include #include const float HIDPI_GL_3D_CANVAS::m_delta_move_step_factor = 0.7f; @@ -71,6 +73,11 @@ void HIDPI_GL_3D_CANVAS::OnMouseWheelCamera( wxMouseEvent& event, bool aPan ) if( m_camera_is_moving ) return; + // Pick the modifier, if any. Shift beats control beats alt, we don't support more than one. + int modifiers = event.ShiftDown() ? WXK_SHIFT + : ( event.ControlDown() ? WXK_CONTROL + : ( event.AltDown() ? WXK_ALT : 0 ) ); + float delta_move = m_delta_move_step_factor * m_camera.GetZoom(); if( aPan ) @@ -87,21 +94,22 @@ void HIDPI_GL_3D_CANVAS::OnMouseWheelCamera( wxMouseEvent& event, bool aPan ) // wheel + ctrl -> horizontal scrolling; // wheel -> zooming. - if( aPan && !event.ControlDown() ) + if( aPan && modifiers != m_settings.m_scrollModifierZoom ) { - if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() ) + if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL + || modifiers == m_settings.m_scrollModifierPanH ) m_camera.Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); else m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); mouseActivity = true; } - else if( event.ShiftDown() && !aPan ) + else if( modifiers == m_settings.m_scrollModifierPanV && !aPan ) { m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); mouseActivity = true; } - else if( event.ControlDown() && !aPan ) + else if( modifiers == m_settings.m_scrollModifierPanH && !aPan ) { m_camera.Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) ); mouseActivity = true; diff --git a/common/gal/hidpi_gl_canvas.cpp b/common/gal/hidpi_gl_canvas.cpp index e20c9eb62a..5c2ee9f4b3 100644 --- a/common/gal/hidpi_gl_canvas.cpp +++ b/common/gal/hidpi_gl_canvas.cpp @@ -35,8 +35,28 @@ HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow* parent, wxWindowID id, const int* at wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ), m_scale_factor( DPI_SCALING::GetDefaultScaleFactor() ) { + this->LoadSettings(); } +void HIDPI_GL_CANVAS::LoadSettings() +{ + COMMON_SETTINGS* cfg = Pgm().GetCommonSettings(); + + m_settings.m_warpCursor = cfg->m_Input.center_on_zoom; + m_settings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb; + m_settings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan; + m_settings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration; + m_settings.m_horizontalPan = cfg->m_Input.horizontal_pan; + m_settings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration; + m_settings.m_zoomSpeed = cfg->m_Input.zoom_speed; + m_settings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto; + m_settings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom; + m_settings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h; + m_settings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v; + m_settings.m_dragLeft = cfg->m_Input.drag_left; + m_settings.m_dragMiddle = cfg->m_Input.drag_middle; + m_settings.m_dragRight = cfg->m_Input.drag_right; +} wxSize HIDPI_GL_CANVAS::GetNativePixelSize() const { diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 3646567095..73bb5c5369 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -395,7 +395,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) double scrollY = 0.0; if( axis == wxMOUSE_WHEEL_HORIZONTAL || modifiers == m_settings.m_scrollModifierPanH ) - scrollX = scrollVec.x; + scrollX = ( axis == wxMOUSE_WHEEL_HORIZONTAL ) ? scrollVec.x : -scrollVec.x; else scrollY = -scrollVec.y; diff --git a/include/gal/hidpi_gl_canvas.h b/include/gal/hidpi_gl_canvas.h index 0913f9cf1a..19fd7ae115 100644 --- a/include/gal/hidpi_gl_canvas.h +++ b/include/gal/hidpi_gl_canvas.h @@ -27,6 +27,9 @@ #ifndef HIDPI_GL_CANVAS_H #define HIDPI_GL_CANVAS_H +#include +#include +#include #include @@ -61,6 +64,15 @@ public: */ double GetScaleFactor() const; + /** + * Loads or updates the current settings + */ + void LoadSettings(); + +protected: + ///< Current VIEW_CONTROLS settings. + KIGFX::VC_SETTINGS m_settings; + private: /** * The current scale factor (e.g. for hi-DPI displays)