From 98616da017705110514ab933b4f0b84243751c61 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 28 Feb 2018 15:47:26 +0100 Subject: [PATCH] Added an option to enforce dragging gesture to always draw selection box Partial solution to a problem described in lp:#1636214 --- pcbnew/dialogs/dialog_general_options.cpp | 3 + ...ialog_general_options_BoardEditor_base.cpp | 11 ++- ...ialog_general_options_BoardEditor_base.fbp | 88 +++++++++++++++++++ .../dialog_general_options_BoardEditor_base.h | 9 +- pcbnew/pcb_general_settings.cpp | 1 + pcbnew/pcb_general_settings.h | 2 + pcbnew/tools/selection_tool.cpp | 6 +- 7 files changed, 112 insertions(+), 8 deletions(-) diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 13a6ee805c..09412ec29b 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -42,6 +42,7 @@ #include #include #include +#include DIALOG_GENERALOPTIONS::DIALOG_GENERALOPTIONS( PCB_EDIT_FRAME* parent ) : @@ -89,6 +90,7 @@ void DIALOG_GENERALOPTIONS::init() m_MagneticPadOptCtrl->SetSelection( GetParent()->Settings().m_magneticPads ); m_MagneticTrackOptCtrl->SetSelection( GetParent()->Settings().m_magneticTracks ); m_UseEditKeyForWidth->SetValue( GetParent()->Settings().m_editActionChangesTrackWidth ); + m_dragSelects->SetValue( GetParent()->Settings().m_dragSelects ); m_Show_Page_Limits->SetValue( GetParent()->ShowPageLimits() ); @@ -174,6 +176,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) GetParent()->Settings().m_magneticPads = (MAGNETIC_PAD_OPTION_VALUES) m_MagneticPadOptCtrl->GetSelection(); GetParent()->Settings().m_magneticTracks = (MAGNETIC_PAD_OPTION_VALUES) m_MagneticTrackOptCtrl->GetSelection(); GetParent()->Settings().m_editActionChangesTrackWidth = m_UseEditKeyForWidth->GetValue(); + GetParent()->Settings().m_dragSelects = m_dragSelects->GetValue(); GetParent()->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp index 1022a0ee00..6f2541481b 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp @@ -1,10 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 17 2016) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/stepped_slider.h" + #include "dialog_general_options_BoardEditor_base.h" /////////////////////////////////////////////////////////////////////////// @@ -147,6 +149,11 @@ DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE::DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( bOptionsSizer->Add( m_UseEditKeyForWidth, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + m_dragSelects = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Prefer selection to dragging"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dragSelects->SetToolTip( _("When enabled and nothing is selected, drag gesture will draw a selection box, even if there are items under the cursor that could be immediately dragged.") ); + + bOptionsSizer->Add( m_dragSelects, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + wxFlexGridSizer* fgSizer12; fgSizer12 = new wxFlexGridSizer( 0, 2, 0, 0 ); fgSizer12->AddGrowableCol( 1 ); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index 6dee0e7758..e946fafbb5 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -1648,6 +1648,94 @@ + + 5 + wxBOTTOM|wxLEFT|wxRIGHT + 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_dragSelects + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + When enabled and nothing is selected, drag gesture will draw a selection box, even if there are items under the cursor that could be immediately dragged. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h index 9cb869c289..27702263de 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 17 2016) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_GENERAL_OPTIONS_BOARDEDITOR_BASE_H__ @@ -11,7 +11,9 @@ #include #include #include -#include "widgets/stepped_slider.h" +class DIALOG_SHIM; +class STEPPED_SLIDER; + #include "dialog_shim.h" #include #include @@ -69,6 +71,7 @@ class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE : public DIALOG_SHIM wxCheckBox* m_Show_Page_Limits; wxCheckBox* m_Segments_45_Only_Ctrl; wxCheckBox* m_UseEditKeyForWidth; + wxCheckBox* m_dragSelects; wxStaticText* m_staticTextRotationAngle; wxTextCtrl* m_RotationAngle; wxRadioBox* m_MagneticPadOptCtrl; diff --git a/pcbnew/pcb_general_settings.cpp b/pcbnew/pcb_general_settings.cpp index 16511e93c9..59dd3d12c7 100644 --- a/pcbnew/pcb_general_settings.cpp +++ b/pcbnew/pcb_general_settings.cpp @@ -37,6 +37,7 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) Add( "MagneticPads", reinterpret_cast( &m_magneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL ); Add( "MagneticTracks", reinterpret_cast( &m_magneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL ); Add( "EditActionChangesTrackWidth", &m_editActionChangesTrackWidth, false ); + Add( "DragSelects", &m_dragSelects, true ); } } diff --git a/pcbnew/pcb_general_settings.h b/pcbnew/pcb_general_settings.h index 7226b3a020..d1f13d99db 100644 --- a/pcbnew/pcb_general_settings.h +++ b/pcbnew/pcb_general_settings.h @@ -62,6 +62,8 @@ public: bool m_legacyUseTwoSegmentTracks = true; bool m_editActionChangesTrackWidth = false; + bool m_dragSelects = true; // True: Drag gesture always draws a selection box, + // False: Drag will preselect an item and move it MAGNETIC_PAD_OPTION_VALUES m_magneticPads = CAPTURE_CURSOR_IN_TRACK_TOOL; MAGNETIC_PAD_OPTION_VALUES m_magneticTracks = CAPTURE_CURSOR_IN_TRACK_TOOL; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 06374bb210..aae688207f 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -313,10 +313,10 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else if( m_selection.Empty() ) { // There is nothing selected, so try to select something - if( !selectCursor() ) + if( getEditFrame()->Settings().m_dragSelects || !selectCursor() ) { - // If nothings has been selected or user wants to select more - // draw the selection box + // If nothings has been selected, user wants to select more or selection + // box is preferred to dragging - draw selection box selectMultiple(); } else