diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 1a3638858d..1dcf2567ac 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -28,32 +28,20 @@ #include #include #include -#include #include #include - #include -#include #include - #include #include #include #include -#include #include #include -#include #include #include -#include #include #include - -#include - -#include - #include #include #include diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 118004ef23..45c6208317 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -83,15 +83,16 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard ) EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - // popup commands + // Horizontal toolbar EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) + EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) // UI update events. EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard ) EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard ) - + EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox ) EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) END_EVENT_TABLE() @@ -108,6 +109,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_canvasType = aBackend; m_AboutTitle = "ModEdit"; + m_selLayerBox = nullptr; // Give an icon wxIcon icon; diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 4748480e7e..46dca334c9 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -26,6 +26,7 @@ #include #include +class PCB_LAYER_BOX_SELECTOR; class PCB_LAYER_WIDGET; class FP_LIB_TABLE; class EDGE_MODULE; @@ -123,6 +124,17 @@ public: */ void ReCreateMenuBar() override; + /** + * Re create the layer Box by clearing the old list, and building + * le new one, from the new layers names and cole layers + * @param aForceResizeToolbar = true to resize the parent toolbar + * false if not needed (mainly in parent toolbar creation, + * or when the layers names are not modified) + */ + void ReCreateLayerBox( bool aForceResizeToolbar = true ); + + void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); + // The Tool Framework initalization, for GAL mode void setupTools(); @@ -342,14 +354,12 @@ public: DECLARE_EVENT_TABLE() protected: - /// protected so only friend PCB::IFACE::CreateWindow() can act as sole factory. FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ); - PCB_LAYER_WIDGET* m_Layers; ///< the layer manager - - /// List of footprint editor configuration parameters. - PARAM_CFG_ARRAY m_configParams; + PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer + PCB_LAYER_WIDGET* m_Layers; // the layer manager + PARAM_CFG_ARRAY m_configParams; // List of footprint editor configuration parameters. /** * Make sure the footprint info list is loaded (with a progress dialog) and then initialize diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index d29e2210f4..8e45a50623 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,10 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file footprint_editor_utils.cpp - */ - #include #include #include @@ -43,7 +39,7 @@ #include #include #include - +#include #include #include #include @@ -55,7 +51,6 @@ #include #include #include - #include #include #include @@ -313,6 +308,13 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SaveFootprintToBoard( true ); break; + case ID_TOOLBARH_PCB_SELECT_LAYER: + SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) ); + + if( static_cast( GetDisplayOptions() )->m_ContrastModeDisplay ) + GetCanvas()->Refresh(); + break; + case ID_MODEDIT_CHECK: // Currently: not implemented break; diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 3de90325a2..a494391606 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() { @@ -53,7 +54,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() #ifdef KICAD_SCRIPTING m_mainToolBar->Add( PCB_ACTIONS::createFootprint ); #endif - + if( IsCurrentFPFromBoard() ) m_mainToolBar->Add( PCB_ACTIONS::saveToBoard ); else @@ -113,6 +114,18 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() updateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); + KiScaledSeparator( m_mainToolBar, this ); + + // Layer selection choice box. + if( m_selLayerBox == nullptr ) + { + m_selLayerBox = new PCB_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_PCB_SELECT_LAYER ); + m_selLayerBox->SetBoardFrame( this ); + } + + ReCreateLayerBox( false ); + m_mainToolBar->AddControl( m_selLayerBox ); + // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); } @@ -129,19 +142,19 @@ void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_drawToolBar, this ); - m_drawToolBar->Add( PCB_ACTIONS::placePad, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawPolygon, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawZoneKeepout, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::placePad, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawPolygon, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawZoneKeepout, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_drawToolBar, this ); - m_drawToolBar->Add( PCB_ACTIONS::setAnchor, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::setAnchor, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Realize(); } @@ -173,6 +186,29 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar() } +void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar ) +{ + if( m_selLayerBox == NULL || m_mainToolBar == NULL ) + return; + + m_selLayerBox->SetToolTip( _( "+/- to switch" ) ); + m_selLayerBox->Resync(); + + if( aForceResizeToolbar ) + { + // the layer box can have its size changed + // Update the aui manager, to take in account the new size + m_auimgr.Update(); + } +} + + +void FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ) +{ + m_selLayerBox->SetLayerSelection( GetActiveLayer() ); +} + + void FOOTPRINT_EDIT_FRAME::SyncToolbars() { #define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) ) @@ -206,7 +242,7 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars() TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon ); - TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout ); + TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::placeText ); TOGGLE_TOOL( m_drawToolBar, ACTIONS::deleteTool ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::setAnchor );