Allow to reverse the mouse wheel movement

This MR adds a CheckBox in the preferences window to reverse the
horizontal pan direction
This commit is contained in:
Rastersoft 2023-08-17 19:17:50 +00:00 committed by Seth Hillbrand
parent a7e74bf4bc
commit 5936960c1e
11 changed files with 314 additions and 18 deletions

View File

@ -123,6 +123,8 @@ bool PANEL_MOUSE_SETTINGS::TransferDataFromWindow()
cfg->m_Input.scroll_modifier_pan_h = m_currentScrollMod.panh;
cfg->m_Input.scroll_modifier_pan_v = m_currentScrollMod.panv;
cfg->m_Input.reverse_scroll_pan_h = m_checkPanHReverse->GetValue();
return true;
}
@ -175,9 +177,10 @@ void PANEL_MOUSE_SETTINGS::applySettingsToPanel( const COMMON_SETTINGS& aSetting
default: break;
}
m_currentScrollMod.zoom = aSettings.m_Input.scroll_modifier_zoom;
m_currentScrollMod.panh = aSettings.m_Input.scroll_modifier_pan_h;
m_currentScrollMod.panv = aSettings.m_Input.scroll_modifier_pan_v;
m_currentScrollMod.zoom = aSettings.m_Input.scroll_modifier_zoom;
m_currentScrollMod.panh = aSettings.m_Input.scroll_modifier_pan_h;
m_currentScrollMod.panv = aSettings.m_Input.scroll_modifier_pan_v;
m_currentScrollMod.panHReverse = aSettings.m_Input.reverse_scroll_pan_h;
updateScrollModButtons();
}
@ -256,14 +259,17 @@ void PANEL_MOUSE_SETTINGS::updateScrollModButtons()
set_wheel_buttons( m_currentScrollMod.panv, m_rbPanVNone, m_rbPanVCtrl, m_rbPanVShift,
m_rbPanVAlt );
m_checkPanHReverse->SetValue( m_currentScrollMod.panHReverse );
}
void PANEL_MOUSE_SETTINGS::onMouseDefaults( wxCommandEvent& event )
{
m_currentScrollMod.zoom = 0;
m_currentScrollMod.panh = WXK_CONTROL;
m_currentScrollMod.panv = WXK_SHIFT;
m_currentScrollMod.zoom = 0;
m_currentScrollMod.panh = WXK_CONTROL;
m_currentScrollMod.panv = WXK_SHIFT;
m_currentScrollMod.panHReverse = false;
updateScrollModButtons();
@ -273,9 +279,10 @@ void PANEL_MOUSE_SETTINGS::onMouseDefaults( wxCommandEvent& event )
void PANEL_MOUSE_SETTINGS::onTrackpadDefaults( wxCommandEvent& event )
{
m_currentScrollMod.zoom = WXK_CONTROL;
m_currentScrollMod.panh = WXK_SHIFT;
m_currentScrollMod.panv = 0;
m_currentScrollMod.zoom = WXK_CONTROL;
m_currentScrollMod.panh = WXK_SHIFT;
m_currentScrollMod.panv = 0;
m_currentScrollMod.panHReverse = false;
updateScrollModButtons();

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -196,7 +196,7 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow
bSizerLeft->Add( bSizer4, 0, wxEXPAND, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 5, 8, 0 );
fgSizer2 = new wxFlexGridSizer( 0, 6, 8, 0 );
fgSizer2->AddGrowableCol( 0 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -221,6 +221,10 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow
m_lblAlt->Wrap( -1 );
fgSizer2->Add( m_lblAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_staticText18 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_staticText18->Wrap( -1 );
fgSizer2->Add( m_staticText18, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_staticText10 = new wxStaticText( this, wxID_ANY, _("Zoom:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText10->Wrap( -1 );
fgSizer2->Add( m_staticText10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
@ -237,6 +241,10 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow
m_rbZoomAlt = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_rbZoomAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_staticText201 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_staticText201->Wrap( -1 );
fgSizer2->Add( m_staticText201, 0, wxALL, 5 );
m_staticText11 = new wxStaticText( this, wxID_ANY, _("Pan up/down:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
fgSizer2->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
@ -253,6 +261,10 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow
m_rbPanVAlt = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_rbPanVAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_staticText211 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_staticText211->Wrap( -1 );
fgSizer2->Add( m_staticText211, 0, wxALL, 5 );
m_staticText20 = new wxStaticText( this, wxID_ANY, _("Pan left/right:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
fgSizer2->Add( m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
@ -269,6 +281,9 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow
m_rbPanHAlt = new wxRadioButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_rbPanHAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_checkPanHReverse = new wxCheckBox( this, wxID_ANY, _("Reverse"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_checkPanHReverse, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizer2->Add( 0, 10, 1, wxEXPAND, 5 );

View File

@ -1626,7 +1626,7 @@
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">5</property>
<property name="cols">6</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0</property>
<property name="growablerows"></property>
@ -1942,6 +1942,67 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText18</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
@ -2263,6 +2324,67 @@
<event name="OnRadioButton">OnScrollRadioButton</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText201</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
@ -2584,6 +2706,67 @@
<event name="OnRadioButton">OnScrollRadioButton</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText211</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
@ -2905,6 +3088,70 @@
<event name="OnRadioButton">OnScrollRadioButton</event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Reverse</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkPanHReverse</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -70,21 +70,25 @@ class PANEL_MOUSE_SETTINGS_BASE : public RESETTABLE_PANEL
wxStaticText* m_lblCtrl;
wxStaticText* m_staticText8;
wxStaticText* m_lblAlt;
wxStaticText* m_staticText18;
wxStaticText* m_staticText10;
wxRadioButton* m_rbZoomNone;
wxRadioButton* m_rbZoomCtrl;
wxRadioButton* m_rbZoomShift;
wxRadioButton* m_rbZoomAlt;
wxStaticText* m_staticText201;
wxStaticText* m_staticText11;
wxRadioButton* m_rbPanVNone;
wxRadioButton* m_rbPanVCtrl;
wxRadioButton* m_rbPanVShift;
wxRadioButton* m_rbPanVAlt;
wxStaticText* m_staticText211;
wxStaticText* m_staticText20;
wxRadioButton* m_rbPanHNone;
wxRadioButton* m_rbPanHCtrl;
wxRadioButton* m_rbPanHShift;
wxRadioButton* m_rbPanHAlt;
wxCheckBox* m_checkPanHReverse;
wxCheckBox* m_checkEnablePanH;
wxButton* m_mouseDefaults;
wxButton* m_trackpadDefaults;

View File

@ -78,7 +78,8 @@ void HIDPI_GL_3D_CANVAS::OnMouseWheelCamera( wxMouseEvent& event, bool aPan )
: ( event.ControlDown() ? WXK_CONTROL
: ( event.AltDown() ? WXK_ALT : 0 ) );
float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
float horizontalSign = m_settings.m_scrollReversePanH ? -1 : 1;
if( aPan )
delta_move *= 0.01f * event.GetWheelRotation();
@ -111,7 +112,7 @@ void HIDPI_GL_3D_CANVAS::OnMouseWheelCamera( wxMouseEvent& event, bool aPan )
}
else if( modifiers == m_settings.m_scrollModifierPanH && !aPan )
{
m_camera.Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) );
m_camera.Pan( SFVEC3F( delta_move * horizontalSign, 0.0f, 0.0f ) );
mouseActivity = true;
}
else

View File

@ -56,6 +56,7 @@ void HIDPI_GL_CANVAS::LoadSettings()
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;
m_settings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h;
}
wxSize HIDPI_GL_CANVAS::GetNativePixelSize() const

View File

@ -275,6 +275,9 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
m_params.emplace_back( new PARAM<int>( "input.scroll_modifier_pan_v",
&m_Input.scroll_modifier_pan_v, WXK_SHIFT ) );
m_params.emplace_back( new PARAM<bool>( "input.reverse_scroll_pan_h",
&m_Input.reverse_scroll_pan_h, false ) );
m_params.emplace_back( new PARAM_ENUM<MOUSE_DRAG_ACTION>( "input.mouse_left",
&m_Input.drag_left, MOUSE_DRAG_ACTION::DRAG_SELECTED, MOUSE_DRAG_ACTION::DRAG_ANY,
MOUSE_DRAG_ACTION::SELECT ) );

View File

@ -171,6 +171,7 @@ void WX_VIEW_CONTROLS::LoadSettings()
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;
m_settings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h;
m_zoomController.reset();
@ -391,13 +392,24 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
// Scrolling
VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
double scrollX = 0.0;
double scrollY = 0.0;
double scrollX = 0.0;
double scrollY = 0.0;
bool hReverse = false;
if( axis != wxMOUSE_WHEEL_HORIZONTAL )
hReverse = m_settings.m_scrollReversePanH;
if( axis == wxMOUSE_WHEEL_HORIZONTAL || modifiers == m_settings.m_scrollModifierPanH )
scrollX = ( axis == wxMOUSE_WHEEL_HORIZONTAL ) ? scrollVec.x : -scrollVec.x;
{
if( hReverse )
scrollX = scrollVec.x;
else
scrollX = ( axis == wxMOUSE_WHEEL_HORIZONTAL ) ? scrollVec.x : -scrollVec.x;
}
else
{
scrollY = -scrollVec.y;
}
VECTOR2D delta( scrollX, scrollY );

View File

@ -33,6 +33,7 @@ struct SCROLL_MOD_SET
int zoom;
int panh;
int panv;
bool panHReverse;
};

View File

@ -98,6 +98,8 @@ public:
MOUSE_DRAG_ACTION drag_left;
MOUSE_DRAG_ACTION drag_middle;
MOUSE_DRAG_ACTION drag_right;
bool reverse_scroll_pan_h;
};
struct GRAPHICS

View File

@ -120,6 +120,9 @@ struct VC_SETTINGS
///< Position of the above event.
VECTOR2D m_lastKeyboardCursorPosition;
///< Wether to invert the scroll wheel movement for horizontal pan
bool m_scrollReversePanH;
};