diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 3955292d6a..9fa529b7e6 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -60,13 +60,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case 0: break; - case ID_TOOLBARH_PCB_SELECT_LAYER: - SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); - - if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) - GetCanvas()->Refresh(); - break; - case ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY: ExportFootprintsToLibrary( false ); break; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index d306be2090..664d344a0f 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -93,9 +93,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnLoadFootprintFromBoard ) EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::OnSaveFootprintToBoard ) - // Horizontal toolbar - EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::SelectLayer ) - // UI update events. EVT_UPDATE_UI( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard ) diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index fa03913fc4..4f704e6c34 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -129,8 +129,6 @@ public: */ void ReCreateLayerBox( bool aForceResizeToolbar = true ); - void SelectLayer( wxCommandEvent& event ); - // The Tool Framework initialization, for GAL mode void setupTools(); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index e8cf5e7707..2e490a38d1 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -115,16 +115,6 @@ void FOOTPRINT_EDIT_FRAME::centerItemIdleHandler( wxIdleEvent& aEvent ) } - -void FOOTPRINT_EDIT_FRAME::SelectLayer( wxCommandEvent& event ) -{ - SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); - - if( GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) - GetCanvas()->Refresh(); -} - - void FOOTPRINT_EDIT_FRAME::OnSaveFootprintToBoard( wxCommandEvent& event ) { SaveFootprintToBoard( true ); diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 13b9dbb97f..3fa0ed8a10 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -1282,8 +1282,7 @@ void PCB_BASE_FRAME::configureToolbars() { if( !m_SelLayerBox ) { - m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( aToolbar, - ID_TOOLBARH_PCB_SELECT_LAYER ); + m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( aToolbar, wxID_ANY ); m_SelLayerBox->SetBoardFrame( this ); } @@ -1293,6 +1292,7 @@ void PCB_BASE_FRAME::configureToolbars() if( IsType( FRAME_FOOTPRINT_EDITOR ) ) m_SelLayerBox->SetNotAllowedLayerSet( LSET::ForbiddenFootprintLayers() ); + m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); m_SelLayerBox->Resync(); aToolbar->Add( m_SelLayerBox ); @@ -1301,16 +1301,27 @@ void PCB_BASE_FRAME::configureToolbars() aToolbar->Bind( wxEVT_UPDATE_UI, [this]( wxUpdateUIEvent& aEvent ) { - if( m_SelLayerBox->GetCount() ) + if( m_SelLayerBox->GetCount() + && ( m_SelLayerBox->GetLayerSelection() != GetActiveLayer() ) ) { - if( m_SelLayerBox->GetSelection() != GetActiveLayer() ) - m_SelLayerBox->SetSelection( GetActiveLayer() ); + m_SelLayerBox->SetLayerSelection( GetActiveLayer() ); } }, m_SelLayerBox->GetId() ); + + // Event handler to respond to the user interacting with the control + aToolbar->Bind( wxEVT_COMBOBOX, + [this]( wxCommandEvent& aEvent ) + { + SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); + + if( GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) + GetCanvas()->Refresh(); + }, + m_SelLayerBox->GetId() ); }; RegisterCustomToolbarControlFactory( m_tbPcbLayerSelectorName, _( "Layer selector" ), _( "Control to select the layer" ), layerSelectorFactory ); -} \ No newline at end of file +} diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 3580190822..4054bcae91 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -175,7 +175,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) // Horizontal toolbar EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) - EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) EVT_CHOICE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 94c5fda424..bf61563a54 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -93,8 +93,6 @@ enum pcbnew_ids ID_PCB_GEN_CMP_FILE, ID_PCB_GEN_BOM_FILE_FROM_BOARD, - ID_TOOLBARH_PCB_SELECT_LAYER, - ID_FPEDIT_SAVE_PNG, ID_MODVIEW_LIB_FILTER,