diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index 2596d82107..f2210603b2 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -31,9 +31,6 @@ #include #include -#include - - static constexpr int dpi_scaling_precision = 1; static constexpr double dpi_scaling_increment = 0.5; @@ -69,6 +66,14 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aP m_textEditorBtn->SetBitmap( KiBitmap( folder_xpm ) ); m_pdfViewerBtn->SetBitmap( KiBitmap( folder_xpm ) ); + + m_canvasScaleCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnCanvasScaleChange ), NULL, this ); +} + + +PANEL_COMMON_SETTINGS::~PANEL_COMMON_SETTINGS() +{ + m_canvasScaleCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnCanvasScaleChange ), NULL, this ); } @@ -127,6 +132,17 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow() commonSettings->Read( ENBL_AUTO_PAN_KEY, &option ); m_AutoPANOpt->SetValue( option ); + if( !commonSettings->Read( PREFER_SELECT_TO_DRAG_KEY, &option ) ) + { + // Legacy versions stored the property only for PCBNew, so see if we have it there + std::unique_ptr pcbSettings = GetNewConfig( wxT( "pcbnew" ) ); + pcbSettings->Read( "DragSelects", &option, true ); + } + m_PreferSelectToDrag->SetValue( option ); + + commonSettings->Read( IMMEDIATE_ACTIONS_KEY, &option ); + m_NonImmediateActions->SetValue( !option ); + m_textEditorPath->SetValue( Pgm().GetEditorName( false ) ); m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() ); m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() ); @@ -160,6 +176,8 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow() commonSettings->Write( ENBL_ZOOM_NO_CENTER_KEY, !m_ZoomCenterOpt->GetValue() ); commonSettings->Write( ENBL_MOUSEWHEEL_PAN_KEY, m_MousewheelPANOpt->GetValue() ); commonSettings->Write( ENBL_AUTO_PAN_KEY, m_AutoPANOpt->GetValue() ); + commonSettings->Write( PREFER_SELECT_TO_DRAG_KEY, m_PreferSelectToDrag->GetValue() ); + commonSettings->Write( IMMEDIATE_ACTIONS_KEY, !m_NonImmediateActions->GetValue() ); Pgm().SetEditorName( m_textEditorPath->GetValue() ); diff --git a/common/dialogs/panel_common_settings.h b/common/dialogs/panel_common_settings.h index 0a96f48ad0..2e6c902ddc 100644 --- a/common/dialogs/panel_common_settings.h +++ b/common/dialogs/panel_common_settings.h @@ -34,6 +34,7 @@ class PANEL_COMMON_SETTINGS : public PANEL_COMMON_SETTINGS_BASE { public: PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aParent ); + ~PANEL_COMMON_SETTINGS() override; protected: bool TransferDataFromWindow() override; @@ -48,7 +49,7 @@ protected: /** * Event fired when the canvas scale field is modified */ - void OnCanvasScaleChange( wxCommandEvent& aEvent ) override; + void OnCanvasScaleChange( wxCommandEvent& aEvent ); /** * Event fired when the canvas auto-scale option is changed diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp index 9731b83a41..874e81077c 100644 --- a/common/dialogs/panel_common_settings_base.cpp +++ b/common/dialogs/panel_common_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 10 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,195 +9,214 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { wxBoxSizer* bPanelSizer; - bPanelSizer = new wxBoxSizer( wxVERTICAL ); - + bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bLeftSizer; bLeftSizer = new wxBoxSizer( wxVERTICAL ); - + wxGridBagSizer* gbSizer1; gbSizer1 = new wxGridBagSizer( 4, 4 ); gbSizer1->SetFlexibleDirection( wxBOTH ); gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); gbSizer1->SetEmptyCellSize( wxSize( -1,2 ) ); - + m_staticTextautosave = new wxStaticText( this, wxID_ANY, _("&Auto save:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextautosave->Wrap( -1 ); gbSizer1->Add( m_staticTextautosave, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + wxBoxSizer* bSizer6; bSizer6 = new wxBoxSizer( wxHORIZONTAL ); - + m_SaveTime = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10, 0 ); m_SaveTime->SetToolTip( _("Delay after the first change to create a backup file of the board on disk.\nIf set to 0, auto backup is disabled") ); - + bSizer6->Add( m_SaveTime, 0, wxALIGN_CENTER_VERTICAL, 5 ); - + wxStaticText* minutesLabel; minutesLabel = new wxStaticText( this, wxID_ANY, _("minutes"), wxDefaultPosition, wxDefaultSize, 0 ); minutesLabel->Wrap( -1 ); bSizer6->Add( minutesLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - + + gbSizer1->Add( bSizer6, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - + m_staticTextFileHistorySize = new wxStaticText( this, wxID_ANY, _("File history size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFileHistorySize->Wrap( -1 ); gbSizer1->Add( m_staticTextFileHistorySize, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + m_fileHistorySize = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 ); gbSizer1->Add( m_fileHistorySize, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + wxStaticText* antialiasingLabel; - antialiasingLabel = new wxStaticText( this, wxID_ANY, _("Graphics (Accelerated):"), wxDefaultPosition, wxDefaultSize, 0 ); + antialiasingLabel = new wxStaticText( this, wxID_ANY, _("Accelerated graphics:"), wxDefaultPosition, wxDefaultSize, 0 ); antialiasingLabel->Wrap( -1 ); gbSizer1->Add( antialiasingLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + wxString m_antialiasingChoices[] = { _("No Antialiasing"), _("Subpixel Antialiasing (High Quality)"), _("Subpixel Antialiasing (Ultra Quality)"), _("Supersampling (2x)"), _("Supersampling (4x)") }; int m_antialiasingNChoices = sizeof( m_antialiasingChoices ) / sizeof( wxString ); m_antialiasing = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_antialiasingNChoices, m_antialiasingChoices, 0 ); m_antialiasing->SetSelection( 0 ); gbSizer1->Add( m_antialiasing, wxGBPosition( 3, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - + wxStaticText* antialiasingLabel1; - antialiasingLabel1 = new wxStaticText( this, wxID_ANY, _("Graphics (Fallback):"), wxDefaultPosition, wxDefaultSize, 0 ); + antialiasingLabel1 = new wxStaticText( this, wxID_ANY, _("Fallback graphics:"), wxDefaultPosition, wxDefaultSize, 0 ); antialiasingLabel1->Wrap( -1 ); gbSizer1->Add( antialiasingLabel1, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + wxString m_antialiasingFallbackChoices[] = { _("No Antialiasing"), _("Fast Antialiasing"), _("Balanced Antialiasing"), _("High Quality Antialiasing") }; int m_antialiasingFallbackNChoices = sizeof( m_antialiasingFallbackChoices ) / sizeof( wxString ); m_antialiasingFallback = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_antialiasingFallbackNChoices, m_antialiasingFallbackChoices, 0 ); m_antialiasingFallback->SetSelection( 0 ); gbSizer1->Add( m_antialiasingFallback, wxGBPosition( 4, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - + + gbSizer1->AddGrowableCol( 1 ); - - bLeftSizer->Add( gbSizer1, 1, wxEXPAND|wxALL, 5 ); - + + bLeftSizer->Add( gbSizer1, 0, wxEXPAND|wxALL, 10 ); + wxStaticBoxSizer* sizerHelperApps; sizerHelperApps = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Helper Applications") ), wxVERTICAL ); - + wxGridBagSizer* gridHelperApps; gridHelperApps = new wxGridBagSizer( 3, 3 ); gridHelperApps->SetFlexibleDirection( wxBOTH ); gridHelperApps->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); gridHelperApps->SetEmptyCellSize( wxSize( -1,5 ) ); - + wxStaticText* textEditorLabel; textEditorLabel = new wxStaticText( sizerHelperApps->GetStaticBox(), wxID_ANY, _("Text editor:"), wxDefaultPosition, wxDefaultSize, 0 ); textEditorLabel->Wrap( -1 ); gridHelperApps->Add( textEditorLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 4 ); - + m_textEditorPath = new wxTextCtrl( sizerHelperApps->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textEditorPath->SetMinSize( wxSize( 360,-1 ) ); - + m_textEditorPath->SetMinSize( wxSize( 280,-1 ) ); + gridHelperApps->Add( m_textEditorPath, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_textEditorBtn = new wxBitmapButton( sizerHelperApps->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + + m_textEditorBtn = new wxBitmapButton( sizerHelperApps->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); m_textEditorBtn->SetMinSize( wxSize( 29,29 ) ); - + gridHelperApps->Add( m_textEditorBtn, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - + m_defaultPDFViewer = new wxRadioButton( sizerHelperApps->GetStaticBox(), wxID_ANY, _("System default PDF viewer"), wxDefaultPosition, wxDefaultSize, 0 ); gridHelperApps->Add( m_defaultPDFViewer, wxGBPosition( 2, 0 ), wxGBSpan( 1, 3 ), 0, 4 ); - + m_otherPDFViewer = new wxRadioButton( sizerHelperApps->GetStaticBox(), wxID_ANY, _("Other:"), wxDefaultPosition, wxDefaultSize, 0 ); gridHelperApps->Add( m_otherPDFViewer, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 4 ); - + m_PDFViewerPath = new wxTextCtrl( sizerHelperApps->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_PDFViewerPath->SetMinSize( wxSize( 360,-1 ) ); - + m_PDFViewerPath->SetMinSize( wxSize( 280,-1 ) ); + gridHelperApps->Add( m_PDFViewerPath, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_pdfViewerBtn = new wxBitmapButton( sizerHelperApps->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + + m_pdfViewerBtn = new wxBitmapButton( sizerHelperApps->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); m_pdfViewerBtn->SetMinSize( wxSize( 29,29 ) ); - + gridHelperApps->Add( m_pdfViewerBtn, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - + + gridHelperApps->AddGrowableCol( 1 ); - - sizerHelperApps->Add( gridHelperApps, 0, wxALL|wxEXPAND, 5 ); - - + + sizerHelperApps->Add( gridHelperApps, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); + + bLeftSizer->Add( sizerHelperApps, 0, wxEXPAND|wxALL, 5 ); - + wxStaticBoxSizer* sbSizerIconsOpts; sbSizerIconsOpts = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Interface") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizer11; fgSizer11 = new wxFlexGridSizer( 0, 3, 0, 0 ); fgSizer11->AddGrowableCol( 1 ); fgSizer11->SetFlexibleDirection( wxBOTH ); fgSizer11->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticTexticonscale = new wxStaticText( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, _("Icon scale:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTexticonscale->Wrap( -1 ); fgSizer11->Add( m_staticTexticonscale, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 4 ); - + m_iconScaleSlider = new STEPPED_SLIDER( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, 50, 50, 275, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS ); - m_iconScaleSlider->SetMinSize( wxSize( 240,-1 ) ); - + m_iconScaleSlider->SetMinSize( wxSize( 140,-1 ) ); + fgSizer11->Add( m_iconScaleSlider, 1, wxBOTTOM|wxEXPAND, 4 ); - + m_iconScaleAuto = new wxCheckBox( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, _("Automatic"), wxDefaultPosition, wxDefaultSize, 0 ); fgSizer11->Add( m_iconScaleAuto, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 25 ); - + m_staticTextCanvasScale = new wxStaticText( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, _("Canvas scale:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextCanvasScale->Wrap( -1 ); fgSizer11->Add( m_staticTextCanvasScale, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - + m_canvasScaleCtrl = new wxSpinCtrlDouble( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0, 1 ); - m_canvasScaleCtrl->SetDigits( 0 ); fgSizer11->Add( m_canvasScaleCtrl, 0, wxALL|wxEXPAND, 5 ); - + m_canvasScaleAuto = new wxCheckBox( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, _("Automatic"), wxDefaultPosition, wxDefaultSize, 0 ); fgSizer11->Add( m_canvasScaleAuto, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 25 ); - - + + fgSizer11->Add( 0, 0, 0, wxEXPAND, 5 ); - - - sbSizerIconsOpts->Add( fgSizer11, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 ); - + + + sbSizerIconsOpts->Add( fgSizer11, 1, wxEXPAND|wxRIGHT, 5 ); + m_checkBoxIconsInMenus = new wxCheckBox( sbSizerIconsOpts->GetStaticBox(), wxID_ANY, _("Show icons in menus"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizerIconsOpts->Add( m_checkBoxIconsInMenus, 0, wxALL, 4 ); - - - bLeftSizer->Add( sbSizerIconsOpts, 0, wxEXPAND|wxALL, 5 ); - + + + bLeftSizer->Add( sbSizerIconsOpts, 1, wxEXPAND|wxALL, 5 ); + + + bPanelSizer->Add( bLeftSizer, 1, wxEXPAND|wxBOTTOM, 5 ); + + 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 ); - + + sbSizer51->Add( m_ZoomCenterOpt, 0, 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 ); - - - bLeftSizer->Add( sbSizer51, 0, wxEXPAND|wxALL, 5 ); - - - bPanelSizer->Add( bLeftSizer, 0, 0, 5 ); - - + + + rightSizer->Add( sbSizer51, 0, wxEXPAND|wxALL, 5 ); + + 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_NonImmediateActions = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("First hotkey selects tool"), wxDefaultPosition, wxDefaultSize, 0 ); + m_NonImmediateActions->SetToolTip( _("If not checked, hotkeys will immediately perform an action even if the relevant tool was not previously selected.") ); + + sbSizer4->Add( m_NonImmediateActions, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + rightSizer->Add( sbSizer4, 1, wxEXPAND|wxALL, 5 ); + + + bPanelSizer->Add( rightSizer, 0, wxEXPAND|wxALL, 5 ); + + this->SetSizer( bPanelSizer ); this->Layout(); bPanelSizer->Fit( this ); - + // Connect Events m_textEditorBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnTextEditorClick ), NULL, this ); m_PDFViewerPath->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_COMMON_SETTINGS_BASE::onUpdateUIPdfPath ), NULL, this ); @@ -213,7 +232,6 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( PANEL_COMMON_SETTINGS_BASE::OnScaleSlider ), NULL, this ); m_iconScaleSlider->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( PANEL_COMMON_SETTINGS_BASE::OnScaleSlider ), NULL, this ); m_iconScaleAuto->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnIconScaleAuto ), NULL, this ); - m_canvasScaleCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleChange ), NULL, this ); m_canvasScaleAuto->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleAuto ), NULL, this ); } @@ -234,7 +252,6 @@ PANEL_COMMON_SETTINGS_BASE::~PANEL_COMMON_SETTINGS_BASE() m_iconScaleSlider->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( PANEL_COMMON_SETTINGS_BASE::OnScaleSlider ), NULL, this ); m_iconScaleSlider->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( PANEL_COMMON_SETTINGS_BASE::OnScaleSlider ), NULL, this ); m_iconScaleAuto->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnIconScaleAuto ), NULL, this ); - m_canvasScaleCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleChange ), NULL, this ); m_canvasScaleAuto->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleAuto ), NULL, this ); - + } diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp index 8e246ec5e5..bf5e301a7d 100644 --- a/common/dialogs/panel_common_settings_base.fbp +++ b/common/dialogs/panel_common_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,7 +14,6 @@ panel_common_settings_base 1000 none - 1 PanelCommonSettings @@ -49,24 +48,54 @@ wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bPanelSizer - wxVERTICAL + wxHORIZONTAL none 5 - - 0 + wxEXPAND|wxBOTTOM + 1 bLeftSizer wxVERTICAL none - 5 + 10 wxEXPAND|wxALL - 1 + 0 -1,2 wxBOTH @@ -114,7 +143,6 @@ 0 wxID_ANY &Auto save: - 0 0 @@ -140,6 +168,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -214,6 +265,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -249,7 +326,6 @@ 0 wxID_ANY minutes - 0 0 @@ -275,6 +351,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -315,7 +414,6 @@ 0 wxID_ANY File history size: - 0 0 @@ -341,6 +439,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -406,6 +527,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -443,8 +590,7 @@ 0 0 wxID_ANY - Graphics (Accelerated): - 0 + Accelerated graphics: 0 @@ -470,6 +616,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -537,6 +706,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -574,8 +767,7 @@ 0 0 wxID_ANY - Graphics (Fallback): - 0 + Fallback graphics: 0 @@ -601,6 +793,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -668,6 +883,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -684,9 +923,10 @@ wxVERTICAL 1 none + 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxLEFT 0 -1,5 @@ -735,7 +975,6 @@ 0 wxID_ANY Text editor: - 0 0 @@ -761,6 +1000,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -804,7 +1066,7 @@ 0 - 360,-1 + 280,-1 1 m_textEditorPath 1 @@ -828,6 +1090,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -855,7 +1144,6 @@ 1 1 - 0 0 @@ -869,10 +1157,9 @@ 0 0 + wxID_ANY Browse - - 0 0 @@ -887,9 +1174,8 @@ protected 1 - - Resizable + 1 @@ -904,6 +1190,29 @@ OnTextEditorClick + + + + + + + + + + + + + + + + + + + + + + + @@ -971,6 +1280,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1038,6 +1371,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1081,7 +1438,7 @@ 0 - 360,-1 + 280,-1 1 m_PDFViewerPath 1 @@ -1105,6 +1462,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + onUpdateUIPdfPath @@ -1133,7 +1516,6 @@ 1 1 - 0 0 @@ -1147,10 +1529,9 @@ 0 0 + wxID_ANY Browse - - 0 0 @@ -1165,9 +1546,8 @@ protected 1 - - Resizable + 1 @@ -1182,6 +1562,28 @@ OnPDFViewerClick + + + + + + + + + + + + + + + + + + + + + + onUpdateUIPdfPath @@ -1192,7 +1594,7 @@ 5 wxEXPAND|wxALL - 0 + 1 wxID_ANY User Interface @@ -1201,10 +1603,11 @@ wxVERTICAL 1 none + 5 - wxEXPAND|wxBOTTOM|wxRIGHT - 0 + wxEXPAND|wxRIGHT + 1 3 wxBOTH @@ -1250,7 +1653,6 @@ 0 wxID_ANY Icon scale: - 0 0 @@ -1276,6 +1678,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -1317,7 +1742,7 @@ 50 0 - 240,-1 + 140,-1 1 m_iconScaleSlider 1 @@ -1341,7 +1766,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnScaleSlider + + + + + + + + + + + + @@ -1406,7 +1873,30 @@ + OnIconScaleAuto + + + + + + + + + + + + + + + + + + + + + + @@ -1442,7 +1932,6 @@ 0 wxID_ANY Canvas scale: - 0 0 @@ -1468,6 +1957,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -1492,7 +2004,6 @@ 1 0 - 0 Dock 0 Left @@ -1532,7 +2043,30 @@ - OnCanvasScaleChange + + + + + + + + + + + + + + + + + + + + + + + + @@ -1597,7 +2131,30 @@ + OnCanvasScaleAuto + + + + + + + + + + + + + + + + + + + + + + @@ -1674,10 +2231,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + + rightSizer + wxVERTICAL + none 5 wxEXPAND|wxALL @@ -1690,9 +2282,10 @@ wxVERTICAL 1 none + 4 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 1 @@ -1752,6 +2345,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1816,6 +2433,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1880,6 +2521,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Editing + + sbSizer4 + 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 + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + First hotkey selects tool + + 0 + + + 0 + + 1 + m_NonImmediateActions + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + If not checked, hotkeys will immediately perform an action even if the relevant tool was not previously selected. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h index 6bf69116fc..aa4c1ec488 100644 --- a/common/dialogs/panel_common_settings_base.h +++ b/common/dialogs/panel_common_settings_base.h @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 10 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#pragma once +#ifndef __PANEL_COMMON_SETTINGS_BASE_H__ +#define __PANEL_COMMON_SETTINGS_BASE_H__ #include #include @@ -22,10 +23,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -38,16 +39,16 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_COMMON_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_COMMON_SETTINGS_BASE : public wxPanel +class PANEL_COMMON_SETTINGS_BASE : public wxPanel { private: - + protected: enum { wxID_AUTOPAN = 1000 }; - + wxStaticText* m_staticTextautosave; wxSpinCtrl* m_SaveTime; wxStaticText* m_staticTextFileHistorySize; @@ -70,21 +71,23 @@ class PANEL_COMMON_SETTINGS_BASE : public wxPanel wxCheckBox* m_ZoomCenterOpt; wxCheckBox* m_MousewheelPANOpt; wxCheckBox* m_AutoPANOpt; - + wxCheckBox* m_PreferSelectToDrag; + wxCheckBox* m_NonImmediateActions; + // Virtual event handlers, overide them in your derived class virtual void OnTextEditorClick( wxCommandEvent& event ) { event.Skip(); } virtual void onUpdateUIPdfPath( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnPDFViewerClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnScaleSlider( wxScrollEvent& event ) { event.Skip(); } virtual void OnIconScaleAuto( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCanvasScaleChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnCanvasScaleAuto( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - PANEL_COMMON_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_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); ~PANEL_COMMON_SETTINGS_BASE(); - + }; +#endif //__PANEL_COMMON_SETTINGS_BASE_H__ diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index a4ab27d7c0..b059a69558 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -161,6 +161,79 @@ EDA_BASE_FRAME::~EDA_BASE_FRAME() } +void EDA_BASE_FRAME::PushTool( const std::string& actionName ) +{ + m_toolStack.push_back( actionName ); + + // Human cognitive stacking is very shallow; deeper tool stacks just get annoying + if( m_toolStack.size() > 3 ) + m_toolStack.erase( m_toolStack.begin() ); + + TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName ); + + if( action ) + DisplayToolMsg( action->GetLabel() ); + else + DisplayToolMsg( actionName ); +} + + +void EDA_BASE_FRAME::PopTool( const std::string& actionName ) +{ + // Push/pop events can get out of order (such as when they're generated by the Simulator + // frame but not processed until the mouse is back in the Schematic frame), so make sure + // we're popping the right stack frame. + + for( int i = m_toolStack.size() - 1; i >= 0; --i ) + { + if( m_toolStack[ i ] == actionName ) + { + m_toolStack.erase( m_toolStack.begin() + i ); + + // If there's something underneath us, and it's now the top of the stack, then + // re-activate it + if( ( --i ) >= 0 && i == m_toolStack.size() - 1 ) + { + std::string back = m_toolStack[ i ]; + TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( back ); + + if( action ) + { + // Pop the action as running it will push it back onto the stack + m_toolStack.pop_back(); + + TOOL_EVENT evt = action->MakeEvent(); + evt.SetHasPosition( false ); + GetToolManager()->PostEvent( evt ); + } + } + else + DisplayToolMsg( ACTIONS::selectionTool.GetLabel() ); + + return; + } + } +} + + +std::string EDA_BASE_FRAME::CurrentToolName() const +{ + if( m_toolStack.empty() ) + return ACTIONS::selectionTool.GetName(); + else + return m_toolStack.back(); +} + + +bool EDA_BASE_FRAME::IsCurrentTool( const TOOL_ACTION& aAction ) const +{ + if( m_toolStack.empty() ) + return &aAction == &ACTIONS::selectionTool; + else + return m_toolStack.back() == aAction.GetName(); +} + + bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent ) { #ifdef __WXMAC__ @@ -327,6 +400,11 @@ void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged ) ReCreateMenuBar(); GetMenuBar()->Refresh(); } + + wxConfigBase* settings = Pgm().CommonSettings(); + + settings->Read( PREFER_SELECT_TO_DRAG_KEY, &m_dragSelects ); + settings->Read( IMMEDIATE_ACTIONS_KEY, &m_immediateActions ); } @@ -387,6 +465,16 @@ void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) aCfg->Read( baseCfgName + entryPerspective, &m_perspective ); aCfg->Read( baseCfgName + entryMruPath, &m_mruPath ); + + wxConfigBase* settings = Pgm().CommonSettings(); + if( !settings->Read( PREFER_SELECT_TO_DRAG_KEY, &m_dragSelects ) ) + { + // Legacy versions stored the property only for PCBNew, so see if we have it there + std::unique_ptr pcbSettings = GetNewConfig( wxT( "pcbnew" ) ); + pcbSettings->Read( "DragSelects", &m_dragSelects, true ); + } + + settings->Read( IMMEDIATE_ACTIONS_KEY, &m_immediateActions, false ); } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index f3aaaf78cb..306a0537ad 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -94,8 +94,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_toolDispatcher = NULL; m_messagePanel = NULL; m_currentScreen = NULL; - m_toolId = ID_NO_TOOL_SELECTED; - m_lastDrawToolId = ID_NO_TOOL_SELECTED; m_showBorderAndTitleBlock = false; // true to display reference sheet. m_LastGridSizeId = 0; m_drawGrid = true; // hide/Show grid. default = show @@ -424,70 +422,6 @@ void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv ) } -void EDA_DRAW_FRAME::PushTool( const std::string& actionName ) -{ - m_toolStack.push_back( actionName ); - - // Human cognitive stacking is very shallow; deeper tool stacks just get annoying - if( m_toolStack.size() > 3 ) - m_toolStack.erase( m_toolStack.begin() ); - - TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName ); - - if( action ) - DisplayToolMsg( action->GetLabel() ); - else - DisplayToolMsg( actionName ); -} - - -void EDA_DRAW_FRAME::PopTool( const std::string& actionName ) -{ - // Push/pop events can get out of order (such as when they're generated by the Simulator - // frame but not processed until the mouse is back in the Schematic frame), so make sure - // we're popping the right stack frame. - - for( int i = m_toolStack.size() - 1; i >= 0; --i ) - { - if( m_toolStack[ i ] == actionName ) - { - m_toolStack.erase( m_toolStack.begin() + i ); - - // If there's something underneath us, and it's now the top of the stack, then - // re-activate it - if( ( --i ) >= 0 && i == m_toolStack.size() - 1 ) - { - std::string back = m_toolStack[ i ]; - TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( back ); - - if( action ) - { - // Pop the action as running it will push it back onto the stack - m_toolStack.pop_back(); - - TOOL_EVENT evt = action->MakeEvent(); - evt.SetHasPosition( false ); - GetToolManager()->PostEvent( evt ); - } - } - else - DisplayToolMsg( ACTIONS::selectionTool.GetLabel() ); - - return; - } - } -} - - -bool EDA_DRAW_FRAME::IsCurrentTool( const TOOL_ACTION& aAction ) -{ - if( m_toolStack.empty() ) - return &aAction == &ACTIONS::selectionTool; - else - return m_toolStack.back() == aAction.GetName(); -} - - void EDA_DRAW_FRAME::UpdateStatusBar() { SetStatusText( GetZoomLevelIndicator(), 1 ); diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index 7a6782a892..c707fb1766 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -435,10 +436,21 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent ) // clients that don't supply a tool will have to check GetSelected() themselves if( evt && m_tool ) { + TOOL_MANAGER* toolMgr = m_tool->GetManager(); + if( g_last_menu_highlighted_id == aEvent.GetId() && !m_isContextMenu ) evt->SetHasPosition( false ); - //aEvent.StopPropagation(); + if( toolMgr->GetEditFrame() && !toolMgr->GetEditFrame()->GetDoImmediateActions() ) + { + // An tool-selection-event has no position + if( evt->GetCommandStr().is_initialized() + && evt->GetCommandStr().get() != toolMgr->GetEditFrame()->CurrentToolName() ) + { + evt->SetHasPosition( false ); + } + } + if( m_tool->GetManager() ) m_tool->GetManager()->ProcessEvent( *evt ); } diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index ea121fbdc6..ec635bec0b 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -114,28 +114,37 @@ class EDA_BASE_FRAME : public wxFrame, public KIWAY_HOLDER wxWindow* findQuasiModalDialog(); protected: - FRAME_T m_Ident; // Id Type (pcb, schematic, library..) + FRAME_T m_Ident; // Id Type (pcb, schematic, library..) wxPoint m_FramePos; wxSize m_FrameSize; - wxString m_AboutTitle; // Name of program displayed in About. + wxString m_AboutTitle; // Name of program displayed in About. wxAuiManager m_auimgr; - wxString m_configName; // prefix used to identify some params (frame size...) - // and to name some config files (legacy hotkey files) + wxString m_configName; // Prefix used to identify some params (frame size...) + // and to name some config files (legacy hotkey files) TOOL_MANAGER* m_toolManager; ACTIONS* m_actions; + std::vector m_toolStack; // Stack of user-level "tools". Not to be confused + // with TOOL_BASE-derived instances, many of which + // implement multiple user-level "tools". The user- + // level "tools" are TOOL_ACTIONSs internally. + + bool m_immediateActions; // Preference for immediate actions. If false, the + // first invocation of a hotkey will just select the + // relevant tool. + bool m_dragSelects; // Prefer selection to dragging. bool m_hasAutoSave; bool m_autoSaveState; - int m_autoSaveInterval; // The auto save interval time in seconds. + int m_autoSaveInterval; // The auto save interval time in seconds. wxTimer* m_autoSaveTimer; - wxString m_perspective; // wxAuiManager perspective. + wxString m_perspective; // wxAuiManager perspective. - wxString m_mruPath; // Most recently used path. + wxString m_mruPath; // Most recently used path. EDA_UNITS_T m_userUnits; @@ -211,21 +220,47 @@ public: */ TOOL_MANAGER* GetToolManager() const { return m_toolManager; } + /** + * NB: the definition of "tool" is different at the user level. The implementation uses + * a single TOOL_BASE derived class to implement several user "tools", such as rectangle + * and circle, or wire and bus. So each user-level tool is actually a TOOL_ACTION. + */ + virtual void PushTool( const std::string& actionName ); + virtual void PopTool( const std::string& actionName ); + + bool ToolStackIsEmpty() { return m_toolStack.empty(); } + + std::string CurrentToolName() const; + bool IsCurrentTool( const TOOL_ACTION& aAction ) const; + + virtual void DisplayToolMsg( const wxString& msg ) {}; + + /** + * Indicates that hotkeys should perform an immediate action even if another tool is + * currently active. If false, the first hotkey should select the relevant tool. + */ + bool GetDoImmediateActions() const { return m_immediateActions; } + + /** + * Indicates that a drag should draw a selection rectangle, even when started over an + * item. + */ + bool GetDragSelects() const { return m_dragSelects; } + /** * Override the default process event handler to implement the auto save feature. * - * @warning If you override this function in a derived class, make sure you call - * down to this or the auto save feature will be disabled. + * @warning If you override this function in a derived class, make sure you call down to + * this or the auto save feature will be disabled. */ bool ProcessEvent( wxEvent& aEvent ) override; /** * Capture the key event before it is sent to the GUI. * - * the basic frame does not capture this event. - * editor frames should override this event function to capture and filter - * these keys when they are used as hotkeys, and skip it if the key is not - * used as hotkey (otherwise the key events will be not sent to menus) + * The basic frame does not capture this event. Editor frames should override this event + * function to capture and filter these keys when they are used as hotkeys, and skip it if + * the key is not used as hotkey (otherwise the key events will be not sent to menus). */ virtual void OnCharHook( wxKeyEvent& event ); @@ -364,31 +399,28 @@ public: /** * Checks if \a aFileName can be written. *

