diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index d8daf2a49c..cb0bfc4dbe 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -103,7 +103,6 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo m_btnNetInspector->SetBitmapLabel( KiBitmap( list_nets_xpm ) ); m_btnConfigureNetClasses->SetBitmapLabel( KiBitmap( options_generic_xpm ) ); - m_btnDeletePreset->SetBitmapLabel( KiBitmap( trash_xpm ) ); m_txtNetFilter->SetHint( _( "Filter nets" ) ); @@ -1252,7 +1251,7 @@ void APPEARANCE_CONTROLS::rebuildNets() m_frame->GetToolManager()->RunAction( action, true, net ); } ); - wxString netName = aNet->GetShortNetname(); + const wxString& netName = aNet->GetShortNetname(); auto menuHandler = [&, netCode, netName]( wxMouseEvent& aEvent ) @@ -1291,7 +1290,7 @@ void APPEARANCE_CONTROLS::rebuildNets() }; auto appendNetclass = - [&]( int aId, NETCLASSPTR aClass, bool isDefault = false ) + [&]( int aId, const NETCLASSPTR& aClass, bool isDefault = false ) { wxString name = aClass->GetName(); @@ -1470,8 +1469,6 @@ void APPEARANCE_CONTROLS::syncLayerPresetSelection() m_currentPreset = static_cast( m_cbLayerPresets->GetClientData( m_cbLayerPresets->GetSelection() ) ); - - updateDeleteLayerPresetButton(); } @@ -1483,12 +1480,10 @@ void APPEARANCE_CONTROLS::updateLayerPresetSelection( const wxString& aName ) { m_cbLayerPresets->SetSelection( idx ); m_currentPreset = static_cast( m_cbLayerPresets->GetClientData( idx ) ); - updateDeleteLayerPresetButton(); } else if( idx < 0 ) { m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 ); // separator - updateDeleteLayerPresetButton(); } } @@ -1543,7 +1538,6 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) index = m_cbLayerPresets->Insert( name, index - 1, static_cast( preset ) ); m_cbLayerPresets->SetSelection( index ); - m_btnDeletePreset->Enable(); return; } @@ -1566,7 +1560,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) } EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items, wxEmptyString ); - dlg.SetListLabel( _( "Select netclass:" ) ); + dlg.SetListLabel( _( "Select preset:" ) ); if( dlg.ShowModal() == wxID_OK ) { @@ -1579,14 +1573,13 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) m_currentPreset = nullptr; } + resetSelection(); return; } LAYER_PRESET* preset = static_cast( m_cbLayerPresets->GetClientData( index ) ); m_currentPreset = preset; - updateDeleteLayerPresetButton(); - doApplyLayerPreset( *preset ); } @@ -1612,36 +1605,6 @@ void APPEARANCE_CONTROLS::doApplyLayerPreset( const LAYER_PRESET& aPreset ) } -void APPEARANCE_CONTROLS::updateDeleteLayerPresetButton() -{ - bool enable = m_currentPreset && !m_currentPreset->readOnly; - - m_btnDeletePreset->Enable( enable ); - m_btnDeletePreset->SetToolTip( enable ? _( "Delete this layer preset " ) : - _( "This preset cannot be deleted" ) ); -} - - -void APPEARANCE_CONTROLS::OnBtnDeleteLayerPreset( wxCommandEvent& event ) -{ - LAYER_PRESET* current = static_cast( - m_cbLayerPresets->GetClientData( m_cbLayerPresets->GetSelection() ) ); - - // Button should not be enabled if we are not on an active preset - wxASSERT( current && current == m_currentPreset ); - - if( current->readOnly ) - return; - - int index = m_cbLayerPresets->GetSelection(); - - m_layerPresets.erase( current->name ); - m_cbLayerPresets->Delete( index ); - m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 ); - m_currentPreset = nullptr; -} - - void APPEARANCE_CONTROLS::OnColorSwatchChanged( wxCommandEvent& aEvent ) { COLOR_SWATCH* swatch = static_cast( aEvent.GetEventObject() ); @@ -1671,24 +1634,11 @@ void APPEARANCE_CONTROLS::onObjectOpacitySlider( int aLayer, float aOpacity ) switch( aLayer ) { - case static_cast( LAYER_TRACKS ): - options.m_TrackOpacity = aOpacity; - break; - - case static_cast( LAYER_VIAS ): - options.m_ViaOpacity = aOpacity; - break; - - case static_cast( LAYER_PADS ): - options.m_PadOpacity = aOpacity; - break; - - case static_cast( LAYER_ZONES ): - options.m_ZoneOpacity = aOpacity; - break; - - default: - return; + case static_cast( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break; + case static_cast( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break; + case static_cast( LAYER_PADS ): options.m_PadOpacity = aOpacity; break; + case static_cast( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break; + default: return; } m_frame->SetDisplayOptions( options ); diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index c8ba31c34b..95412346a6 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -149,8 +149,6 @@ protected: void OnNetDisplayPaneChanged( wxCollapsiblePaneEvent& event ) override; - void OnBtnDeleteLayerPreset( wxCommandEvent& event ) override; - void OnNotebookPageChanged( wxNotebookEvent& event ) override; private: @@ -251,8 +249,6 @@ private: void syncLayerPresetSelection(); - void updateDeleteLayerPresetButton(); - void onLayerClick( wxMouseEvent& aEvent ); void onLayerVisibilityChanged( PCB_LAYER_ID aLayer, bool isVisible, bool isFinal ); @@ -263,7 +259,7 @@ private: void updateLayerPresetSelection( const wxString& aName ); - void onLayerPresetChanged( wxCommandEvent& aEvent ); + void onLayerPresetChanged( wxCommandEvent& aEvent ) override; void doApplyLayerPreset( const LAYER_PRESET& aPreset ); diff --git a/pcbnew/widgets/appearance_controls_base.cpp b/pcbnew/widgets/appearance_controls_base.cpp index 02173508a2..78e114f00f 100644 --- a/pcbnew/widgets/appearance_controls_base.cpp +++ b/pcbnew/widgets/appearance_controls_base.cpp @@ -80,7 +80,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_panelLayers->SetSizer( m_panelLayersSizer ); m_panelLayers->Layout(); m_panelLayersSizer->Fit( m_panelLayers ); - m_notebook->AddPage( m_panelLayers, wxT("Layers"), false ); + m_notebook->AddPage( m_panelLayers, wxT("Layers"), true ); m_panelObjects = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelObjects->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); @@ -234,29 +234,33 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_panelNetsAndClasses->SetSizer( bSizer16 ); m_panelNetsAndClasses->Layout(); bSizer16->Fit( m_panelNetsAndClasses ); - m_notebook->AddPage( m_panelNetsAndClasses, wxT("Nets"), true ); + m_notebook->AddPage( m_panelNetsAndClasses, wxT("Nets"), false ); m_sizerOuter->Add( m_notebook, 1, wxEXPAND, 5 ); - wxStaticBoxSizer* presetsSizer; - presetsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Layer Presets") ), wxHORIZONTAL ); + wxBoxSizer* bSizer18; + bSizer18 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer171; + bSizer171 = new wxBoxSizer( wxVERTICAL ); + + m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("Presets:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + bSizer171->Add( m_staticText5, 0, wxTOP|wxRIGHT|wxLEFT, 2 ); wxString m_cbLayerPresetsChoices[] = { wxT("All Layers"), wxT("(unsaved)") }; int m_cbLayerPresetsNChoices = sizeof( m_cbLayerPresetsChoices ) / sizeof( wxString ); - m_cbLayerPresets = new wxChoice( presetsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbLayerPresetsNChoices, m_cbLayerPresetsChoices, 0 ); + m_cbLayerPresets = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbLayerPresetsNChoices, m_cbLayerPresetsChoices, 0 ); m_cbLayerPresets->SetSelection( 1 ); m_cbLayerPresets->SetToolTip( wxT("Layer presets") ); - presetsSizer->Add( m_cbLayerPresets, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_btnDeletePreset = new wxBitmapButton( presetsSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - m_btnDeletePreset->Enable( false ); - m_btnDeletePreset->SetToolTip( wxT("Delete this layer preset") ); - - presetsSizer->Add( m_btnDeletePreset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer171->Add( m_cbLayerPresets, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 2 ); - m_sizerOuter->Add( presetsSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizer18->Add( bSizer171, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + m_sizerOuter->Add( bSizer18, 0, wxEXPAND|wxBOTTOM, 2 ); this->SetSizer( m_sizerOuter ); @@ -268,8 +272,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_paneLayerDisplay->Connect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( APPEARANCE_CONTROLS_BASE::OnLayerDisplayPaneChanged ), NULL, this ); m_cbFlipBoard->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnFlipBoardChecked ), NULL, this ); m_paneNetDisplay->Connect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( APPEARANCE_CONTROLS_BASE::OnNetDisplayPaneChanged ), NULL, this ); - m_cbLayerPresets->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnLayerPresetChanged ), NULL, this ); - m_btnDeletePreset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnBtnDeleteLayerPreset ), NULL, this ); + m_cbLayerPresets->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::onLayerPresetChanged ), NULL, this ); } APPEARANCE_CONTROLS_BASE::~APPEARANCE_CONTROLS_BASE() @@ -279,7 +282,6 @@ APPEARANCE_CONTROLS_BASE::~APPEARANCE_CONTROLS_BASE() m_paneLayerDisplay->Disconnect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( APPEARANCE_CONTROLS_BASE::OnLayerDisplayPaneChanged ), NULL, this ); m_cbFlipBoard->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnFlipBoardChecked ), NULL, this ); m_paneNetDisplay->Disconnect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( APPEARANCE_CONTROLS_BASE::OnNetDisplayPaneChanged ), NULL, this ); - m_cbLayerPresets->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnLayerPresetChanged ), NULL, this ); - m_btnDeletePreset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::OnBtnDeleteLayerPreset ), NULL, this ); + m_cbLayerPresets->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( APPEARANCE_CONTROLS_BASE::onLayerPresetChanged ), NULL, this ); } diff --git a/pcbnew/widgets/appearance_controls_base.fbp b/pcbnew/widgets/appearance_controls_base.fbp index 28cf56efe3..f472cdc3e6 100644 --- a/pcbnew/widgets/appearance_controls_base.fbp +++ b/pcbnew/widgets/appearance_controls_base.fbp @@ -1892,153 +1892,149 @@ - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 2 + wxEXPAND|wxBOTTOM 0 - - wxID_ANY - Layer Presets + - presetsSizer - wxHORIZONTAL - 1 + bSizer18 + wxVERTICAL none 5 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "All Layers" "(unsaved)" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_cbLayerPresets - 1 - - - protected - 1 - - Resizable - 1 - 1 - - - ; ; forward_declare - 0 - Layer presets - - wxFILTER_NONE - wxDefaultValidator - - - - - OnLayerPresetChanged - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - - 1 - - - 0 - 0 - wxID_ANY - New Preset - - 0 - - 0 - - - 0 + - 1 - m_btnDeletePreset - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - Delete this layer preset - - wxFILTER_NONE - wxDefaultValidator - - - - - OnBtnDeleteLayerPreset + bSizer171 + wxVERTICAL + none + + 2 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Presets: + 0 + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 2 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "All Layers" "(unsaved)" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_cbLayerPresets + 1 + + + protected + 1 + + Resizable + 1 + 1 + + + ; ; forward_declare + 0 + Layer presets + + wxFILTER_NONE + wxDefaultValidator + + + + + onLayerPresetChanged + + diff --git a/pcbnew/widgets/appearance_controls_base.h b/pcbnew/widgets/appearance_controls_base.h index d2e4f03ad4..460a0a54af 100644 --- a/pcbnew/widgets/appearance_controls_base.h +++ b/pcbnew/widgets/appearance_controls_base.h @@ -31,7 +31,6 @@ #include #include #include -#include /////////////////////////////////////////////////////////////////////////// @@ -79,16 +78,15 @@ class APPEARANCE_CONTROLS_BASE : public wxPanel wxRadioButton* m_rbNetColorAll; wxRadioButton* m_rbNetColorRatsnest; wxRadioButton* m_rbNetColorOff; + wxStaticText* m_staticText5; wxChoice* m_cbLayerPresets; - wxBitmapButton* m_btnDeletePreset; // Virtual event handlers, overide them in your derived class virtual void OnNotebookPageChanged( wxNotebookEvent& event ) { event.Skip(); } virtual void OnLayerDisplayPaneChanged( wxCollapsiblePaneEvent& event ) { event.Skip(); } virtual void OnFlipBoardChecked( wxCommandEvent& event ) { event.Skip(); } virtual void OnNetDisplayPaneChanged( wxCollapsiblePaneEvent& event ) { event.Skip(); } - virtual void OnLayerPresetChanged( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBtnDeleteLayerPreset( wxCommandEvent& event ) { event.Skip(); } + virtual void onLayerPresetChanged( wxCommandEvent& event ) { event.Skip(); } public: