ADDED: New mouse settings panel, expanded mouse settings
You can now choose the behavior of dragging with the middle and right mouse buttons. You can also choose which modifier keys to use for panning and zooming with the scroll wheel or trackpad. You can also customize the zoom speed, which makes it possible to have a good zoom experience on a wider range of input devices. You can also now zoom by dragging with the right or middle button if desired. Fixes https://gitlab.com/kicad/code/kicad/-/issues/3885 Fixes https://gitlab.com/kicad/code/kicad/-/issues/4348
This commit is contained in:
parent
c7daf8a8f3
commit
a52435bbb0
|
@ -137,7 +137,8 @@ void PANEL_PREV_3D::loadCommonSettings()
|
|||
const DPI_SCALING dpi{ settings, this };
|
||||
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
|
||||
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
|
||||
// TODO(JE) use all control options
|
||||
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -886,5 +886,6 @@ void EDA_3D_VIEWER::loadCommonSettings()
|
|||
|
||||
const DPI_SCALING dpi{ settings, this };
|
||||
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
|
||||
// TODO(JE) use all control options
|
||||
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 );
|
||||
}
|
||||
|
|
|
@ -179,6 +179,8 @@ set( COMMON_DLG_SRCS
|
|||
dialogs/panel_common_settings.cpp
|
||||
dialogs/panel_common_settings_base.cpp
|
||||
dialogs/panel_hotkeys_editor.cpp
|
||||
dialogs/panel_mouse_settings.cpp
|
||||
dialogs/panel_mouse_settings_base.cpp
|
||||
dialogs/panel_text_variables.cpp
|
||||
dialogs/panel_text_variables_base.cpp
|
||||
dialogs/wx_html_report_panel.cpp
|
||||
|
|
|
@ -114,9 +114,6 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
|
|||
}
|
||||
|
||||
m_checkBoxIconsInMenus->SetValue( commonSettings->m_Appearance.use_icons_in_menus );
|
||||
m_ZoomCenterOpt->SetValue( commonSettings->m_Input.center_on_zoom );
|
||||
m_MousewheelPANOpt->SetValue( commonSettings->m_Input.mousewheel_pan );
|
||||
m_AutoPANOpt->SetValue( commonSettings->m_Input.auto_pan );
|
||||
|
||||
m_PreferSelectToDrag->SetValue( commonSettings->m_Input.prefer_select_to_drag );
|
||||
m_warpMouseOnMove->SetValue( commonSettings->m_Input.warp_mouse_on_move );
|
||||
|
@ -152,10 +149,7 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
|
|||
|
||||
commonSettings->m_Appearance.use_icons_in_menus = m_checkBoxIconsInMenus->GetValue();
|
||||
|
||||
commonSettings->m_Input.auto_pan = m_AutoPANOpt->GetValue();
|
||||
commonSettings->m_Input.center_on_zoom = m_ZoomCenterOpt->GetValue();
|
||||
commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
|
||||
commonSettings->m_Input.mousewheel_pan = m_MousewheelPANOpt->GetValue();
|
||||
commonSettings->m_Input.prefer_select_to_drag = m_PreferSelectToDrag->GetValue();
|
||||
commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 6 2019)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -175,27 +175,6 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
|
|||
wxBoxSizer* rightSizer;
|
||||
rightSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticBoxSizer* sbSizer51;
|
||||
sbSizer51 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pan and Zoom") ), wxVERTICAL );
|
||||
|
||||
m_ZoomCenterOpt = new wxCheckBox( sbSizer51->GetStaticBox(), wxID_ANY, _("Ce&nter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ZoomCenterOpt->SetToolTip( _("Center the cursor on screen when zooming.") );
|
||||
|
||||
sbSizer51->Add( m_ZoomCenterOpt, 0, wxTOP|wxRIGHT|wxLEFT, 4 );
|
||||
|
||||
m_MousewheelPANOpt = new wxCheckBox( sbSizer51->GetStaticBox(), wxID_ANY, _("Use touchpad to pan"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_MousewheelPANOpt->SetToolTip( _("Enable touchpad-friendly controls (pan with scroll action, zoom with Ctrl+scroll).") );
|
||||
|
||||
sbSizer51->Add( m_MousewheelPANOpt, 0, wxALL, 4 );
|
||||
|
||||
m_AutoPANOpt = new wxCheckBox( sbSizer51->GetStaticBox(), wxID_AUTOPAN, _("&Pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_AutoPANOpt->SetToolTip( _("When drawing a track or moving an item, pan when approaching the edge of the display.") );
|
||||
|
||||
sbSizer51->Add( m_AutoPANOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 );
|
||||
|
||||
|
||||
rightSizer->Add( sbSizer51, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
wxStaticBoxSizer* sbSizer4;
|
||||
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Editing") ), wxVERTICAL );
|
||||
|
||||
|
|
|
@ -1688,212 +1688,6 @@
|
|||
<property name="name">rightSizer</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Pan and Zoom</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sbSizer51</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="parent">1</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">4</property>
|
||||
<property name="flag">wxTOP|wxRIGHT|wxLEFT</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">Ce&nter and warp cursor on zoom</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_ZoomCenterOpt</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"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Center the cursor on screen when zooming.</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">4</property>
|
||||
<property name="flag">wxALL</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">Use touchpad to pan</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_MousewheelPANOpt</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"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Enable touchpad-friendly controls (pan with scroll action, zoom with Ctrl+scroll).</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">4</property>
|
||||
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</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_AUTOPAN</property>
|
||||
<property name="label">&Pan while moving object</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_AutoPANOpt</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"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">When drawing a track or moving an item, pan when approaching the edge of the display.</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>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALL</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 6 2019)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -43,11 +43,6 @@ class PANEL_COMMON_SETTINGS_BASE : public wxPanel
|
|||
private:
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
wxID_AUTOPAN = 1000
|
||||
};
|
||||
|
||||
wxStaticText* m_staticTextautosave;
|
||||
wxSpinCtrl* m_SaveTime;
|
||||
wxStaticText* m_staticTextFileHistorySize;
|
||||
|
@ -67,9 +62,6 @@ class PANEL_COMMON_SETTINGS_BASE : public wxPanel
|
|||
wxSpinCtrlDouble* m_canvasScaleCtrl;
|
||||
wxCheckBox* m_canvasScaleAuto;
|
||||
wxCheckBox* m_checkBoxIconsInMenus;
|
||||
wxCheckBox* m_ZoomCenterOpt;
|
||||
wxCheckBox* m_MousewheelPANOpt;
|
||||
wxCheckBox* m_AutoPANOpt;
|
||||
wxCheckBox* m_PreferSelectToDrag;
|
||||
wxCheckBox* m_warpMouseOnMove;
|
||||
wxCheckBox* m_NonImmediateActions;
|
||||
|
|
|
@ -0,0 +1,247 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dialog_shim.h>
|
||||
#include <dialogs/panel_mouse_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <wx/defs.h>
|
||||
|
||||
using KIGFX::MOUSE_DRAG_ACTION;
|
||||
|
||||
|
||||
PANEL_MOUSE_SETTINGS::PANEL_MOUSE_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aParent ) :
|
||||
PANEL_MOUSE_SETTINGS_BASE( aParent ),
|
||||
m_dialog( aDialog )
|
||||
{
|
||||
m_checkAutoZoomSpeed->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED,
|
||||
[&]( wxCommandEvent& aEvt )
|
||||
{
|
||||
m_zoomSpeed->Enable( !m_checkAutoZoomSpeed->GetValue() );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
PANEL_MOUSE_SETTINGS::~PANEL_MOUSE_SETTINGS()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool PANEL_MOUSE_SETTINGS::TransferDataToWindow()
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
|
||||
m_checkZoomCenter->SetValue( cfg->m_Input.center_on_zoom );
|
||||
m_checkAutoPan->SetValue( cfg->m_Input.auto_pan );
|
||||
m_checkZoomAcceleration->SetValue( cfg->m_Input.zoom_acceleration );
|
||||
m_zoomSpeed->SetValue( cfg->m_Input.zoom_speed );
|
||||
m_checkAutoZoomSpeed->SetValue( cfg->m_Input.zoom_speed_auto );
|
||||
m_checkEnablePanH->SetValue( cfg->m_Input.horizontal_pan );
|
||||
m_autoPanSpeed->SetValue( cfg->m_Input.auto_pan_acceleration );
|
||||
|
||||
m_zoomSpeed->Enable( !cfg->m_Input.zoom_speed_auto );
|
||||
|
||||
auto set_mouse_buttons =
|
||||
[]( const MOUSE_DRAG_ACTION& aVal, wxChoice* aChoice )
|
||||
{
|
||||
switch( aVal )
|
||||
{
|
||||
case MOUSE_DRAG_ACTION::PAN:
|
||||
aChoice->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::ZOOM:
|
||||
aChoice->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::NONE:
|
||||
aChoice->SetSelection( 2 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::SELECT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_middle ), m_choiceMiddleButtonDrag );
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_right ), m_choiceRightButtonDrag );
|
||||
|
||||
m_currentScrollMod.zoom = cfg->m_Input.scroll_modifier_zoom;
|
||||
m_currentScrollMod.panh = cfg->m_Input.scroll_modifier_pan_h;
|
||||
m_currentScrollMod.panv = cfg->m_Input.scroll_modifier_pan_v;
|
||||
|
||||
updateScrollModButtons();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PANEL_MOUSE_SETTINGS::TransferDataFromWindow()
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
|
||||
m_currentScrollMod = getScrollModSet();
|
||||
|
||||
if( !isScrollModSetValid( m_currentScrollMod ) )
|
||||
return false;
|
||||
|
||||
int drag_middle = static_cast<int>( MOUSE_DRAG_ACTION::NONE );
|
||||
int drag_right = static_cast<int>( MOUSE_DRAG_ACTION::NONE );
|
||||
|
||||
switch( m_choiceMiddleButtonDrag->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
drag_middle = static_cast<int>( MOUSE_DRAG_ACTION::PAN );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
drag_middle = static_cast<int>( MOUSE_DRAG_ACTION::ZOOM );
|
||||
break;
|
||||
|
||||
default:
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
switch( m_choiceRightButtonDrag->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
drag_right = static_cast<int>( MOUSE_DRAG_ACTION::PAN );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
drag_right = static_cast<int>( MOUSE_DRAG_ACTION::ZOOM );
|
||||
break;
|
||||
|
||||
default:
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
cfg->m_Input.center_on_zoom = m_checkZoomCenter->GetValue();
|
||||
cfg->m_Input.auto_pan = m_checkAutoPan->GetValue();
|
||||
cfg->m_Input.auto_pan_acceleration = m_autoPanSpeed->GetValue();
|
||||
cfg->m_Input.zoom_acceleration = m_checkZoomAcceleration->GetValue();
|
||||
cfg->m_Input.zoom_speed = m_zoomSpeed->GetValue();
|
||||
cfg->m_Input.zoom_speed_auto = m_checkAutoZoomSpeed->GetValue();
|
||||
cfg->m_Input.horizontal_pan = m_checkEnablePanH->GetValue();
|
||||
|
||||
cfg->m_Input.scroll_modifier_zoom = m_currentScrollMod.zoom;
|
||||
cfg->m_Input.scroll_modifier_pan_h = m_currentScrollMod.panh;
|
||||
cfg->m_Input.scroll_modifier_pan_v = m_currentScrollMod.panv;
|
||||
|
||||
cfg->m_Input.drag_middle = drag_middle;
|
||||
cfg->m_Input.drag_right = drag_right;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PANEL_MOUSE_SETTINGS::OnScrollRadioButton( wxCommandEvent& event )
|
||||
{
|
||||
wxRadioButton* btn = dynamic_cast<wxRadioButton*>( event.GetEventObject() );
|
||||
|
||||
if( !btn )
|
||||
return;
|
||||
|
||||
SCROLL_MOD_SET newSet = getScrollModSet();
|
||||
|
||||
if( isScrollModSetValid( newSet ) )
|
||||
m_currentScrollMod = newSet;
|
||||
else
|
||||
updateScrollModButtons();
|
||||
}
|
||||
|
||||
|
||||
SCROLL_MOD_SET PANEL_MOUSE_SETTINGS::getScrollModSet()
|
||||
{
|
||||
SCROLL_MOD_SET ret = {};
|
||||
|
||||
if( m_rbZoomShift->GetValue() )
|
||||
ret.zoom = WXK_SHIFT;
|
||||
else if( m_rbZoomCtrl->GetValue() )
|
||||
ret.zoom = WXK_CONTROL;
|
||||
else if( m_rbZoomAlt->GetValue() )
|
||||
ret.zoom = WXK_ALT;
|
||||
|
||||
if( m_rbPanHShift->GetValue() )
|
||||
ret.panh = WXK_SHIFT;
|
||||
else if( m_rbPanHCtrl->GetValue() )
|
||||
ret.panh = WXK_CONTROL;
|
||||
else if( m_rbPanHAlt->GetValue() )
|
||||
ret.panh = WXK_ALT;
|
||||
|
||||
if( m_rbPanVShift->GetValue() )
|
||||
ret.panv = WXK_SHIFT;
|
||||
else if( m_rbPanVCtrl->GetValue() )
|
||||
ret.panv = WXK_CONTROL;
|
||||
else if( m_rbPanVAlt->GetValue() )
|
||||
ret.panv = WXK_ALT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool PANEL_MOUSE_SETTINGS::isScrollModSetValid( const SCROLL_MOD_SET& aSet )
|
||||
{
|
||||
return ( aSet.zoom != aSet.panh && aSet.panh != aSet.panv && aSet.panv != aSet.zoom );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_MOUSE_SETTINGS::updateScrollModButtons()
|
||||
{
|
||||
auto set_wheel_buttons =
|
||||
[]( int aModifier, wxRadioButton* aNoneBtn, wxRadioButton* aCtrlBtn,
|
||||
wxRadioButton* aShiftBtn, wxRadioButton* aAltBtn )
|
||||
{
|
||||
switch( aModifier )
|
||||
{
|
||||
case 0:
|
||||
aNoneBtn->SetValue( true );
|
||||
break;
|
||||
|
||||
case WXK_CONTROL:
|
||||
aCtrlBtn->SetValue( true );
|
||||
break;
|
||||
|
||||
case WXK_SHIFT:
|
||||
aShiftBtn->SetValue( true );
|
||||
break;
|
||||
|
||||
case WXK_ALT:
|
||||
aAltBtn->SetValue( true );
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
set_wheel_buttons(
|
||||
m_currentScrollMod.zoom, m_rbZoomNone, m_rbZoomCtrl, m_rbZoomShift, m_rbZoomAlt );
|
||||
|
||||
set_wheel_buttons(
|
||||
m_currentScrollMod.panh, m_rbPanHNone, m_rbPanHCtrl, m_rbPanHShift, m_rbPanHAlt );
|
||||
|
||||
set_wheel_buttons(
|
||||
m_currentScrollMod.panv, m_rbPanVNone, m_rbPanVCtrl, m_rbPanVShift, m_rbPanVAlt );
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KICAD_PANEL_MOUSE_SETTINGS_H
|
||||
#define KICAD_PANEL_MOUSE_SETTINGS_H
|
||||
|
||||
#include <dialogs/panel_mouse_settings_base.h>
|
||||
|
||||
|
||||
class DIALOG_SHIM;
|
||||
|
||||
|
||||
struct SCROLL_MOD_SET
|
||||
{
|
||||
int zoom;
|
||||
int panh;
|
||||
int panv;
|
||||
};
|
||||
|
||||
|
||||
class PANEL_MOUSE_SETTINGS : public PANEL_MOUSE_SETTINGS_BASE
|
||||
{
|
||||
public:
|
||||
PANEL_MOUSE_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aParent );
|
||||
|
||||
~PANEL_MOUSE_SETTINGS();
|
||||
|
||||
protected:
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
void OnScrollRadioButton( wxCommandEvent& event ) override;
|
||||
|
||||
DIALOG_SHIM* m_dialog;
|
||||
|
||||
private:
|
||||
SCROLL_MOD_SET getScrollModSet();
|
||||
|
||||
void updateScrollModButtons();
|
||||
|
||||
bool isScrollModSetValid( const SCROLL_MOD_SET& aSet );
|
||||
|
||||
SCROLL_MOD_SET m_currentScrollMod;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,232 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "panel_mouse_settings_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
|
||||
{
|
||||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticBoxSizer* sbSizer1;
|
||||
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pan and Zoom") ), wxVERTICAL );
|
||||
|
||||
wxGridBagSizer* gbSizer1;
|
||||
gbSizer1 = new wxGridBagSizer( 0, 0 );
|
||||
gbSizer1->SetFlexibleDirection( wxBOTH );
|
||||
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_checkZoomCenter = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Center and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkZoomCenter->SetToolTip( _("Center the cursor on screen when zooming.") );
|
||||
|
||||
gbSizer1->Add( m_checkZoomCenter, wxGBPosition( 0, 0 ), wxGBSpan( 1, 3 ), wxALL, 5 );
|
||||
|
||||
m_checkAutoPan = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Automatically pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkAutoPan->SetToolTip( _("When drawing a track or moving an item, pan when approaching the edge of the display.") );
|
||||
|
||||
gbSizer1->Add( m_checkAutoPan, wxGBPosition( 0, 3 ), wxGBSpan( 1, 3 ), wxALL, 5 );
|
||||
|
||||
m_checkZoomAcceleration = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Use zoom acceleration"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkZoomAcceleration->SetToolTip( _("Zoom faster when scrolling quickly") );
|
||||
|
||||
gbSizer1->Add( m_checkZoomAcceleration, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxALL, 5 );
|
||||
|
||||
m_staticText1 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Zoom speed:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
gbSizer1->Add( m_staticText1, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 10 );
|
||||
|
||||
m_zoomSpeed = new wxSlider( sbSizer1->GetStaticBox(), wxID_ANY, 5, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
|
||||
m_zoomSpeed->Enable( false );
|
||||
m_zoomSpeed->SetToolTip( _("How far to zoom in for each rotation of the mouse wheel") );
|
||||
|
||||
gbSizer1->Add( m_zoomSpeed, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
|
||||
|
||||
m_staticText22 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Auto pan speed:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText22->Wrap( -1 );
|
||||
gbSizer1->Add( m_staticText22, wxGBPosition( 2, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_autoPanSpeed = new wxSlider( sbSizer1->GetStaticBox(), wxID_ANY, 5, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
|
||||
m_autoPanSpeed->SetToolTip( _("How fast to pan when moving an object off the edge of the screen") );
|
||||
|
||||
gbSizer1->Add( m_autoPanSpeed, wxGBPosition( 2, 4 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
|
||||
|
||||
m_checkAutoZoomSpeed = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Automatic"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkAutoZoomSpeed->SetValue(true);
|
||||
m_checkAutoZoomSpeed->SetToolTip( _("Pick the zoom speed automatically") );
|
||||
|
||||
gbSizer1->Add( m_checkAutoZoomSpeed, wxGBPosition( 3, 0 ), wxGBSpan( 1, 6 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
||||
sbSizer1->Add( gbSizer1, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( sbSizer1, 0, wxALL|wxEXPAND, 10 );
|
||||
|
||||
wxStaticBoxSizer* sbSizer2;
|
||||
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Mouse Buttons") ), wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer1;
|
||||
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 5 );
|
||||
fgSizer1->AddGrowableRow( 0 );
|
||||
fgSizer1->SetFlexibleDirection( wxHORIZONTAL );
|
||||
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_staticText3 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Middle button drag:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText3->Wrap( -1 );
|
||||
fgSizer1->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
wxString m_choiceMiddleButtonDragChoices[] = { _("Pan"), _("Zoom"), _("None") };
|
||||
int m_choiceMiddleButtonDragNChoices = sizeof( m_choiceMiddleButtonDragChoices ) / sizeof( wxString );
|
||||
m_choiceMiddleButtonDrag = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceMiddleButtonDragNChoices, m_choiceMiddleButtonDragChoices, 0 );
|
||||
m_choiceMiddleButtonDrag->SetSelection( 0 );
|
||||
fgSizer1->Add( m_choiceMiddleButtonDrag, 0, wxALL, 5 );
|
||||
|
||||
m_staticText31 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Right button drag:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText31->Wrap( -1 );
|
||||
fgSizer1->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
wxString m_choiceRightButtonDragChoices[] = { _("Pan"), _("Zoom"), _("None") };
|
||||
int m_choiceRightButtonDragNChoices = sizeof( m_choiceRightButtonDragChoices ) / sizeof( wxString );
|
||||
m_choiceRightButtonDrag = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceRightButtonDragNChoices, m_choiceRightButtonDragChoices, 0 );
|
||||
m_choiceRightButtonDrag->SetSelection( 0 );
|
||||
fgSizer1->Add( m_choiceRightButtonDrag, 0, wxALL, 5 );
|
||||
|
||||
|
||||
sbSizer2->Add( fgSizer1, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( sbSizer2, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxStaticBoxSizer* sbSizer3;
|
||||
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Mouse Wheel and Touchpad Scrolling") ), wxVERTICAL );
|
||||
|
||||
m_staticText21 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Behavior of vertical touchpad or scroll wheel:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText21->Wrap( -1 );
|
||||
sbSizer3->Add( m_staticText21, 0, wxALL, 5 );
|
||||
|
||||
wxFlexGridSizer* fgSizer2;
|
||||
fgSizer2 = new wxFlexGridSizer( 0, 5, 0, 5 );
|
||||
fgSizer2->SetFlexibleDirection( wxHORIZONTAL );
|
||||
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_staticText19 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("While pressing:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText19->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText19, 0, wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
m_staticText17 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText17->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText17, 0, wxALL, 5 );
|
||||
|
||||
m_lblCtrl = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Ctrl"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_lblCtrl->Wrap( -1 );
|
||||
fgSizer2->Add( m_lblCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_staticText8 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Shift"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText8->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_lblAlt = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Alt"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_lblAlt->Wrap( -1 );
|
||||
fgSizer2->Add( m_lblAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_staticText10 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Zoom:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText10->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText10, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
m_rbZoomNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
fgSizer2->Add( m_rbZoomNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbZoomCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbZoomCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbZoomShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbZoomShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbZoomAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbZoomAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_staticText11 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan up and down:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText11->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
m_rbPanVNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
fgSizer2->Add( m_rbPanVNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanVCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanVCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanVShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanVShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanVAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanVAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_staticText20 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan left and right:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText20->Wrap( -1 );
|
||||
fgSizer2->Add( m_staticText20, 0, wxALIGN_RIGHT|wxALL, 5 );
|
||||
|
||||
m_rbPanHNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
fgSizer2->Add( m_rbPanHNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanHCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanHCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanHShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanHShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
m_rbPanHAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_rbPanHAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
|
||||
|
||||
|
||||
sbSizer3->Add( fgSizer2, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_checkEnablePanH = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan left/right with horizontal touchpad or scroll wheel movement"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkEnablePanH->SetToolTip( _("Pan the canvas left and right when scrolling left to right on the touchpad") );
|
||||
|
||||
sbSizer3->Add( m_checkEnablePanH, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( sbSizer3, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bSizer1 );
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
m_rbZoomNone->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomCtrl->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomShift->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomAlt->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVNone->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVCtrl->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVShift->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVAlt->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHNone->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHCtrl->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHShift->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHAlt->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
}
|
||||
|
||||
PANEL_MOUSE_SETTINGS_BASE::~PANEL_MOUSE_SETTINGS_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_rbZoomNone->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomCtrl->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomShift->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbZoomAlt->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVNone->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVCtrl->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVShift->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanVAlt->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHNone->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHCtrl->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHShift->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
m_rbPanHAlt->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,83 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/slider.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/panel.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PANEL_MOUSE_SETTINGS_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PANEL_MOUSE_SETTINGS_BASE : public wxPanel
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxCheckBox* m_checkZoomCenter;
|
||||
wxCheckBox* m_checkAutoPan;
|
||||
wxCheckBox* m_checkZoomAcceleration;
|
||||
wxStaticText* m_staticText1;
|
||||
wxSlider* m_zoomSpeed;
|
||||
wxStaticText* m_staticText22;
|
||||
wxSlider* m_autoPanSpeed;
|
||||
wxCheckBox* m_checkAutoZoomSpeed;
|
||||
wxStaticText* m_staticText3;
|
||||
wxChoice* m_choiceMiddleButtonDrag;
|
||||
wxStaticText* m_staticText31;
|
||||
wxChoice* m_choiceRightButtonDrag;
|
||||
wxStaticText* m_staticText21;
|
||||
wxStaticText* m_staticText19;
|
||||
wxStaticText* m_staticText17;
|
||||
wxStaticText* m_lblCtrl;
|
||||
wxStaticText* m_staticText8;
|
||||
wxStaticText* m_lblAlt;
|
||||
wxStaticText* m_staticText10;
|
||||
wxRadioButton* m_rbZoomNone;
|
||||
wxRadioButton* m_rbZoomCtrl;
|
||||
wxRadioButton* m_rbZoomShift;
|
||||
wxRadioButton* m_rbZoomAlt;
|
||||
wxStaticText* m_staticText11;
|
||||
wxRadioButton* m_rbPanVNone;
|
||||
wxRadioButton* m_rbPanVCtrl;
|
||||
wxRadioButton* m_rbPanVShift;
|
||||
wxRadioButton* m_rbPanVAlt;
|
||||
wxStaticText* m_staticText20;
|
||||
wxRadioButton* m_rbPanHNone;
|
||||
wxRadioButton* m_rbPanHCtrl;
|
||||
wxRadioButton* m_rbPanHShift;
|
||||
wxRadioButton* m_rbPanHAlt;
|
||||
wxCheckBox* m_checkEnablePanH;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnScrollRadioButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 584,550 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
~PANEL_MOUSE_SETTINGS_BASE();
|
||||
|
||||
};
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
#include <bitmaps.h>
|
||||
#include <dialog_shim.h>
|
||||
#include <dialogs/panel_common_settings.h>
|
||||
#include <dialogs/panel_mouse_settings.h>
|
||||
#include <filehistory.h>
|
||||
#include <id.h>
|
||||
#include <kiface_i.h>
|
||||
|
@ -664,6 +665,8 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
|
|||
|
||||
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
|
||||
|
||||
book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Trackpad" ) );
|
||||
|
||||
PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
|
||||
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
|
||||
|
||||
|
|
|
@ -219,9 +219,7 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
|
|||
|
||||
SetAutoSaveInterval( settings->m_System.autosave_interval );
|
||||
|
||||
viewControls->EnableMousewheelPan( settings->m_Input.mousewheel_pan );
|
||||
viewControls->EnableCursorWarping( settings->m_Input.center_on_zoom );
|
||||
viewControls->EnableAutoPan( settings->m_Input.auto_pan );
|
||||
viewControls->LoadSettings();
|
||||
|
||||
m_galDisplayOptions.ReadCommonConfig( *settings, this );
|
||||
}
|
||||
|
|
|
@ -20,15 +20,19 @@
|
|||
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/parameters.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/zoom_controller.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
using KIGFX::MOUSE_DRAG_ACTION;
|
||||
|
||||
|
||||
extern const char* traceSettings;
|
||||
|
||||
|
||||
///! Update the schema version whenever a migration is required
|
||||
const int commonSchemaVersion = 0;
|
||||
const int commonSchemaVersion = 1;
|
||||
|
||||
COMMON_SETTINGS::COMMON_SETTINGS() :
|
||||
JSON_SETTINGS( "kicad_common", SETTINGS_LOC::USER, commonSchemaVersion ),
|
||||
|
@ -58,21 +62,64 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
|
|||
|
||||
m_params.emplace_back( new PARAM<bool>( "input.auto_pan", &m_Input.auto_pan, false ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<int>( "input.auto_pan_acceleration", &m_Input.auto_pan_acceleration, 5 ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( "input.center_on_zoom", &m_Input.center_on_zoom, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "input.immediate_actions",
|
||||
&m_Input.immediate_actions, true ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( "input.mousewheel_pan", &m_Input.mousewheel_pan, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "input.prefer_select_to_drag",
|
||||
&m_Input.prefer_select_to_drag, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "input.warp_mouse_on_move",
|
||||
&m_Input.warp_mouse_on_move, true ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( "input.horizontal_pan", &m_Input.horizontal_pan, false ) );
|
||||
|
||||
#if defined(__WXMAC__) || defined(__WXGTK3__)
|
||||
bool default_zoom_acceleration = false;
|
||||
#else
|
||||
bool default_zoom_acceleration = true;
|
||||
#endif
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>(
|
||||
"input.zoom_acceleration", &m_Input.zoom_acceleration, default_zoom_acceleration ) );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
int default_zoom_speed = 5;
|
||||
#else
|
||||
int default_zoom_speed = 1;
|
||||
#endif
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<int>( "input.zoom_speed", &m_Input.zoom_speed, default_zoom_speed ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( "input.zoom_speed_auto", &m_Input.zoom_speed_auto, true ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<int>( "input.scroll_modifier_zoom", &m_Input.scroll_modifier_zoom, 0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>(
|
||||
"input.scroll_modifier_pan_h", &m_Input.scroll_modifier_pan_h, WXK_CONTROL ) );
|
||||
|
||||
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<int>( "input.mouse_middle", &m_Input.drag_middle,
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::PAN ),
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::SELECT ),
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::NONE ) ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "input.mouse_right", &m_Input.drag_right,
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::PAN ),
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::SELECT ),
|
||||
static_cast<int>( MOUSE_DRAG_ACTION::NONE ) ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "graphics.opengl_antialiasing_mode",
|
||||
&m_Graphics.opengl_aa_mode, 0, 0, 4 ) );
|
||||
|
||||
|
@ -102,6 +149,68 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
|
|||
}
|
||||
|
||||
|
||||
bool COMMON_SETTINGS::Migrate()
|
||||
{
|
||||
bool ret = true;
|
||||
int filever = at( PointerFromString( "meta.version" ) ).get<int>();
|
||||
|
||||
if( filever == 0 )
|
||||
{
|
||||
ret &= migrateSchema0to1();
|
||||
|
||||
if( ret )
|
||||
{
|
||||
( *this )[PointerFromString( "meta.version" )] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool COMMON_SETTINGS::migrateSchema0to1()
|
||||
{
|
||||
/**
|
||||
* Schema version 0 to 1:
|
||||
*
|
||||
* mousewheel_pan is replaced by explicit settings for scroll wheel behavior
|
||||
*/
|
||||
|
||||
nlohmann::json::json_pointer mwp_pointer( "/input/mousewheel_pan"_json_pointer );
|
||||
|
||||
bool mwp = false;
|
||||
|
||||
try
|
||||
{
|
||||
mwp = at( mwp_pointer );
|
||||
at( nlohmann::json::json_pointer( "/input"_json_pointer ) ).erase( "mousewheel_pan" );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
wxLogTrace( traceSettings, "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" );
|
||||
}
|
||||
|
||||
if( mwp )
|
||||
{
|
||||
( *this )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true;
|
||||
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_SHIFT;
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0;
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = WXK_CONTROL;
|
||||
}
|
||||
else
|
||||
{
|
||||
( *this )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false;
|
||||
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_CONTROL;
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = WXK_SHIFT;
|
||||
( *this )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||
{
|
||||
bool ret = true;
|
||||
|
|
|
@ -57,23 +57,29 @@ void VIEW_CONTROLS::Reset()
|
|||
|
||||
void VC_SETTINGS::Reset()
|
||||
{
|
||||
m_showCursor = false;
|
||||
m_forceCursorPosition = false;
|
||||
m_cursorCaptured = false;
|
||||
m_snappingEnabled = true;
|
||||
m_grabMouse = false;
|
||||
m_autoPanEnabled = false;
|
||||
m_autoPanSettingEnabled = false;
|
||||
m_autoPanMargin = 0.02f;
|
||||
m_autoPanSpeed = 0.15f;
|
||||
m_autoPanAcceleration = 1.5f;
|
||||
m_warpCursor = false;
|
||||
m_enableMousewheelPan = false;
|
||||
m_panWithRightButton = false;
|
||||
m_panWithLeftButton = false;
|
||||
m_showCursor = false;
|
||||
m_forceCursorPosition = false;
|
||||
m_cursorCaptured = false;
|
||||
m_snappingEnabled = true;
|
||||
m_grabMouse = false;
|
||||
m_autoPanEnabled = false;
|
||||
m_autoPanSettingEnabled = false;
|
||||
m_autoPanMargin = 0.02f;
|
||||
m_autoPanSpeed = 0.15f;
|
||||
m_autoPanAcceleration = 5.0f;
|
||||
m_warpCursor = false;
|
||||
m_horizontalPan = false;
|
||||
m_zoomAcceleration = false;
|
||||
m_zoomSpeed = 5;
|
||||
m_zoomSpeedAuto = true;
|
||||
m_scrollModifierZoom = 0;
|
||||
m_scrollModifierPanH = WXK_CONTROL;
|
||||
m_scrollModifierPanV = WXK_SHIFT;
|
||||
m_dragMiddle = MOUSE_DRAG_ACTION::PAN;
|
||||
m_dragRight = MOUSE_DRAG_ACTION::PAN;
|
||||
m_lastKeyboardCursorPositionValid = false;
|
||||
m_lastKeyboardCursorPosition = { 0.0, 0.0 };
|
||||
m_lastKeyboardCursorCommand = ACTIONS::CURSOR_NONE;
|
||||
m_lastKeyboardCursorPosition = { 0.0, 0.0 };
|
||||
m_lastKeyboardCursorCommand = ACTIONS::CURSOR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +92,5 @@ void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
|
|||
SetAutoPan( aSettings.m_autoPanEnabled );
|
||||
SetAutoPanMargin( aSettings.m_autoPanMargin );
|
||||
SetAutoPanSpeed( aSettings.m_autoPanSpeed );
|
||||
SetAutoPanAcceleration( aSettings.m_autoPanAcceleration );
|
||||
ForceCursorPosition( aSettings.m_forceCursorPosition, aSettings.m_forcedPosition );
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <view/zoom_controller.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
|
||||
|
@ -68,13 +69,7 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
|
|||
m_cursorPos( 0, 0 ),
|
||||
m_updateCursor( true )
|
||||
{
|
||||
bool enableMousewheelPan = Pgm().GetCommonSettings()->m_Input.mousewheel_pan;
|
||||
bool enableZoomNoCenter = !Pgm().GetCommonSettings()->m_Input.center_on_zoom;
|
||||
bool enableAutoPan = Pgm().GetCommonSettings()->m_Input.auto_pan;
|
||||
|
||||
m_settings.m_enableMousewheelPan = enableMousewheelPan;
|
||||
m_settings.m_warpCursor = !enableZoomNoCenter;
|
||||
m_settings.m_autoPanSettingEnabled = enableAutoPan;
|
||||
LoadSettings();
|
||||
|
||||
m_parentPanel->Connect( wxEVT_MOTION,
|
||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
||||
|
@ -118,8 +113,6 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
|
|||
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEDOWN,
|
||||
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
|
||||
|
||||
m_zoomController = GetZoomControllerForPlatform();
|
||||
|
||||
m_cursorWarped = false;
|
||||
|
||||
m_panTimer.SetOwner( this );
|
||||
|
@ -136,6 +129,47 @@ WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS()
|
|||
}
|
||||
|
||||
|
||||
void WX_VIEW_CONTROLS::LoadSettings()
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
|
||||
m_settings.m_warpCursor = cfg->m_Input.center_on_zoom;
|
||||
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_dragMiddle = static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_middle );
|
||||
m_settings.m_dragRight = static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_right );
|
||||
|
||||
m_zoomController.reset();
|
||||
|
||||
if( cfg->m_Input.zoom_speed_auto )
|
||||
{
|
||||
// TODO(JE) this ignores the acceleration option
|
||||
m_zoomController = GetZoomControllerForPlatform();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cfg->m_Input.zoom_acceleration )
|
||||
{
|
||||
m_zoomController =
|
||||
std::make_unique<ACCELERATING_ZOOM_CONTROLLER>( cfg->m_Input.zoom_speed );
|
||||
}
|
||||
else
|
||||
{
|
||||
double scale = CONSTANT_ZOOM_CONTROLLER::MANUAL_SCALE_FACTOR * cfg->m_Input.zoom_speed;
|
||||
|
||||
m_zoomController = std::make_unique<CONSTANT_ZOOM_CONTROLLER>( scale );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
||||
{
|
||||
bool isAutoPanning = false;
|
||||
|
@ -154,6 +188,17 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
|||
m_view->SetCenter( m_lookStartPoint + delta );
|
||||
aEvent.StopPropagation();
|
||||
}
|
||||
else if( m_state == DRAG_ZOOMING )
|
||||
{
|
||||
VECTOR2D d = m_dragStartPoint - mousePos;
|
||||
|
||||
double scale = 1 + ( d.y * m_settings.m_zoomSpeed * 0.001 );
|
||||
|
||||
wxLogTrace( traceZoomScroll, wxString::Format( "dy: %f scale: %f", d.y, scale ) );
|
||||
|
||||
m_view->SetScale( m_initialZoomScale * scale, m_view->ToWorld( m_dragStartPoint ) );
|
||||
aEvent.StopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
if( m_updateCursor ) // do not update the cursor position if it was explicitly set
|
||||
|
@ -180,17 +225,34 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
|||
const double wheelPanSpeed = 0.001;
|
||||
const int axis = aEvent.GetWheelAxis();
|
||||
|
||||
// mousewheelpan disabled:
|
||||
// wheel + ctrl -> horizontal scrolling;
|
||||
// wheel + shift -> vertical scrolling;
|
||||
// wheel -> zooming;
|
||||
// mousewheelpan enabled:
|
||||
// wheel -> pan;
|
||||
// wheel + ctrl -> zooming;
|
||||
// wheel + shift -> horizontal scrolling.
|
||||
if( axis == wxMOUSE_WHEEL_HORIZONTAL && !m_settings.m_horizontalPan )
|
||||
return;
|
||||
|
||||
if( ( !m_settings.m_enableMousewheelPan && ( aEvent.ControlDown() || aEvent.ShiftDown() ) ) ||
|
||||
( m_settings.m_enableMousewheelPan && !aEvent.ControlDown() ) )
|
||||
// Pick the modifier, if any. Shift beats control beats alt, we don't support more than one.
|
||||
int modifiers =
|
||||
aEvent.ShiftDown() ? WXK_SHIFT :
|
||||
( aEvent.ControlDown() ? WXK_CONTROL : ( aEvent.AltDown() ? WXK_ALT : 0 ) );
|
||||
|
||||
// Restrict zoom handling to the vertical axis, otherwise horizontal
|
||||
// scrolling events (e.g. touchpads and some mice) end up interpreted
|
||||
// as vertical scroll events and confuse the user.
|
||||
if( axis == wxMOUSE_WHEEL_VERTICAL && modifiers == m_settings.m_scrollModifierZoom )
|
||||
{
|
||||
const int rotation = aEvent.GetWheelRotation();
|
||||
const double zoomScale = m_zoomController->GetScaleForRotation( rotation );
|
||||
|
||||
if( IsCursorWarpingEnabled() )
|
||||
{
|
||||
CenterOnCursor();
|
||||
m_view->SetScale( m_view->GetScale() * zoomScale );
|
||||
}
|
||||
else
|
||||
{
|
||||
const VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
||||
m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Scrolling
|
||||
VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
|
||||
|
@ -198,48 +260,16 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
|||
double scrollX = 0.0;
|
||||
double scrollY = 0.0;
|
||||
|
||||
if( m_settings.m_enableMousewheelPan )
|
||||
{
|
||||
if ( axis == wxMOUSE_WHEEL_HORIZONTAL || aEvent.ShiftDown() )
|
||||
scrollX = scrollVec.x;
|
||||
else
|
||||
scrollY = -scrollVec.y;
|
||||
}
|
||||
if( axis == wxMOUSE_WHEEL_HORIZONTAL || modifiers == m_settings.m_scrollModifierPanH )
|
||||
scrollX = scrollVec.x;
|
||||
else
|
||||
{
|
||||
if( aEvent.ControlDown() )
|
||||
scrollX = -scrollVec.x;
|
||||
else
|
||||
scrollY = -scrollVec.y;
|
||||
}
|
||||
scrollY = -scrollVec.y;
|
||||
|
||||
VECTOR2D delta( scrollX, scrollY );
|
||||
|
||||
m_view->SetCenter( m_view->GetCenter() + delta );
|
||||
refreshMouse();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restrict zoom handling to the vertical axis, otherwise horizontal
|
||||
// scrolling events (e.g. touchpads and some mice) end up interpreted
|
||||
// as vertical scroll events and confuse the user.
|
||||
if( axis == wxMOUSE_WHEEL_VERTICAL )
|
||||
{
|
||||
const int rotation = aEvent.GetWheelRotation();
|
||||
const double zoomScale = m_zoomController->GetScaleForRotation( rotation );
|
||||
|
||||
if( IsCursorWarpingEnabled() )
|
||||
{
|
||||
CenterOnCursor();
|
||||
m_view->SetScale( m_view->GetScale() * zoomScale );
|
||||
}
|
||||
else
|
||||
{
|
||||
const VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
||||
m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do not skip this event, otherwise wxWidgets will fire
|
||||
// 3 wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN (normal wxWidgets behavior)
|
||||
|
@ -266,20 +296,27 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
|||
{
|
||||
case IDLE:
|
||||
case AUTO_PANNING:
|
||||
if( aEvent.MiddleDown() ||
|
||||
( aEvent.LeftDown() && m_settings.m_panWithLeftButton ) ||
|
||||
( aEvent.RightDown() && m_settings.m_panWithRightButton ) )
|
||||
if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::PAN ) ||
|
||||
( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::PAN ) )
|
||||
{
|
||||
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
||||
m_lookStartPoint = m_view->GetCenter();
|
||||
m_state = DRAG_PANNING;
|
||||
}
|
||||
else if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::ZOOM ) ||
|
||||
( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::ZOOM ) )
|
||||
{
|
||||
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
||||
m_initialZoomScale = m_view->GetScale();
|
||||
m_state = DRAG_ZOOMING;
|
||||
}
|
||||
|
||||
if( aEvent.LeftUp() )
|
||||
m_state = IDLE; // Stop autopanning when user release left mouse button
|
||||
|
||||
break;
|
||||
|
||||
case DRAG_ZOOMING:
|
||||
case DRAG_PANNING:
|
||||
if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
|
||||
m_state = IDLE;
|
||||
|
@ -354,8 +391,10 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|||
|
||||
VECTOR2D dir( m_panDirection );
|
||||
|
||||
float accel = 0.5f + ( m_settings.m_autoPanAcceleration / 5.0f );
|
||||
|
||||
if( dir.EuclideanNorm() > borderSize / 2 )
|
||||
dir = dir.Resize( pow( borderSize, m_settings.m_autoPanAcceleration ) );
|
||||
dir = dir.Resize( pow( borderSize, accel ) );
|
||||
else if( dir.EuclideanNorm() > borderSize )
|
||||
dir = dir.Resize( borderSize );
|
||||
|
||||
|
@ -368,6 +407,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|||
|
||||
case IDLE: // Just remove unnecessary warnings
|
||||
case DRAG_PANNING:
|
||||
case DRAG_ZOOMING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -633,6 +673,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
|||
break;
|
||||
|
||||
case DRAG_PANNING:
|
||||
case DRAG_ZOOMING:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,9 @@ public:
|
|||
|
||||
|
||||
ACCELERATING_ZOOM_CONTROLLER::ACCELERATING_ZOOM_CONTROLLER(
|
||||
const TIMEOUT& aAccTimeout, TIMESTAMP_PROVIDER* aTimestampProv )
|
||||
: m_accTimeout( aAccTimeout )
|
||||
double aScale, const TIMEOUT& aAccTimeout, TIMESTAMP_PROVIDER* aTimestampProv ) :
|
||||
m_accTimeout( aAccTimeout ),
|
||||
m_scale( aScale )
|
||||
{
|
||||
if( aTimestampProv )
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ ACCELERATING_ZOOM_CONTROLLER::ACCELERATING_ZOOM_CONTROLLER(
|
|||
double ACCELERATING_ZOOM_CONTROLLER::GetScaleForRotation( int aRotation )
|
||||
{
|
||||
// The minimal step value when changing the current zoom level
|
||||
const double zoomLevelScale = 1.2;
|
||||
const double minStep = 1.05;
|
||||
|
||||
const auto timestamp = m_timestampProv->GetTimestamp();
|
||||
auto timeDiff = std::chrono::duration_cast<TIMEOUT>( timestamp - m_lastTimestamp );
|
||||
|
@ -87,17 +88,17 @@ double ACCELERATING_ZOOM_CONTROLLER::GetScaleForRotation( int aRotation )
|
|||
// Set scaling speed depending on scroll wheel event interval
|
||||
if( timeDiff < m_accTimeout )
|
||||
{
|
||||
zoomScale = 2.05 - timeDiff / m_accTimeout;
|
||||
zoomScale = ( 2.05 * m_scale / 5.0 ) - timeDiff / m_accTimeout;
|
||||
|
||||
// be sure zoomScale value is significant
|
||||
zoomScale = std::max( zoomScale, zoomLevelScale );
|
||||
zoomScale = std::max( zoomScale, minStep );
|
||||
|
||||
if( aRotation < 0 )
|
||||
zoomScale = 1.0 / zoomScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
zoomScale = ( aRotation > 0 ) ? zoomLevelScale : 1 / zoomLevelScale;
|
||||
zoomScale = ( aRotation > 0 ) ? minStep : 1 / minStep;
|
||||
}
|
||||
|
||||
wxLogTrace( traceZoomScroll, wxString::Format( " Zoom factor: %f", zoomScale ) );
|
||||
|
|
|
@ -56,21 +56,6 @@ int CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( m_frame->ToolStackIsEmpty() )
|
||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||
|
||||
// This is kind of hacky: activate RMB drag on any event.
|
||||
// There doesn't seem to be any other good way to tell when another tool
|
||||
// is canceled and control returns to the selection tool, except by the
|
||||
// fact that the selection tool starts to get events again.
|
||||
if( m_frame->IsCurrentTool( ACTIONS::selectionTool ) )
|
||||
{
|
||||
getViewControls()->SetAdditionalPanButtons( false, true );
|
||||
}
|
||||
|
||||
// Disable RMB pan for other tools; they can re-enable if desired
|
||||
if( evt->IsActivate() )
|
||||
{
|
||||
getViewControls()->SetAdditionalPanButtons( false, false );
|
||||
}
|
||||
|
||||
// single click? Select single object
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "spice_simulator.h"
|
||||
#include "spice_reporter.h"
|
||||
#include <menus_helpers.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <eeschema_settings.h>
|
||||
|
@ -484,7 +485,7 @@ SIM_PANEL_BASE* SIM_PLOT_FRAME::NewPlotPanel( SIM_TYPE aSimType )
|
|||
panel = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, this, wxID_ANY );
|
||||
|
||||
panel->GetPlotWin()->EnableMouseWheelPan(
|
||||
m_schematicFrame->GetCanvas()->GetViewControls()->IsMousewheelPanEnabled() );
|
||||
Pgm().GetCommonSettings()->m_Input.scroll_modifier_zoom != 0 );
|
||||
|
||||
plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
|
||||
}
|
||||
|
|
|
@ -194,21 +194,6 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
else if( evt->Modifier( MD_CTRL ) )
|
||||
m_exclusive_or = true;
|
||||
|
||||
// This is kind of hacky: activate RMB drag on any event.
|
||||
// There doesn't seem to be any other good way to tell when another tool
|
||||
// is canceled and control returns to the selection tool, except by the
|
||||
// fact that the selection tool starts to get events again.
|
||||
if( m_frame->IsCurrentTool( ACTIONS::selectionTool ) )
|
||||
{
|
||||
getViewControls()->SetAdditionalPanButtons( false, true );
|
||||
}
|
||||
|
||||
// Disable RMB pan for other tools; they can re-enable if desired
|
||||
if( evt->IsActivate() )
|
||||
{
|
||||
getViewControls()->SetAdditionalPanButtons( false, false );
|
||||
}
|
||||
|
||||
// single click? Select single object
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
|
@ -585,7 +570,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
|
||||
controls.ShowCursor( true );
|
||||
controls.SetSnapping( true );
|
||||
controls.SetAdditionalPanButtons( false, true );
|
||||
|
||||
while( TOOL_EVENT* evt = Wait() )
|
||||
{
|
||||
|
|
|
@ -43,11 +43,23 @@ public:
|
|||
struct INPUT
|
||||
{
|
||||
bool auto_pan;
|
||||
int auto_pan_acceleration;
|
||||
bool center_on_zoom;
|
||||
bool immediate_actions;
|
||||
bool mousewheel_pan;
|
||||
bool prefer_select_to_drag;
|
||||
bool warp_mouse_on_move;
|
||||
bool horizontal_pan;
|
||||
|
||||
bool zoom_acceleration;
|
||||
int zoom_speed;
|
||||
bool zoom_speed_auto;
|
||||
|
||||
int scroll_modifier_zoom;
|
||||
int scroll_modifier_pan_h;
|
||||
int scroll_modifier_pan_v;
|
||||
|
||||
int drag_middle;
|
||||
int drag_right;
|
||||
};
|
||||
|
||||
struct GRAPHICS
|
||||
|
@ -73,6 +85,11 @@ public:
|
|||
|
||||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
|
||||
|
||||
bool Migrate() override;
|
||||
|
||||
private:
|
||||
bool migrateSchema0to1();
|
||||
|
||||
public:
|
||||
APPEARANCE m_Appearance;
|
||||
|
||||
|
|
|
@ -40,6 +40,17 @@ namespace KIGFX
|
|||
{
|
||||
class VIEW;
|
||||
|
||||
|
||||
///> Action to perform when the mouse is dragged
|
||||
enum class MOUSE_DRAG_ACTION
|
||||
{
|
||||
SELECT,
|
||||
ZOOM,
|
||||
PAN,
|
||||
NONE
|
||||
};
|
||||
|
||||
|
||||
///> Structure to keep VIEW_CONTROLS settings for easy store/restore operations
|
||||
struct VC_SETTINGS
|
||||
{
|
||||
|
@ -87,14 +98,32 @@ struct VC_SETTINGS
|
|||
///> If the cursor is allowed to be warped
|
||||
bool m_warpCursor;
|
||||
|
||||
///> Mousewheel (2-finger touchpad) panning
|
||||
bool m_enableMousewheelPan;
|
||||
///> Enable horizontal panning with the horizontal scroll/trackpad input
|
||||
bool m_horizontalPan;
|
||||
|
||||
///> Allow panning with the right button in addition to middle
|
||||
bool m_panWithRightButton;
|
||||
///> Enable the accelerating zoom controller
|
||||
bool m_zoomAcceleration;
|
||||
|
||||
///> Allow panning with the left button in addition to middle
|
||||
bool m_panWithLeftButton;
|
||||
///> Zoom speed for the non-accelerating zoom controller
|
||||
int m_zoomSpeed;
|
||||
|
||||
///> When true, ignore zoom_speed and pick a platform-specific default
|
||||
bool m_zoomSpeedAuto;
|
||||
|
||||
///> What modifier key to enable zoom with the (vertical) scroll wheel
|
||||
int m_scrollModifierZoom;
|
||||
|
||||
///> What modifier key to enable horizontal pan with the (vertical) scroll wheel
|
||||
int m_scrollModifierPanH;
|
||||
|
||||
///> What modifier key to enable vertical with the (vertical) scroll wheel
|
||||
int m_scrollModifierPanV;
|
||||
|
||||
///> What drag action to perform when the middle button is pressed
|
||||
MOUSE_DRAG_ACTION m_dragMiddle;
|
||||
|
||||
///> What drag action to perform when the right button is pressed
|
||||
MOUSE_DRAG_ACTION m_dragRight;
|
||||
|
||||
///> Is last cursor motion event coming from keyboard arrow cursor motion action
|
||||
bool m_lastKeyboardCursorPositionValid;
|
||||
|
@ -352,25 +381,6 @@ public:
|
|||
return m_settings.m_warpCursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function EnableMousewheelPan()
|
||||
* Enables or disables mousewheel panning.
|
||||
* @param aEnable is true if mouse-wheel panning is enabled.
|
||||
*/
|
||||
virtual void EnableMousewheelPan( bool aEnable )
|
||||
{
|
||||
m_settings.m_enableMousewheelPan = aEnable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function IsMousewheelPanEnabled()
|
||||
* @return the current setting for mousewheel panning
|
||||
*/
|
||||
virtual bool IsMousewheelPanEnabled() const
|
||||
{
|
||||
return m_settings.m_enableMousewheelPan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function CenterOnCursor()
|
||||
* Sets the viewport center to the current cursor position and warps the cursor to the
|
||||
|
@ -378,12 +388,6 @@ public:
|
|||
*/
|
||||
virtual void CenterOnCursor() const = 0;
|
||||
|
||||
void SetAdditionalPanButtons( bool aLeft = false, bool aRight = false )
|
||||
{
|
||||
m_settings.m_panWithLeftButton = aLeft;
|
||||
m_settings.m_panWithRightButton = aRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Reset()
|
||||
* Restores the default VIEW_CONTROLS settings.
|
||||
|
@ -399,6 +403,9 @@ public:
|
|||
///> Applies VIEW_CONTROLS settings from an object
|
||||
void ApplySettings( const VC_SETTINGS& aSettings );
|
||||
|
||||
///> Load new settings from program common settings
|
||||
virtual void LoadSettings() {}
|
||||
|
||||
protected:
|
||||
///> Pointer to controlled VIEW.
|
||||
VIEW* m_view;
|
||||
|
|
|
@ -103,6 +103,9 @@ public:
|
|||
|
||||
void ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) ) override;
|
||||
|
||||
///> Applies VIEW_CONTROLS settings from the program COMMON_SETTINGS
|
||||
void LoadSettings() override;
|
||||
|
||||
/// Event that forces mouse move event in the dispatcher (eg. used in autopanning, when mouse
|
||||
/// cursor does not move in screen coordinates, but does in world coordinates)
|
||||
static const wxEventType EVT_REFRESH_MOUSE;
|
||||
|
@ -114,6 +117,7 @@ private:
|
|||
IDLE = 1, /// Nothing is happening
|
||||
DRAG_PANNING, /// Panning with mouse button pressed
|
||||
AUTO_PANNING, /// Panning on approaching borders of the frame
|
||||
DRAG_ZOOMING, /// Zooming with mouse button pressed
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -162,6 +166,9 @@ private:
|
|||
/// Current scrollbar position
|
||||
VECTOR2I m_scrollPos;
|
||||
|
||||
/// The zoom scale when a drag zoom started
|
||||
double m_initialZoomScale;
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
/// Last event timestamp used to de-bounce mouse wheel
|
||||
long int m_lastTimestamp;
|
||||
|
|
|
@ -72,6 +72,9 @@ public:
|
|||
/// The default timeout, after which a another scroll will not be accelerated
|
||||
static constexpr TIMEOUT DEFAULT_TIMEOUT = std::chrono::milliseconds( 500 );
|
||||
|
||||
/// The default minimum step factor for accelerating controller
|
||||
static constexpr double DEFAULT_ACCELERATION_SCALE = 5.0;
|
||||
|
||||
/*
|
||||
* A class interface that provides timestamps for events
|
||||
*/
|
||||
|
@ -93,8 +96,9 @@ public:
|
|||
* be provided, which is the main steady_clock (this is probably what you
|
||||
* want for real usage)
|
||||
*/
|
||||
ACCELERATING_ZOOM_CONTROLLER( const TIMEOUT& aAccTimeout = DEFAULT_TIMEOUT,
|
||||
TIMESTAMP_PROVIDER* aTimestampProv = nullptr );
|
||||
ACCELERATING_ZOOM_CONTROLLER( double aScale = DEFAULT_ACCELERATION_SCALE,
|
||||
const TIMEOUT& aAccTimeout = DEFAULT_TIMEOUT,
|
||||
TIMESTAMP_PROVIDER* aTimestampProv = nullptr );
|
||||
|
||||
double GetScaleForRotation( int aRotation ) override;
|
||||
|
||||
|
@ -119,6 +123,9 @@ private:
|
|||
TIME_PT m_lastTimestamp;
|
||||
/// The timeout value
|
||||
TIMEOUT m_accTimeout;
|
||||
|
||||
/// A multiplier for the minimum zoom step size
|
||||
double m_scale;
|
||||
};
|
||||
|
||||
|
||||
|
@ -143,6 +150,9 @@ public:
|
|||
/// A suitable (magic) scale factor for Mac systems
|
||||
static constexpr double MAC_SCALE = 0.01;
|
||||
|
||||
/// Multipler for manual scale ssetting
|
||||
static constexpr double MANUAL_SCALE_FACTOR = 0.001;
|
||||
|
||||
private:
|
||||
/// The scale factor set by the constructor.
|
||||
double m_scale;
|
||||
|
|
|
@ -265,8 +265,8 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas()
|
|||
m_panelShowPadGal->SwitchBackend( m_parent->GetCanvas()->GetBackend() );
|
||||
m_panelShowPadGal->SetStealsFocus( false );
|
||||
|
||||
bool mousewheelPan = m_parent->GetCanvas()->GetViewControls()->IsMousewheelPanEnabled();
|
||||
m_panelShowPadGal->GetViewControls()->EnableMousewheelPan( mousewheelPan );
|
||||
m_panelShowPadGal->GetViewControls()->ApplySettings(
|
||||
m_parent->GetCanvas()->GetViewControls()->GetSettings() );
|
||||
|
||||
m_panelShowPadGal->Show();
|
||||
|
||||
|
|
|
@ -116,9 +116,9 @@ struct ACCEL_ZOOM_CASE
|
|||
|
||||
static const std::vector<ACCEL_ZOOM_CASE> accel_cases = {
|
||||
// Scrolls widely spaced, just go up and down by a constant factor
|
||||
{ 500, { 0, 1000, 2000, 3000 }, { 120, 120, -120 }, { 1.2, 1.2, 1 / 1.2 } },
|
||||
{ 500, { 0, 1000, 2000, 3000 }, { 120, 120, -120 }, { 1.05, 1.05, 1 / 1.05 } },
|
||||
// Close scrolls - acceleration on the latter
|
||||
{ 500, { 0, 1000, 1100 }, { 120, 120 }, { 1.2, 2.05 } },
|
||||
{ 500, { 0, 1000, 1100 }, { 120, 120 }, { 1.05, 2.05 } },
|
||||
};
|
||||
|
||||
|
||||
|
@ -134,6 +134,7 @@ BOOST_AUTO_TEST_CASE( AccelController )
|
|||
PREDEF_TIMESTAMPER timestamper( c.stamps );
|
||||
|
||||
ACCELERATING_ZOOM_CONTROLLER zoom_ctrl(
|
||||
ACCELERATING_ZOOM_CONTROLLER::DEFAULT_ACCELERATION_SCALE,
|
||||
std::chrono::milliseconds( c.timeout ), ×tamper );
|
||||
|
||||
for( unsigned i = 0; i < c.scrolls.size(); i++ )
|
||||
|
|
Loading…
Reference in New Issue