- * The function performs a number of tests on \a aFileName to verify that it - * can be saved. If \a aFileName defines a path with no file name, them the - * path is tested for user write permission. If \a aFileName defines a file - * name that does not exist in the path, the path is tested for user write - * permission. If \a aFileName defines a file that already exits, the file - * name is tested for user write permissions. + * The function performs a number of tests on \a aFileName to verify that it can be saved. + * If \a aFileName defines a path with no file name, them the path is tested for user write + * permission. If \a aFileName defines a file name that does not exist in the path, the + * path is tested for user write permission. If \a aFileName defines a file that already + * exits, the file name is tested for user write permissions. *

- * - * @note The file name path must be set or an assertion will be raised on debug - * builds and return false on release builds. + * @note The file name path must be set or an assertion will be raised on debug builds and + * return false on release builds. * @param aFileName The full path and/or file name of the file to test. * @return False if \a aFileName cannot be written. */ bool IsWritable( const wxFileName& aFileName ); /** - * Check if an auto save file exists for \a aFileName and takes the appropriate - * action depending on the user input. + * Check if an auto save file exists for \a aFileName and takes the appropriate action + * depending on the user input. *

- * If an auto save file exists for \a aFileName, the user is prompted if they wish - * to replace file \a aFileName with the auto saved file. If the user chooses to - * replace the file, the backup file of \a aFileName is removed, \a aFileName is - * renamed to the backup file name, and the auto save file is renamed to \a aFileName. - * If user chooses to keep the existing version of \a aFileName, the auto save file - * is removed. + * If an auto save file exists for \a aFileName, the user is prompted if they wish to + * replace file \a aFileName with the auto saved file. If the user chooses to replace the + * file, the backup file of \a aFileName is removed, \a aFileName is renamed to the backup + * file name, and the auto save file is renamed to \a aFileName. If user chooses to keep + * the existing version of \a aFileName, the auto save file is removed. *

* @param aFileName A wxFileName object containing the file name to check. */ diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 5dab312387..f55b2e9ba0 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -35,7 +35,6 @@ #include "hotkeys_basic.h" class wxSingleInstanceChecker; -class EDA_HOTKEY; class ACTION_TOOLBAR; class TOOL_MENU; @@ -82,47 +81,35 @@ namespace KIGFX */ class EDA_DRAW_FRAME : public KIWAY_PLAYER { - ///< Id of active button on the vertical toolbar. - int m_toolId; - - BASE_SCREEN* m_currentScreen; ///< current used SCREEN - - EDA_DRAW_PANEL_GAL* m_canvas; + BASE_SCREEN* m_currentScreen; ///< current used SCREEN + EDA_DRAW_PANEL_GAL* m_canvas; ///< GAL display options - this is the frame's interface to setting GAL display options KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; protected: - wxSocketServer* m_socketServer; - std::vector m_sockets; ///< interprocess communication + wxSocketServer* m_socketServer; + std::vector m_sockets; ///< interprocess communication std::unique_ptr m_file_checker; ///< prevents opening same file multiple times. - int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid - // 0 is for the grid corresponding to - // a wxCommand ID = ID_POPUP_GRID_LEVEL_1000. - bool m_drawGrid; // hide/Show grid - bool m_showPageLimits; ///< true to display the page limits - COLOR4D m_gridColor; ///< Grid color - COLOR4D m_drawBgColor; ///< the background color of the draw canvas - ///< BLACK for Pcbnew, BLACK or WHITE for eeschema - double m_zoomLevelCoeff; ///< a suitable value to convert the internal zoom scaling factor - // to a zoom level value which rougly gives 1.0 when the board/schematic - // is at scale = 1 - int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed + int m_LastGridSizeId; // The command id offset (>= 0) of the last selected + // grid 0 is for the grid corresponding to a + // wxCommand ID = ID_POPUP_GRID_LEVEL_1000. + bool m_drawGrid; // Hide/Show grid + bool m_showPageLimits; // True to display the page limits + COLOR4D m_gridColor; // Grid color + COLOR4D m_drawBgColor; // The background color of the draw canvas; BLACK for + // Pcbnew, BLACK or WHITE for eeschema + double m_zoomLevelCoeff; // A suitable value to convert the internal zoom + // scaling factor to a zoom level value which rougly + // gives 1.0 when the board/schematic is at scale = 1 + int m_UndoRedoCountMax; // Default Undo/Redo command Max depth, to be handed // to screens - bool m_PolarCoords; //< for those frames that support polar coordinates + bool m_PolarCoords; // For those frames that support polar coordinates TOOL_DISPATCHER* m_toolDispatcher; - /// Tool ID of previously active draw tool bar button. - int m_lastDrawToolId; // JEY TODO: remove this; it doesn't work in modern toolset anyway - - std::vector m_toolStack; // stack of user-level "tools". Used to temporarily - // invoke an immediate-mode action. Note that these - // are "tools" in the UI sense, which are actually - // TOOL_ACTIONs internally - bool m_showBorderAndTitleBlock; /// Show the worksheet (border and title block). long m_firstRunDialogSetting; /// Show first run dialog on startup @@ -303,62 +290,15 @@ public: virtual void ReCreateOptToolbar() = 0; virtual void ReCreateAuxiliaryToolbar() { } - /** - * The definition of "tool" is different at the user level. The implementation uses - * a single TOOL_BASE derived class to implement several user "tools", such as rectangle - * and circle, or wire and bus. So each user-level tool is actually a TOOL_ACTION. + /* + * These 4 functions provide a basic way to show/hide grid and /get/set grid color. + * These parameters are saved in KiCad config for each main frame. */ - virtual void PushTool( const std::string& actionName ); - virtual void PopTool( const std::string& actionName ); + virtual bool IsGridVisible() const { return m_drawGrid; } + virtual void SetGridVisibility( bool aVisible ) { m_drawGrid = aVisible; } - bool ToolStackIsEmpty() { return m_toolStack.empty(); } - - bool IsCurrentTool( const TOOL_ACTION& aAction ); - - - /** - * @return the current tool ID - * when there is no active tool, the ID_NO_TOOL_SELECTED is returned - * (the id of the default Tool (idle tool) of the right vertical toolbar) - */ - int GetToolId() const { return m_toolId; } - - /* These 4 functions provide a basic way to show/hide grid - * and /get/set grid color. - * These parameters are saved in KiCad config for each main frame - */ - /** - * @return true if the grid must be shown - */ - virtual bool IsGridVisible() const - { - return m_drawGrid; - } - - /** - * It may be overloaded by derived classes - * @param aVisible = true if the grid must be shown - */ - virtual void SetGridVisibility( bool aVisible ) - { - m_drawGrid = aVisible; - } - - /** - * @return the color of the grid - */ - virtual COLOR4D GetGridColor() - { - return m_gridColor; - } - - /** - * @param aColor = the new color of the grid - */ - virtual void SetGridColor( COLOR4D aColor ) - { - m_gridColor = aColor; - } + virtual COLOR4D GetGridColor() { return m_gridColor; } + virtual void SetGridColor( COLOR4D aColor ) { m_gridColor = aColor; } /** * Command event handler for selecting grid sizes. @@ -392,26 +332,6 @@ public: */ virtual void OnSize( wxSizeEvent& event ); - void OnEraseBackground( wxEraseEvent& SizeEvent ); - - /** - * Change the zoom to the next one available redraws the screen - * and warp the mouse pointer on request. - * - * @param aCenterPoint is the reference point for zooming - * @param aWarpPointer = true to move the pointer to the aCenterPoint - */ - void SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer ); - - /** - * Change the zoom to the previous one available redraws the screen - * and warp the mouse pointer on request. - * - * @param aCenterPoint is the reference point for zooming - * @param aWarpPointer = true to move the pointer to the aCenterPoint - */ - void SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer ); - /** * Rebuild the GAL and redraws the screen. Call when something went wrong. */ @@ -462,7 +382,7 @@ public: const wxString &aFilename, const wxString &aSheetLayer = wxEmptyString, COLOR4D aColor = COLOR4D::UNSPECIFIED ); - void DisplayToolMsg( const wxString& msg ); + void DisplayToolMsg( const wxString& msg ) override; /** * Called when modifying the page settings. diff --git a/include/pgm_base.h b/include/pgm_base.h index 8c2a896bf8..c2ef70a1bc 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -55,6 +55,8 @@ #define GAL_DISPLAY_OPTIONS_KEY wxT( "GalDisplayOptions" ) #define GAL_ANTIALIASING_MODE_KEY wxT( "OpenGLAntialiasingMode" ) #define CAIRO_ANTIALIASING_MODE_KEY wxT( "CairoAntialiasingMode" ) +#define IMMEDIATE_ACTIONS_KEY wxT( "ImmediateActions" ) +#define PREFER_SELECT_TO_DRAG_KEY wxT( "PreferSelectionToDragging" ) ///@} diff --git a/pcbnew/dialogs/panel_modedit_settings.cpp b/pcbnew/dialogs/panel_modedit_settings.cpp index 914da3515b..754e1cf19c 100644 --- a/pcbnew/dialogs/panel_modedit_settings.cpp +++ b/pcbnew/dialogs/panel_modedit_settings.cpp @@ -47,7 +47,6 @@ bool PANEL_MODEDIT_SETTINGS::TransferDataToWindow() // Editing options m_Segments_45_Only_Ctrl->SetValue( m_frame->Settings().m_Use45DegreeGraphicSegments ); m_MagneticPads->SetValue( m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS ); - m_dragSelects->SetValue( m_frame->Settings().m_DragSelects ); return true; } @@ -62,7 +61,6 @@ bool PANEL_MODEDIT_SETTINGS::TransferDataFromWindow() // Editing options m_frame->Settings().m_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue(); m_frame->Settings().m_MagneticPads = m_MagneticPads->GetValue() ? CAPTURE_ALWAYS : NO_EFFECT; - m_frame->Settings().m_DragSelects = m_dragSelects->GetValue(); return true; } diff --git a/pcbnew/dialogs/panel_modedit_settings_base.cpp b/pcbnew/dialogs/panel_modedit_settings_base.cpp index 54fc7ec87f..fd8b09b437 100644 --- a/pcbnew/dialogs/panel_modedit_settings_base.cpp +++ b/pcbnew/dialogs/panel_modedit_settings_base.cpp @@ -45,18 +45,10 @@ PANEL_MODEDIT_SETTINGS_BASE::PANEL_MODEDIT_SETTINGS_BASE( wxWindow* parent, wxWi m_MagneticPads = new wxCheckBox( sbSizerEditOptions->GetStaticBox(), wxID_ANY, _("Magnetic pads"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizerEditOptions->Add( m_MagneticPads, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - sbSizerEditOptions->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - m_Segments_45_Only_Ctrl = new wxCheckBox( sbSizerEditOptions->GetStaticBox(), wxID_SEGMENTS45, _("L&imit graphic lines to H, V and 45 degrees"), wxDefaultPosition, wxDefaultSize, 0 ); m_Segments_45_Only_Ctrl->SetToolTip( _("Force line segment directions to H, V or 45 degrees when drawing on technical layers.") ); - sbSizerEditOptions->Add( m_Segments_45_Only_Ctrl, 0, wxALL, 5 ); - - m_dragSelects = new wxCheckBox( sbSizerEditOptions->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.") ); - - sbSizerEditOptions->Add( m_dragSelects, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + sbSizerEditOptions->Add( m_Segments_45_Only_Ctrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerColumns->Add( sbSizerEditOptions, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); diff --git a/pcbnew/dialogs/panel_modedit_settings_base.fbp b/pcbnew/dialogs/panel_modedit_settings_base.fbp index baba66b8a2..d18ad5c3a8 100644 --- a/pcbnew/dialogs/panel_modedit_settings_base.fbp +++ b/pcbnew/dialogs/panel_modedit_settings_base.fbp @@ -386,17 +386,7 @@
5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 0 - protected - 0 - - - - 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -482,94 +472,6 @@ - - 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 - g_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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/panel_modedit_settings_base.h b/pcbnew/dialogs/panel_modedit_settings_base.h index 930201fa01..6620f5ec0a 100644 --- a/pcbnew/dialogs/panel_modedit_settings_base.h +++ b/pcbnew/dialogs/panel_modedit_settings_base.h @@ -40,7 +40,6 @@ class PANEL_MODEDIT_SETTINGS_BASE : public wxPanel wxRadioBox* m_UnitsSelection; wxCheckBox* m_MagneticPads; wxCheckBox* m_Segments_45_Only_Ctrl; - wxCheckBox* m_dragSelects; public: diff --git a/pcbnew/dialogs/panel_pcbnew_settings.cpp b/pcbnew/dialogs/panel_pcbnew_settings.cpp index f8d6da4eff..0f69d63d84 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings.cpp @@ -61,7 +61,6 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow() m_magneticTrackChoice->SetSelection( general_opts.m_MagneticTracks ); m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticGraphics ); m_UseEditKeyForWidth->SetValue( general_opts.m_EditHotkeyChangesTrackWidth ); - m_dragSelects->SetValue( general_opts.m_DragSelects ); m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight ); m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() ); @@ -84,7 +83,6 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow() m_Frame->Settings().m_MagneticTracks = (MAGNETIC_OPTIONS) m_magneticTrackChoice->GetSelection(); m_Frame->Settings().m_MagneticGraphics = !m_magneticGraphicsChoice->GetSelection(); m_Frame->Settings().m_EditHotkeyChangesTrackWidth = m_UseEditKeyForWidth->GetValue(); - m_Frame->Settings().m_DragSelects = m_dragSelects->GetValue(); m_Frame->Settings().m_FlipLeftRight = m_FlipLeftRight->GetValue(); m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp index 4bdcf146f8..972a1471e6 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp @@ -49,11 +49,6 @@ PANEL_PCBNEW_SETTINGS_BASE::PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWind 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 ); - m_FlipLeftRight = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Flip board items L/R (default is T/B)"), wxDefaultPosition, wxDefaultSize, 0 ); bOptionsSizer->Add( m_FlipLeftRight, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp index a9eda1fd72..461258c4d5 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp @@ -470,94 +470,6 @@ - - 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 wxBOTTOM|wxRIGHT|wxLEFT diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.h b/pcbnew/dialogs/panel_pcbnew_settings_base.h index ed7729b6b9..c1e11cbe0b 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.h +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.h @@ -46,7 +46,6 @@ class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel wxRadioBox* m_UnitsSelection; wxCheckBox* m_Segments_45_Only_Ctrl; wxCheckBox* m_UseEditKeyForWidth; - wxCheckBox* m_dragSelects; wxCheckBox* m_FlipLeftRight; wxStaticText* m_staticTextRotationAngle; wxTextCtrl* m_RotationAngle; diff --git a/pcbnew/pcb_general_settings.cpp b/pcbnew/pcb_general_settings.cpp index 356177a72e..0c276d842c 100644 --- a/pcbnew/pcb_general_settings.cpp +++ b/pcbnew/pcb_general_settings.cpp @@ -28,7 +28,6 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) : m_Use45DegreeGraphicSegments( false ), m_EditHotkeyChangesTrackWidth( false ), - m_DragSelects( true ), m_FlipLeftRight( false ), m_MagneticPads( CAPTURE_CURSOR_IN_TRACK_TOOL ), m_MagneticTracks( CAPTURE_CURSOR_IN_TRACK_TOOL ), @@ -44,7 +43,6 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) : Add( "MagneticTracks", reinterpret_cast( &m_MagneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL ); Add( "MagneticGraphics", &m_MagneticGraphics, true ); Add( "EditActionChangesTrackWidth", &m_EditHotkeyChangesTrackWidth, false ); - Add( "DragSelects", &m_DragSelects, true ); Add( "FlipLeftRight", &m_FlipLeftRight, false ); break; diff --git a/pcbnew/pcb_general_settings.h b/pcbnew/pcb_general_settings.h index 38924ec175..496eb679a5 100644 --- a/pcbnew/pcb_general_settings.h +++ b/pcbnew/pcb_general_settings.h @@ -50,8 +50,6 @@ public: bool m_Use45DegreeGraphicSegments; // True to constraint graphic lines to horizontal, // vertical and 45ยบ bool m_EditHotkeyChangesTrackWidth; - bool m_DragSelects; // True: Drag gesture always draws a selection box, - // False: Drag will select an item and move it bool m_FlipLeftRight; // True: Flip footprints across Y axis // False: Flip footprints across X axis diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 314031189b..39875d4193 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -189,7 +189,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - bool dragAlwaysSelects = getEditFrame()->Settings().m_DragSelects; + bool dragAlwaysSelects = getEditFrame()->GetDragSelects(); m_additive = m_subtractive = m_exclusive_or = false; if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) )