Unify mouse movements
This commit is contained in:
parent
684344c45c
commit
43fe1eec84
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <settings/common_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gal/hidpi_gl_3D_canvas.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#ifndef HIDPI_GL_CANVAS_H
|
||||
#define HIDPI_GL_CANVAS_H
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <wx/glcanvas.h>
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue