Added an option to enforce dragging gesture to always draw selection box

Partial solution to a problem described in lp:#1636214
This commit is contained in:
Maciej Suminski 2018-02-28 15:47:26 +01:00
parent ce1bd4c6b7
commit 98616da017
7 changed files with 112 additions and 8 deletions

View File

@ -42,6 +42,7 @@
#include <collectors.h>
#include <pgm_base.h>
#include <dialog_general_options.h>
#include <widgets/stepped_slider.h>
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() );

View File

@ -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 );

View File

@ -1648,6 +1648,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="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">Prefer selection to dragging</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_dragSelects</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 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.</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>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "widgets/stepped_slider.h"
class DIALOG_SHIM;
class STEPPED_SLIDER;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
@ -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;

View File

@ -37,6 +37,7 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType )
Add( "MagneticPads", reinterpret_cast<int*>( &m_magneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
Add( "MagneticTracks", reinterpret_cast<int*>( &m_magneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL );
Add( "EditActionChangesTrackWidth", &m_editActionChangesTrackWidth, false );
Add( "DragSelects", &m_dragSelects, true );
}
}

View File

@ -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;

View File

@ -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<PCB_BASE_FRAME>()->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