diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index ca73201483..d1157f39cf 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -126,9 +126,8 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow() commonSettings->m_Appearance.use_icons_in_menus = m_checkBoxIconsInMenus->GetValue(); - commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue(); - commonSettings->m_Input.prefer_select_to_drag = m_PreferSelectToDrag->GetValue(); - commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue(); + commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue(); + commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue(); commonSettings->m_Backup.enabled = m_cbBackupEnabled->GetValue(); commonSettings->m_Backup.backup_on_autosave = m_cbBackupAutosave->GetValue(); @@ -203,7 +202,6 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings ) m_checkBoxIconsInMenus->SetValue( aSettings.m_Appearance.use_icons_in_menus ); - m_PreferSelectToDrag->SetValue( aSettings.m_Input.prefer_select_to_drag ); m_warpMouseOnMove->SetValue( aSettings.m_Input.warp_mouse_on_move ); m_NonImmediateActions->SetValue( !aSettings.m_Input.immediate_actions ); diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp index 680c66bc40..e05e8df98a 100644 --- a/common/dialogs/panel_common_settings_base.cpp +++ b/common/dialogs/panel_common_settings_base.cpp @@ -201,9 +201,6 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind wxStaticBoxSizer* sbSizer4; sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Editing") ), wxVERTICAL ); - m_PreferSelectToDrag = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Prefer selection to dragging"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer4->Add( m_PreferSelectToDrag, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_warpMouseOnMove = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Warp mouse to origin of moved object"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer4->Add( m_warpMouseOnMove, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp index a9a41acad7..656a9e8d92 100644 --- a/common/dialogs/panel_common_settings_base.fbp +++ b/common/dialogs/panel_common_settings_base.fbp @@ -1916,70 +1916,6 @@ wxVERTICAL 1 none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Prefer selection to dragging - - 0 - - - 0 - - 1 - m_PreferSelectToDrag - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - 5 wxBOTTOM|wxRIGHT|wxLEFT diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h index 546afcaf79..4ee69a878f 100644 --- a/common/dialogs/panel_common_settings_base.h +++ b/common/dialogs/panel_common_settings_base.h @@ -67,7 +67,6 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL wxSpinCtrlDouble* m_canvasScaleCtrl; wxCheckBox* m_canvasScaleAuto; wxCheckBox* m_checkBoxIconsInMenus; - wxCheckBox* m_PreferSelectToDrag; wxCheckBox* m_warpMouseOnMove; wxCheckBox* m_NonImmediateActions; wxCheckBox* m_cbBackupEnabled; diff --git a/common/dialogs/panel_mouse_settings.cpp b/common/dialogs/panel_mouse_settings.cpp index 70712c10f1..400207fd71 100644 --- a/common/dialogs/panel_mouse_settings.cpp +++ b/common/dialogs/panel_mouse_settings.cpp @@ -81,23 +81,28 @@ bool PANEL_MOUSE_SETTINGS::TransferDataFromWindow() if( !isScrollModSetValid( m_currentScrollMod ) ) return false; - int drag_middle = static_cast( MOUSE_DRAG_ACTION::NONE ); - int drag_right = static_cast( MOUSE_DRAG_ACTION::NONE ); + switch( m_choiceLeftButtonDrag->GetSelection() ) + { + case 0: cfg->m_Input.drag_left = static_cast( MOUSE_DRAG_ACTION::SELECT ); break; + case 1: cfg->m_Input.drag_left = static_cast( MOUSE_DRAG_ACTION::DRAG_SELECTED ); break; + case 2: cfg->m_Input.drag_left = static_cast( MOUSE_DRAG_ACTION::DRAG_ANY ); break; + default: break; + } switch( m_choiceMiddleButtonDrag->GetSelection() ) { - case 0: drag_middle = static_cast( MOUSE_DRAG_ACTION::PAN ); break; - case 1: drag_middle = static_cast( MOUSE_DRAG_ACTION::ZOOM ); break; - case 2: break; - default: break; + case 0: cfg->m_Input.drag_middle = static_cast( MOUSE_DRAG_ACTION::PAN ); break; + case 1: cfg->m_Input.drag_middle = static_cast( MOUSE_DRAG_ACTION::ZOOM ); break; + case 2: cfg->m_Input.drag_middle = static_cast( MOUSE_DRAG_ACTION::NONE ); break; + default: break; } switch( m_choiceRightButtonDrag->GetSelection() ) { - case 0: drag_right = static_cast( MOUSE_DRAG_ACTION::PAN ); break; - case 1: drag_right = static_cast( MOUSE_DRAG_ACTION::ZOOM ); break; - case 2: break; - default: break; + case 0: cfg->m_Input.drag_right = static_cast( MOUSE_DRAG_ACTION::PAN ); break; + case 1: cfg->m_Input.drag_right = static_cast( MOUSE_DRAG_ACTION::ZOOM ); break; + case 2: cfg->m_Input.drag_right = static_cast( MOUSE_DRAG_ACTION::NONE ); break; + default: break; } cfg->m_Input.center_on_zoom = m_checkZoomCenter->GetValue(); @@ -112,9 +117,6 @@ 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.drag_middle = drag_middle; - cfg->m_Input.drag_right = drag_right; - return true; } @@ -141,6 +143,14 @@ void PANEL_MOUSE_SETTINGS::applySettingsToPanel( const COMMON_SETTINGS& aSetting m_zoomSpeed->Enable( !aSettings.m_Input.zoom_speed_auto ); + switch( static_cast( aSettings.m_Input.drag_left ) ) + { + case MOUSE_DRAG_ACTION::SELECT: m_choiceLeftButtonDrag->SetSelection( 0 ); break; + case MOUSE_DRAG_ACTION::DRAG_SELECTED: m_choiceLeftButtonDrag->SetSelection( 1 ); break; + case MOUSE_DRAG_ACTION::DRAG_ANY: m_choiceLeftButtonDrag->SetSelection( 2 ); break; + default: break; + } + auto set_mouse_buttons = []( const MOUSE_DRAG_ACTION& aVal, wxChoice* aChoice ) { diff --git a/common/dialogs/panel_mouse_settings_base.cpp b/common/dialogs/panel_mouse_settings_base.cpp index 079a43df7f..6807a33880 100644 --- a/common/dialogs/panel_mouse_settings_base.cpp +++ b/common/dialogs/panel_mouse_settings_base.cpp @@ -49,9 +49,9 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow 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") ); - m_zoomSpeed->SetMinSize( wxSize( 150,-1 ) ); + m_zoomSpeed->SetMinSize( wxSize( 120,-1 ) ); - m_zoomSizer->Add( m_zoomSpeed, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 0 ); + m_zoomSizer->Add( m_zoomSpeed, 1, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 0 ); m_checkAutoZoomSpeed = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Automatic"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkAutoZoomSpeed->SetValue(true); @@ -70,15 +70,17 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow 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") ); - m_autoPanSpeed->SetMinSize( wxSize( 150,-1 ) ); + m_autoPanSpeed->SetMinSize( wxSize( 120,-1 ) ); - m_panSizer->Add( m_autoPanSpeed, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 0 ); + m_panSizer->Add( m_autoPanSpeed, 1, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 0 ); gbSizer1->Add( m_panSizer, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxEXPAND|wxTOP, 5 ); + gbSizer1->AddGrowableCol( 0 ); gbSizer1->AddGrowableCol( 1 ); + gbSizer1->AddGrowableCol( 2 ); sbSizer1->Add( gbSizer1, 1, wxEXPAND|wxRIGHT, 10 ); @@ -86,33 +88,52 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow bSizer1->Add( sbSizer1, 0, wxALL|wxEXPAND, 10 ); wxStaticBoxSizer* sbSizer2; - sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Mouse Buttons") ), wxVERTICAL ); + sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Drag Gestures") ), wxVERTICAL ); wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 2, 5, 5 ); - fgSizer1->AddGrowableRow( 0 ); + fgSizer1 = new wxFlexGridSizer( 0, 3, 5, 5 ); + fgSizer1->AddGrowableCol( 2 ); fgSizer1->SetFlexibleDirection( wxHORIZONTAL ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + m_leftButtonDragLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Left button drag:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_leftButtonDragLabel->Wrap( -1 ); + fgSizer1->Add( m_leftButtonDragLabel, 0, wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_choiceLeftButtonDragChoices[] = { _("Draw selection rectangle"), _("Drag selected objects; otherwise draw selection rectangle"), _("Drag any object (selected or not)") }; + int m_choiceLeftButtonDragNChoices = sizeof( m_choiceLeftButtonDragChoices ) / sizeof( wxString ); + m_choiceLeftButtonDrag = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceLeftButtonDragNChoices, m_choiceLeftButtonDragChoices, 0 ); + m_choiceLeftButtonDrag->SetSelection( 0 ); + fgSizer1->Add( m_choiceLeftButtonDrag, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + 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|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 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, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( m_choiceMiddleButtonDrag, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 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|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 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, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_choiceRightButtonDrag, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); sbSizer2->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -121,99 +142,116 @@ PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindow bSizer1->Add( sbSizer2, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Mouse Wheel and Touchpad Scrolling") ), wxVERTICAL ); + sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scroll Gestures") ), wxVERTICAL ); - m_staticText21 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Behavior of vertical touchpad or scroll wheel movement:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText21 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Vertical touchpad or scroll wheel movement:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); - sbSizer3->Add( m_staticText21, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + sbSizer3->Add( m_staticText21, 0, wxRIGHT|wxLEFT, 5 ); wxFlexGridSizer* fgSizer2; - fgSizer2 = new wxFlexGridSizer( 0, 5, 0, 5 ); - fgSizer2->SetFlexibleDirection( wxHORIZONTAL ); + fgSizer2 = new wxFlexGridSizer( 0, 5, 5, 0 ); + fgSizer2->AddGrowableCol( 0 ); + fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_staticText19 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_staticText19->Wrap( -1 ); - fgSizer2->Add( m_staticText19, 0, wxALIGN_RIGHT|wxALL, 5 ); + fgSizer2->Add( m_staticText19, 0, wxALIGN_RIGHT|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_staticText17 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("No Modifiers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText17 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("--"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText17->Wrap( -1 ); - fgSizer2->Add( m_staticText17, 0, wxALL, 5 ); + fgSizer2->Add( m_staticText17, 0, wxTOP|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 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 ); + fgSizer2->Add( m_lblCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 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 ); + fgSizer2->Add( m_staticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 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 ); + fgSizer2->Add( m_lblAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL, 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 ); + fgSizer2->Add( m_staticText10, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT, 5 ); m_rbZoomNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - fgSizer2->Add( m_rbZoomNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbZoomNone, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_rbZoomCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbZoomCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbZoomCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_rbZoomShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbZoomShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbZoomShift, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_rbZoomAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbZoomAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbZoomAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_staticText11 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan up/down:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText11->Wrap( -1 ); - fgSizer2->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgSizer2->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT, 5 ); m_rbPanVNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - fgSizer2->Add( m_rbPanVNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanVNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_rbPanVCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanVCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanVCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_rbPanVShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanVShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanVShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_rbPanVAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanVAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanVAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_staticText20 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan left/right:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText20->Wrap( -1 ); - fgSizer2->Add( m_staticText20, 0, wxALIGN_RIGHT|wxALL, 5 ); + fgSizer2->Add( m_staticText20, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_rbPanHNone = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - fgSizer2->Add( m_rbPanHNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanHNone, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_rbPanHCtrl = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanHCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanHCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_rbPanHShift = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanHShift, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanHShift, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_rbPanHAlt = new wxRadioButton( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rbPanHAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + fgSizer2->Add( m_rbPanHAlt, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - sbSizer3->Add( fgSizer2, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 24 ); + fgSizer2->Add( 0, 12, 1, wxEXPAND, 5 ); + + + fgSizer2->Add( 42, 0, 1, wxEXPAND, 5 ); + + + fgSizer2->Add( 42, 0, 1, wxEXPAND, 5 ); + + + fgSizer2->Add( 42, 0, 1, wxEXPAND, 5 ); + + + fgSizer2->Add( 42, 0, 1, wxEXPAND, 5 ); + + + sbSizer3->Add( fgSizer2, 0, wxRIGHT|wxLEFT, 24 ); m_checkEnablePanH = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Pan left/right with horizontal 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, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + sbSizer3->Add( m_checkEnablePanH, 0, wxALL, 5 ); - bSizer1->Add( sbSizer3, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + bSizer1->Add( sbSizer3, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); this->SetSizer( bSizer1 ); this->Layout(); + bSizer1->Fit( this ); // Connect Events m_rbZoomNone->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_MOUSE_SETTINGS_BASE::OnScrollRadioButton ), NULL, this ); diff --git a/common/dialogs/panel_mouse_settings_base.fbp b/common/dialogs/panel_mouse_settings_base.fbp index c0a8c87e9a..d71fd8b8a9 100644 --- a/common/dialogs/panel_mouse_settings_base.fbp +++ b/common/dialogs/panel_mouse_settings_base.fbp @@ -43,7 +43,7 @@ PANEL_MOUSE_SETTINGS_BASE - 584,550 + -1,-1 RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare @@ -73,7 +73,7 @@ wxBOTH - 1 + 0,1,2 0 @@ -371,7 +371,7 @@ 0 wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 + 1 1 1 @@ -407,7 +407,7 @@ 1 0 - 150,-1 + 120,-1 1 m_zoomSpeed 1 @@ -575,7 +575,7 @@ 0 wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 + 1 1 1 @@ -611,7 +611,7 @@ 1 0 - 150,-1 + 120,-1 1 m_autoPanSpeed 1 @@ -649,7 +649,7 @@ 0 wxID_ANY - Mouse Buttons + Drag Gestures sbSizer2 wxVERTICAL @@ -660,10 +660,10 @@ wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 1 - 2 + 3 wxHORIZONTAL - - 0 + 2 + 5 fgSizer1 @@ -671,9 +671,144 @@ none 0 5 + + 5 + wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Left button drag: + 0 + + 0 + + + 0 + + 1 + m_leftButtonDragLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Draw selection rectangle" "Drag selected objects; otherwise draw selection rectangle" "Drag any object (selected or not)" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceLeftButtonDrag + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -734,7 +869,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND 0 1 @@ -796,9 +931,19 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -859,7 +1004,7 @@ 5 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND 0 1 @@ -921,6 +1066,16 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + @@ -928,10 +1083,10 @@ 10 wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 + 0 wxID_ANY - Mouse Wheel and Touchpad Scrolling + Scroll Gestures -1,-1 sbSizer3 wxVERTICAL @@ -939,7 +1094,7 @@ none 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 1 @@ -969,7 +1124,7 @@ 0 0 wxID_ANY - Behavior of vertical touchpad or scroll wheel movement: + Vertical touchpad or scroll wheel movement: 0 0 @@ -1000,23 +1155,23 @@ 24 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 5 - wxHORIZONTAL - + wxBOTH + 0 - 5 + 0 fgSizer2 wxFLEX_GROWMODE_SPECIFIED none 0 - 0 + 5 5 - wxALIGN_RIGHT|wxALL + wxALIGN_RIGHT|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -1077,7 +1232,7 @@ 5 - wxALL + wxTOP|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL 0 1 @@ -1107,14 +1262,14 @@ 0 0 wxID_ANY - No Modifiers + -- 0 0 0 - + -1,-1 1 m_staticText17 1 @@ -1138,7 +1293,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL 0 1 @@ -1199,7 +1354,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL 0 1 @@ -1260,7 +1415,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxALIGN_CENTER_VERTICAL 0 1 @@ -1321,7 +1476,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT 0 1 @@ -1382,7 +1537,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL 0 1 @@ -1418,7 +1573,7 @@ 0 - + -1,-1 1 m_rbZoomNone 1 @@ -1447,7 +1602,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 0 1 @@ -1512,7 +1667,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -1577,7 +1732,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -1642,7 +1797,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT 0 1 @@ -1703,7 +1858,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 0 1 @@ -1768,7 +1923,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 0 1 @@ -1833,7 +1988,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -1898,7 +2053,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -1963,7 +2118,7 @@ 5 - wxALIGN_RIGHT|wxALL + wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -2024,7 +2179,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 0 1 @@ -2089,7 +2244,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 0 1 @@ -2154,7 +2309,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -2219,7 +2374,7 @@ 5 - wxALIGN_CENTER_HORIZONTAL|wxALL + wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -2282,11 +2437,61 @@ OnScrollRadioButton + + 5 + wxEXPAND + 1 + + 12 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 42 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 42 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 42 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 42 + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxALL 0 1 diff --git a/common/dialogs/panel_mouse_settings_base.h b/common/dialogs/panel_mouse_settings_base.h index b642899e2c..633fc1a487 100644 --- a/common/dialogs/panel_mouse_settings_base.h +++ b/common/dialogs/panel_mouse_settings_base.h @@ -46,6 +46,8 @@ class PANEL_MOUSE_SETTINGS_BASE : public RESETTABLE_PANEL wxBoxSizer* m_panSizer; wxStaticText* m_staticText22; wxSlider* m_autoPanSpeed; + wxStaticText* m_leftButtonDragLabel; + wxChoice* m_choiceLeftButtonDrag; wxStaticText* m_staticText3; wxChoice* m_choiceMiddleButtonDrag; wxStaticText* m_staticText31; @@ -79,7 +81,7 @@ class PANEL_MOUSE_SETTINGS_BASE : public RESETTABLE_PANEL 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( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_MOUSE_SETTINGS_BASE(); }; diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index 241c1afdf4..ec7163253e 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -40,7 +40,7 @@ const std::set envVarBlacklist = ///! Update the schema version whenever a migration is required -const int commonSchemaVersion = 1; +const int commonSchemaVersion = 2; COMMON_SETTINGS::COMMON_SETTINGS() : JSON_SETTINGS( "kicad_common", SETTINGS_LOC::USER, commonSchemaVersion ), @@ -106,9 +106,6 @@ COMMON_SETTINGS::COMMON_SETTINGS() : m_params.emplace_back( new PARAM( "input.immediate_actions", &m_Input.immediate_actions, true ) ); - m_params.emplace_back( new PARAM( "input.prefer_select_to_drag", - &m_Input.prefer_select_to_drag, false ) ); - m_params.emplace_back( new PARAM( "input.warp_mouse_on_move", &m_Input.warp_mouse_on_move, true ) ); @@ -145,6 +142,11 @@ COMMON_SETTINGS::COMMON_SETTINGS() : m_params.emplace_back( new PARAM( "input.scroll_modifier_pan_v", &m_Input.scroll_modifier_pan_v, WXK_SHIFT ) ); + m_params.emplace_back( new PARAM( "input.mouse_left", &m_Input.drag_left, + static_cast( MOUSE_DRAG_ACTION::DRAG_SELECTED ), + static_cast( MOUSE_DRAG_ACTION::DRAG_ANY ), + static_cast( MOUSE_DRAG_ACTION::SELECT ) ) ); + m_params.emplace_back( new PARAM( "input.mouse_middle", &m_Input.drag_middle, static_cast( MOUSE_DRAG_ACTION::PAN ), static_cast( MOUSE_DRAG_ACTION::SELECT ), @@ -189,6 +191,7 @@ COMMON_SETTINGS::COMMON_SETTINGS() : &m_Session.remember_open_files, false ) ); registerMigration( 0, 1, std::bind( &COMMON_SETTINGS::migrateSchema0to1, this ) ); + registerMigration( 1, 2, std::bind( &COMMON_SETTINGS::migrateSchema1to2, this ) ); } @@ -235,6 +238,31 @@ bool COMMON_SETTINGS::migrateSchema0to1() } +bool COMMON_SETTINGS::migrateSchema1to2() +{ + nlohmann::json::json_pointer v1_pointer( "/input/prefer_select_to_drag"_json_pointer ); + + bool prefer_selection = false; + + try + { + prefer_selection = at( v1_pointer ); + at( nlohmann::json::json_pointer( "/input"_json_pointer ) ).erase( "prefer_select_to_drag" ); + } + catch( ... ) + { + wxLogTrace( traceSettings, "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ); + } + + if( prefer_selection ) + ( *this )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::SELECT; + else + ( *this )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::DRAG_ANY; + + return true; +} + + bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) { bool ret = true; diff --git a/common/tool/tools_holder.cpp b/common/tool/tools_holder.cpp index 2658ab5791..414dca36c2 100644 --- a/common/tool/tools_holder.cpp +++ b/common/tool/tools_holder.cpp @@ -35,7 +35,7 @@ TOOLS_HOLDER::TOOLS_HOLDER() : m_actions( nullptr ), m_toolDispatcher( nullptr ), m_immediateActions( true ), - m_dragSelects( true ), + m_dragAction( KIGFX::MOUSE_DRAG_ACTION::SELECT ), m_moveWarpsCursor( true ) { } @@ -122,7 +122,7 @@ void TOOLS_HOLDER::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsCh COMMON_SETTINGS* settings = Pgm().GetCommonSettings(); m_moveWarpsCursor = settings->m_Input.warp_mouse_on_move; - m_dragSelects = settings->m_Input.prefer_select_to_drag; + m_dragAction = static_cast( settings->m_Input.drag_left ); m_immediateActions = settings->m_Input.immediate_actions; } diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 3217588f3c..9a5fa871b8 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -145,6 +145,7 @@ void WX_VIEW_CONTROLS::LoadSettings() m_settings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom; m_settings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h; m_settings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v; + m_settings.m_dragLeft = static_cast( cfg->m_Input.drag_left ); m_settings.m_dragMiddle = static_cast( cfg->m_Input.drag_middle ); m_settings.m_dragRight = static_cast( cfg->m_Input.drag_right ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index c316937cc1..dd5d314d7e 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -325,6 +325,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_exclusive_or = true; bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; + KIGFX::MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction(); // Is the user requesting that the selection list include all possible // items without removing less likely selection candidates @@ -431,7 +432,11 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( SCH_EDIT_FRAME* schframe = dynamic_cast( m_frame ) ) schframe->FocusOnItem( nullptr ); - if( modifier_enabled || ( m_selection.Empty() && m_frame->GetDragSelects() ) ) + if( modifier_enabled || drag_action == KIGFX::MOUSE_DRAG_ACTION::SELECT ) + { + selectMultiple(); + } + else if( m_selection.Empty() && drag_action != KIGFX::MOUSE_DRAG_ACTION::DRAG_ANY ) { selectMultiple(); } @@ -576,8 +581,10 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { m_nonModifiedCursor = KICURSOR::HAND; } - else if( !m_selection.Empty() && !m_frame->GetDragSelects() && evt->HasPosition() - && selectionContains( evt->Position() ) ) //move/drag option prediction + else if( !m_selection.Empty() + && drag_action == KIGFX::MOUSE_DRAG_ACTION::DRAG_SELECTED + && evt->HasPosition() + && selectionContains( evt->Position() ) ) //move/drag option prediction { m_nonModifiedCursor = KICURSOR::MOVING; } diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h index d2b0133116..60cab5d796 100644 --- a/include/settings/common_settings.h +++ b/include/settings/common_settings.h @@ -58,7 +58,6 @@ public: int auto_pan_acceleration; bool center_on_zoom; bool immediate_actions; - bool prefer_select_to_drag; bool warp_mouse_on_move; bool horizontal_pan; @@ -70,6 +69,7 @@ public: int scroll_modifier_pan_h; int scroll_modifier_pan_v; + int drag_left; int drag_middle; int drag_right; }; @@ -105,6 +105,7 @@ public: private: bool migrateSchema0to1(); + bool migrateSchema1to2(); public: APPEARANCE m_Appearance; diff --git a/include/tool/tools_holder.h b/include/tool/tools_holder.h index eb3080abee..f8c258e4a6 100644 --- a/include/tool/tools_holder.h +++ b/include/tool/tools_holder.h @@ -25,6 +25,7 @@ #define TOOL_HOLDER_H #include +#include #include #include #include @@ -127,10 +128,10 @@ public: bool GetDoImmediateActions() const { return m_immediateActions; } /** - * Indicate that a drag should draw a selection rectangle, even when started over an - * item. + * Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) + * objects. */ - bool GetDragSelects() const { return m_dragSelects; } + KIGFX::MOUSE_DRAG_ACTION GetDragAction() const { return m_dragAction; } /** * Indicate that a move operation should warp the mouse pointer to the origin of the @@ -170,7 +171,8 @@ protected: // the first invocation of a hotkey will just // select the relevant tool rather than executing // the tool's action. - bool m_dragSelects; // Prefer selection to dragging. + KIGFX::MOUSE_DRAG_ACTION m_dragAction; // DRAG_ANY/DRAG_SELECTED/SELECT. + bool m_moveWarpsCursor; // cursor is warped to move/drag origin }; diff --git a/include/view/view_controls.h b/include/view/view_controls.h index f3cdb10e96..b0f33fd211 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -44,6 +44,8 @@ class VIEW; ///< Action to perform when the mouse is dragged enum class MOUSE_DRAG_ACTION { + DRAG_ANY, + DRAG_SELECTED, SELECT, ZOOM, PAN, @@ -119,10 +121,8 @@ struct VC_SETTINGS ///< 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_dragLeft; 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. diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index b5019207f1..c49089bae3 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -202,9 +202,14 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) { - if( !modifier_enabled && !m_selection.Empty() && !m_frame->GetDragSelects() - && evt->HasPosition() && selectionContains( evt->Position() ) ) + if( !modifier_enabled + && !m_selection.Empty() + && m_frame->GetDragAction() == KIGFX::MOUSE_DRAG_ACTION::DRAG_SELECTED + && evt->HasPosition() + && selectionContains( evt->Position() ) ) + { m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); + } else { if( m_additive ) diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 83365cb110..1b05180ade 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -208,8 +208,8 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) { - bool dragAlwaysSelects = getEditFrame()->GetDragSelects(); - TRACK_DRAG_ACTION dragAction = getEditFrame()->Settings().m_TrackDragAction; + KIGFX::MOUSE_DRAG_ACTION dragAction = m_frame->GetDragAction(); + TRACK_DRAG_ACTION trackDragAction = m_frame->Settings().m_TrackDragAction; // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL: // Due to the fact ALT key modifier cannot be useed freely on Winows and Linux, @@ -340,7 +340,11 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->FocusOnItem( nullptr ); m_toolMgr->ProcessEvent( EVENTS::InhibitSelectionEditing ); - if( modifier_enabled || dragAlwaysSelects ) + if( modifier_enabled || dragAction == KIGFX::MOUSE_DRAG_ACTION::SELECT ) + { + selectMultiple(); + } + else if( m_selection.Empty() && dragAction != KIGFX::MOUSE_DRAG_ACTION::DRAG_ANY ) { selectMultiple(); } @@ -384,9 +388,9 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Yes -> run the move tool and wait till it finishes TRACK* track = dynamic_cast( m_selection.GetItem( 0 ) ); - if( track && dragAction == TRACK_DRAG_ACTION::DRAG ) + if( track && trackDragAction == TRACK_DRAG_ACTION::DRAG ) m_toolMgr->RunAction( PCB_ACTIONS::drag45Degree, true ); - else if( track && dragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE ) + else if( track && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE ) m_toolMgr->RunAction( PCB_ACTIONS::dragFreeAngle, true ); else m_toolMgr->RunAction( PCB_ACTIONS::move, true ); @@ -419,8 +423,11 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) { //move cursor prediction - if( !modifier_enabled && !dragAlwaysSelects && !m_selection.Empty() - && evt->HasPosition() && selectionContains( evt->Position() ) ) + if( !modifier_enabled + && dragAction == KIGFX::MOUSE_DRAG_ACTION::DRAG_SELECTED + && !m_selection.Empty() + && evt->HasPosition() + && selectionContains( evt->Position() ) ) { m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING ); }