From 548334b4e2a24e472b97637c393dda2f3750b5c1 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 26 Feb 2025 03:22:49 +0000 Subject: [PATCH] Load toolbar configuration from settings --- 3d-viewer/3d_viewer/3d_toolbar.cpp | 87 ---- 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 5 +- 3d-viewer/3d_viewer/eda_3d_viewer_frame.h | 2 - 3d-viewer/3d_viewer/toolbars_3d.cpp | 98 ++++ 3d-viewer/3d_viewer/toolbars_3d.h | 40 ++ 3d-viewer/CMakeLists.txt | 2 +- common/eda_base_frame.cpp | 76 ++-- common/eda_draw_frame.cpp | 6 +- common/tool/action_toolbar.cpp | 18 + common/tool/ui/toolbar_configuration.cpp | 34 +- cvpcb/CMakeLists.txt | 1 + cvpcb/cvpcb_mainframe.cpp | 3 + cvpcb/cvpcb_mainframe.h | 2 - cvpcb/display_footprints_frame.cpp | 58 +-- cvpcb/display_footprints_frame.h | 4 - cvpcb/toolbars_cvpcb.cpp | 72 ++- cvpcb/toolbars_cvpcb.h | 47 ++ cvpcb/toolbars_display_footprints.cpp | 81 ++++ cvpcb/toolbars_display_footprints.h | 40 ++ eeschema/sch_edit_frame.cpp | 2 + eeschema/sch_edit_frame.h | 5 - eeschema/sim/simulator_frame.cpp | 3 + eeschema/sim/simulator_frame.h | 2 - eeschema/sim/toolbars_simulator_frame.cpp | 58 ++- eeschema/sim/toolbars_simulator_frame.h | 40 ++ eeschema/symbol_editor/symbol_edit_frame.cpp | 3 + eeschema/symbol_editor/symbol_edit_frame.h | 5 - .../symbol_editor/toolbars_symbol_editor.cpp | 178 ++++---- .../symbol_editor/toolbars_symbol_editor.h | 40 ++ eeschema/symbol_viewer_frame.cpp | 2 + eeschema/symbol_viewer_frame.h | 3 - eeschema/toolbars_sch_editor.cpp | 295 ++++++------ eeschema/toolbars_sch_editor.h | 41 ++ eeschema/toolbars_symbol_viewer.cpp | 68 +-- eeschema/toolbars_symbol_viewer.h | 41 ++ gerbview/gerbview_frame.cpp | 2 + gerbview/gerbview_frame.h | 5 - gerbview/toolbars_gerber.cpp | 166 ++++--- gerbview/toolbars_gerber.h | 51 +++ include/eda_base_frame.h | 44 +- include/eda_draw_frame.h | 3 - include/tool/action_toolbar.h | 53 ++- include/tool/ui/toolbar_configuration.h | 37 +- kicad/CMakeLists.txt | 1 + kicad/kicad_manager_frame.cpp | 2 + kicad/kicad_manager_frame.h | 3 - kicad/menubar.cpp | 23 - kicad/toolbars_kicad_manager.cpp | 60 +++ kicad/toolbars_kicad_manager.h | 40 ++ pagelayout_editor/pl_editor_frame.cpp | 2 + pagelayout_editor/pl_editor_frame.h | 5 - pagelayout_editor/toolbars_pl_editor.cpp | 135 +++--- pagelayout_editor/toolbars_pl_editor.h | 47 ++ pcbnew/CMakeLists.txt | 1 + pcbnew/footprint_edit_frame.cpp | 4 + pcbnew/footprint_edit_frame.h | 5 - pcbnew/footprint_viewer_frame.cpp | 3 + pcbnew/footprint_viewer_frame.h | 4 - pcbnew/footprint_wizard_frame.cpp | 48 +- pcbnew/footprint_wizard_frame.h | 3 - pcbnew/pcb_base_edit_frame.cpp | 4 +- pcbnew/pcb_base_edit_frame.h | 1 - pcbnew/pcb_edit_frame.cpp | 5 + pcbnew/pcb_edit_frame.h | 5 - pcbnew/toolbars_footprint_editor.cpp | 249 +++++----- pcbnew/toolbars_footprint_editor.h | 40 ++ pcbnew/toolbars_footprint_viewer.cpp | 85 ++-- pcbnew/toolbars_footprint_viewer.h | 40 ++ pcbnew/toolbars_footprint_wizard.cpp | 81 ++++ pcbnew/toolbars_footprint_wizard.h | 40 ++ pcbnew/toolbars_pcb_editor.cpp | 428 +++++++++--------- pcbnew/toolbars_pcb_editor.h | 48 ++ 72 files changed, 1975 insertions(+), 1260 deletions(-) delete mode 100644 3d-viewer/3d_viewer/3d_toolbar.cpp create mode 100644 3d-viewer/3d_viewer/toolbars_3d.cpp create mode 100644 3d-viewer/3d_viewer/toolbars_3d.h create mode 100644 cvpcb/toolbars_cvpcb.h create mode 100644 cvpcb/toolbars_display_footprints.cpp create mode 100644 cvpcb/toolbars_display_footprints.h create mode 100644 eeschema/sim/toolbars_simulator_frame.h create mode 100644 eeschema/symbol_editor/toolbars_symbol_editor.h create mode 100644 eeschema/toolbars_sch_editor.h create mode 100644 eeschema/toolbars_symbol_viewer.h create mode 100644 gerbview/toolbars_gerber.h create mode 100644 kicad/toolbars_kicad_manager.cpp create mode 100644 kicad/toolbars_kicad_manager.h create mode 100644 pagelayout_editor/toolbars_pl_editor.h create mode 100644 pcbnew/toolbars_footprint_editor.h create mode 100644 pcbnew/toolbars_footprint_viewer.h create mode 100644 pcbnew/toolbars_footprint_wizard.cpp create mode 100644 pcbnew/toolbars_footprint_wizard.h create mode 100644 pcbnew/toolbars_pcb_editor.h diff --git a/3d-viewer/3d_viewer/3d_toolbar.cpp b/3d-viewer/3d_viewer/3d_toolbar.cpp deleted file mode 100644 index 72523c6d4e..0000000000 --- a/3d-viewer/3d_viewer/3d_toolbar.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Mario Luzeiro - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 2023 CERN - * Copyright The 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include - -#include -#include -#include -#include -#include -#include <3d_viewer_id.h> - -std::optional EDA_3D_VIEWER_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( EDA_3D_ACTIONS::reloadBoard ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::copyToClipboard ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::toggleRaytacing ); - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::rotateXCW ) - .AppendAction( EDA_3D_ACTIONS::rotateXCCW ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::rotateYCW ) - .AppendAction( EDA_3D_ACTIONS::rotateYCCW ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::rotateZCW ) - .AppendAction( EDA_3D_ACTIONS::rotateZCCW ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::flipView ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::moveLeft ) - .AppendAction( EDA_3D_ACTIONS::moveRight ) - .AppendAction( EDA_3D_ACTIONS::moveUp ) - .AppendAction( EDA_3D_ACTIONS::moveDown ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::toggleOrtho ); - - config.AppendSeparator() - .AppendAction( EDA_3D_ACTIONS::showLayersManager ); - - // clang-format on - - return config; -} diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index 386e27720a..17ebe8e952 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include <3d_navlib/nl_3d_viewer_plugin.h> @@ -147,6 +148,8 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent m_toolManager->InvokeTool( "3DViewer.Control" ); ReCreateMenuBar(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); @@ -612,8 +615,6 @@ void EDA_3D_VIEWER_FRAME::CommonSettingsChanged( int aFlags ) // Regen menu bars, etc EDA_BASE_FRAME::CommonSettingsChanged( aFlags ); - RecreateToolbars(); - loadCommonSettings(); applySettings( Pgm().GetSettingsManager().GetAppSettings( "3d_viewer" ) ); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.h b/3d-viewer/3d_viewer/eda_3d_viewer_frame.h index 004ab0f088..ad10d426c0 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.h @@ -130,8 +130,6 @@ public: void OnDarkModeToggle(); - std::optional DefaultTopMainToolbarConfig() override; - /** * Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard diff --git a/3d-viewer/3d_viewer/toolbars_3d.cpp b/3d-viewer/3d_viewer/toolbars_3d.cpp new file mode 100644 index 0000000000..d0190924e7 --- /dev/null +++ b/3d-viewer/3d_viewer/toolbars_3d.cpp @@ -0,0 +1,98 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2016 Mario Luzeiro + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 2023 CERN + * Copyright The 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include +#include +#include +#include +#include +#include <3d_viewer_id.h> + +#include + + +std::optional EDA_3D_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) +{ + TOOLBAR_CONFIGURATION config; + + // clang-format off + switch( aToolbar ) + { + case TOOLBAR_LOC::LEFT: + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( EDA_3D_ACTIONS::reloadBoard ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::copyToClipboard ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::toggleRaytacing ); + + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::rotateXCW ) + .AppendAction( EDA_3D_ACTIONS::rotateXCCW ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::rotateYCW ) + .AppendAction( EDA_3D_ACTIONS::rotateYCCW ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::rotateZCW ) + .AppendAction( EDA_3D_ACTIONS::rotateZCCW ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::flipView ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::moveLeft ) + .AppendAction( EDA_3D_ACTIONS::moveRight ) + .AppendAction( EDA_3D_ACTIONS::moveUp ) + .AppendAction( EDA_3D_ACTIONS::moveDown ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::toggleOrtho ); + + config.AppendSeparator() + .AppendAction( EDA_3D_ACTIONS::showLayersManager ); + break; + } + + // clang-format on + return config; +} diff --git a/3d-viewer/3d_viewer/toolbars_3d.h b/3d-viewer/3d_viewer/toolbars_3d.h new file mode 100644 index 0000000000..6bb568b65d --- /dev/null +++ b/3d-viewer/3d_viewer/toolbars_3d.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_3D_H_ +#define TOOLBARS_3D_H_ + +#include + +/** + * Toolbar configuration for the 3D viewer. + */ +class EDA_3D_VIEWER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + EDA_3D_VIEWER_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "3d_viewer" ) + {} + + ~EDA_3D_VIEWER_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_3D_H_ */ diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt index 23a2c75b03..f73352c6e0 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -81,7 +81,7 @@ set(3D-VIEWER_SRCS 3d_rendering/test_cases.cpp 3d_rendering/trackball.cpp 3d_viewer/3d_menubar.cpp - 3d_viewer/3d_toolbar.cpp + 3d_viewer/toolbars_3d.cpp 3d_viewer/tools/eda_3d_actions.cpp 3d_viewer/tools/eda_3d_conditions.cpp 3d_viewer/tools/eda_3d_controller.cpp diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 41ed83c394..8c23641812 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -493,14 +493,10 @@ void EDA_BASE_FRAME::setupUIConditions() } -void EDA_BASE_FRAME::RegisterCustomToolbarControlFactory( const std::string& aName, const wxString& aUiName, - const wxString& aDescription, +void EDA_BASE_FRAME::RegisterCustomToolbarControlFactory( const ACTION_TOOLBAR_CONTROL& aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY& aControlFactory ) { - wxASSERT_MSG( aName.starts_with( "control" ), - wxString::Format( "Control name \"%s\" must start with \"control\"", aName ) ); - - m_toolbarControlFactories.emplace_back( aName, aUiName, aDescription, aControlFactory ); + m_toolbarControlFactories.emplace( aControlDesc.GetName(), aControlFactory ); } @@ -508,8 +504,8 @@ ACTION_TOOLBAR_CONTROL_FACTORY* EDA_BASE_FRAME::GetCustomToolbarControlFactory( { for( auto& control : m_toolbarControlFactories ) { - if( control.name == aName ) - return &control.factory; + if( control.first == aName ) + return &control.second; } return nullptr; @@ -518,37 +514,7 @@ ACTION_TOOLBAR_CONTROL_FACTORY* EDA_BASE_FRAME::GetCustomToolbarControlFactory( void EDA_BASE_FRAME::configureToolbars() { - APP_SETTINGS_BASE* cfg = config(); - - if( cfg && cfg->m_CustomToolbars ) - { - // Get the custom toolbar config - TOOLBAR_SETTINGS tb( cfg->GetFilename() + "-toolbars" ); - - tb.LoadFromFile( SETTINGS_MANAGER::GetToolbarSettingsPath() ); - - for( auto t : tb.m_Toolbars ) - { - if( t.first == "left" ) - m_tbConfigLeft = t.second; - else if( t.first == "right" ) - m_tbConfigRight = t.second; - else if( t.first == "top_aux" ) - m_tbConfigTopAux = t.second; - else if( t.first == "top_main" ) - m_tbConfigTopMain = t.second; - else - wxASSERT_MSG( false, wxString::Format( "Unknown toolbar: '%s'", t.first ) ); - } - } - else - { - // Get the default toolbar config for the frame - m_tbConfigLeft = DefaultLeftToolbarConfig(); - m_tbConfigRight = DefaultRightToolbarConfig(); - m_tbConfigTopAux = DefaultTopAuxToolbarConfig(); - m_tbConfigTopMain = DefaultTopMainToolbarConfig(); - } + m_toolbarSettings->LoadFromFile( Pgm().GetSettingsManager().GetToolbarSettingsPath() ); } @@ -556,8 +522,14 @@ void EDA_BASE_FRAME::RecreateToolbars() { wxWindowUpdateLocker dummy( this ); + wxASSERT( m_toolbarSettings.get() ); + + std::optional tbConfig; + // Drawing tools (typically on right edge of window) - if( m_tbConfigRight.has_value() ) + tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::RIGHT, config()->m_CustomToolbars ); + + if( tbConfig.has_value() ) { if( !m_tbRight ) { @@ -566,11 +538,13 @@ void EDA_BASE_FRAME::RecreateToolbars() m_tbRight->SetAuiManager( &m_auimgr ); } - m_tbRight->ApplyConfiguration( m_tbConfigRight.value() ); + m_tbRight->ApplyConfiguration( tbConfig.value() ); } // Options (typically on left edge of window) - if( m_tbConfigLeft.has_value() ) + tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::LEFT, config()->m_CustomToolbars ); + + if( tbConfig.has_value() ) { if( !m_tbLeft ) { @@ -579,11 +553,13 @@ void EDA_BASE_FRAME::RecreateToolbars() m_tbLeft->SetAuiManager( &m_auimgr ); } - m_tbLeft->ApplyConfiguration( m_tbConfigLeft.value() ); + m_tbLeft->ApplyConfiguration( tbConfig.value() ); } // Top main toolbar (the top one) - if( m_tbConfigTopMain.has_value() ) + tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_MAIN, config()->m_CustomToolbars ); + + if( tbConfig.has_value() ) { if( !m_tbTopMain ) { @@ -592,11 +568,13 @@ void EDA_BASE_FRAME::RecreateToolbars() m_tbTopMain->SetAuiManager( &m_auimgr ); } - m_tbTopMain->ApplyConfiguration( m_tbConfigTopMain.value() ); + m_tbTopMain->ApplyConfiguration( tbConfig.value() ); } // Top aux toolbar (the bottom one) - if( m_tbConfigTopAux.has_value() ) + tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_AUX, config()->m_CustomToolbars ); + + if( tbConfig.has_value() ) { if( !m_tbTopAux ) { @@ -605,7 +583,7 @@ void EDA_BASE_FRAME::RecreateToolbars() m_tbTopAux->SetAuiManager( &m_auimgr ); } - m_tbTopAux->ApplyConfiguration( m_tbConfigTopAux.value() ); + m_tbTopAux->ApplyConfiguration( tbConfig.value() ); } } @@ -745,6 +723,10 @@ void EDA_BASE_FRAME::CommonSettingsChanged( int aFlags ) ReCreateMenuBar(); GetMenuBar()->Refresh(); } + + // Update the toolbars by loading the settings from disk + m_toolbarSettings->LoadFromFile( Pgm().GetSettingsManager().GetToolbarSettingsPath() ); + RecreateToolbars(); } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index f3cd95a836..7be50ede2e 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -208,8 +208,7 @@ void EDA_DRAW_FRAME::configureToolbars() aToolbar->Add( m_gridSelectBox ); }; - RegisterCustomToolbarControlFactory( m_tbGridSelectName, _( "Grid Selector" ), - _( "Grid Selection box" ), gridSelectorFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::gridSelect, gridSelectorFactory ); // Zoom selection auto zoomSelectorFactory = @@ -225,8 +224,7 @@ void EDA_DRAW_FRAME::configureToolbars() aToolbar->Add( m_zoomSelectBox ); }; - RegisterCustomToolbarControlFactory( m_tbZoomSelectName, _( "Zoom Selector" ), - _( "Zoom selection box" ), zoomSelectorFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::zoomSelect, zoomSelectorFactory ); } diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index bbe0c1aad7..96816044e1 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -1024,3 +1024,21 @@ void ACTION_TOOLBAR::RefreshBitmaps() Refresh(); } + +/* + * Common controls for the toolbar + */ +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::gridSelect( "control.GridSelector", _( "Grid Selector" ), + _( "Grid Selection box" ) ); + +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::zoomSelect( "control.ZoomSelector", _( "Zoom Selector" ), + _( "Zoom Selection box" ) ); + +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::ipcScripting( "control.IPCPlugin", _( "IPC/Scripting plugins" ), + _( "Region to hold the IPC/Scripting action buttons" ) ); + +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::layerSelector( "control.LayerSelector", _( "Layer selector" ), + _( "Control to select the layer" ) ); + +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::unitSelector( "control.UnitSelector", _( "Symbol unit selector" ), + _( "Displays the current unit" ) ); diff --git a/common/tool/ui/toolbar_configuration.cpp b/common/tool/ui/toolbar_configuration.cpp index 7883d98c7e..c36fd5c651 100644 --- a/common/tool/ui/toolbar_configuration.cpp +++ b/common/tool/ui/toolbar_configuration.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include @@ -119,9 +120,9 @@ TOOLBAR_SETTINGS::TOOLBAR_SETTINGS( const wxString& aFullPath ) : // Serialize the toolbars nlohmann::json js = nlohmann::json::array(); - for( const auto& [name, tb] : m_Toolbars ) + for( const auto& [loc, tb] : m_toolbars ) { - js.push_back( nlohmann::json( { { "name", name }, + js.push_back( nlohmann::json( { { "name", magic_enum::enum_name( loc ) }, { "contents", tb } } ) ); } @@ -130,7 +131,7 @@ TOOLBAR_SETTINGS::TOOLBAR_SETTINGS( const wxString& aFullPath ) : [&]( const nlohmann::json& aObj ) { // Deserialize the toolbars - m_Toolbars.clear(); + m_toolbars.clear(); if( !aObj.is_array() ) return; @@ -140,10 +141,31 @@ TOOLBAR_SETTINGS::TOOLBAR_SETTINGS( const wxString& aFullPath ) : if( entry.empty() || !entry.is_object() ) continue; - m_Toolbars.emplace( - std::make_pair( entry["name"].get(), - entry["contents"].get() ) ); + auto loc = magic_enum::enum_cast( entry["name"].get(), + magic_enum::case_insensitive ); + + if( loc.has_value() ) + { + m_toolbars.emplace( + std::make_pair( loc.value(), + entry["contents"].get() ) ); + } } }, nlohmann::json::array() ) ); } + + +std::optional TOOLBAR_SETTINGS::GetToolbarConfig( TOOLBAR_LOC aToolbar, bool aAllowCustom ) +{ + // If custom is allowed, look for if a toolbar exists + if( aAllowCustom ) + { + auto tb = m_toolbars.find( aToolbar ); + + if( tb != m_toolbars.end() ) + return tb->second; + } + + return DefaultToolbarConfig( aToolbar ); +} diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 46d71a4f91..e1a0554be0 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -38,6 +38,7 @@ set( CVPCB_SRCS menubar.cpp readwrite_dlgs.cpp toolbars_cvpcb.cpp + toolbars_display_footprints.cpp tools/cvpcb_actions.cpp tools/cvpcb_association_tool.cpp tools/cvpcb_control.cpp diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 3b78d3337c..9d41e38fd8 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,8 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : setupTools(); setupUIConditions(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); ReCreateMenuBar(); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 0e5ad2b816..a026ae4b98 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -139,8 +139,6 @@ public: */ void OnSelectComponent( wxListEvent& event ); - std::optional DefaultTopMainToolbarConfig() override; - void ShowChangedLanguage() override; /** diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 0481da5ad2..17f4321532 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -54,6 +54,7 @@ #include // Shared conditions with other Pcbnew frames #include // shared tools with other Pcbnew frames #include +#include #include #include #include @@ -114,6 +115,8 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa m_toolManager->InitTools(); setupUIConditions(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); @@ -213,61 +216,6 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions() } -std::optional DISPLAY_FOOTPRINTS_FRAME::DefaultLeftToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( ACTIONS::selectionTool ) - .AppendAction( ACTIONS::measureTool ); - - config.AppendSeparator() - .AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::togglePolarCoords ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showPadNumbers ) - .AppendAction( PCB_ACTIONS::padDisplayMode ) - .AppendAction( PCB_ACTIONS::textOutlines ) - .AppendAction( PCB_ACTIONS::graphicsOutlines ); - - // clang-format on - return config; -} - - -std::optional DISPLAY_FOOTPRINTS_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); - - config.AppendSeparator() - .AppendAction( ACTIONS::show3DViewer ); - - config.AppendSeparator() - .AppendControl( m_tbGridSelectName ); - - config.AppendSeparator() - .AppendControl( m_tbZoomSelectName ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::fpAutoZoom ); - - // clang-format on - return config; -} - - void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { CVPCB_SETTINGS* cfg = dynamic_cast( aCfg ); diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index 0661537087..47090ca758 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -47,10 +47,6 @@ public: DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aParent ); ~DISPLAY_FOOTPRINTS_FRAME() override; - // Currently, no top aux or right toolbars - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - /** * Refresh the full display for this frame. * diff --git a/cvpcb/toolbars_cvpcb.cpp b/cvpcb/toolbars_cvpcb.cpp index 45d6924eab..bc1e920539 100644 --- a/cvpcb/toolbars_cvpcb.cpp +++ b/cvpcb/toolbars_cvpcb.cpp @@ -19,6 +19,8 @@ * with this program. If not, see . */ +#include + #include #include @@ -30,33 +32,43 @@ #include -std::optional CVPCB_MAINFRAME::DefaultTopMainToolbarConfig() +std::optional CVPCB_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( CVPCB_ACTIONS::saveAssociationsToSchematic ); + switch( aToolbar ) + { + case TOOLBAR_LOC::LEFT: + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - config.AppendSeparator() - .AppendAction( ACTIONS::showFootprintLibTable ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( CVPCB_ACTIONS::saveAssociationsToSchematic ); - config.AppendSeparator() - .AppendAction( CVPCB_ACTIONS::showFootprintViewer ); + config.AppendSeparator() + .AppendAction( ACTIONS::showFootprintLibTable ); - config.AppendSeparator() - .AppendAction( CVPCB_ACTIONS::gotoPreviousNA ) - .AppendAction( CVPCB_ACTIONS::gotoNextNA ); + config.AppendSeparator() + .AppendAction( CVPCB_ACTIONS::showFootprintViewer ); - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ) - .AppendAction( CVPCB_ACTIONS::autoAssociate ) - .AppendAction( CVPCB_ACTIONS::deleteAll ); + config.AppendSeparator() + .AppendAction( CVPCB_ACTIONS::gotoPreviousNA ) + .AppendAction( CVPCB_ACTIONS::gotoNextNA ); - // Add tools for footprint names filtering: - config.AppendSeparator() - .AppendSpacer( 15 ) - .AppendControl( "control.CVPCBFilters" ); + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ) + .AppendAction( CVPCB_ACTIONS::autoAssociate ) + .AppendAction( CVPCB_ACTIONS::deleteAll ); + + // Add tools for footprint names filtering: + config.AppendSeparator() + .AppendSpacer( 15 ) + .AppendControl( CVPCB_ACTION_TOOLBAR_CONTROLS::footprintFilter ); + break; + } // clang-format on return config; @@ -103,23 +115,9 @@ void CVPCB_MAINFRAME::configureToolbars() aToolbar->AddControl( m_tcFilterString ); }; - RegisterCustomToolbarControlFactory( "control.CVPCBFilters", _( "Footprint filters" ), - _( "Footprint filtering controls" ), - footprintFilterFactory ); - - TOOLBAR_SETTINGS tb( "cvpcb-toolbars" ); - - if( m_tbConfigLeft.has_value() ) - tb.m_Toolbars.emplace( "left", m_tbConfigLeft.value() ); - - if( m_tbConfigRight.has_value() ) - tb.m_Toolbars.emplace( "right", m_tbConfigRight.value() ); - - if( m_tbConfigTopAux.has_value() ) - tb.m_Toolbars.emplace( "top_aux", m_tbConfigTopAux.value() ); - - if( m_tbConfigTopMain.has_value() ) - tb.m_Toolbars.emplace( "top_main", m_tbConfigTopMain.value() ); - - tb.SaveToFile( SETTINGS_MANAGER::GetToolbarSettingsPath(), true ); + RegisterCustomToolbarControlFactory( CVPCB_ACTION_TOOLBAR_CONTROLS::footprintFilter, footprintFilterFactory ); } + + +ACTION_TOOLBAR_CONTROL CVPCB_ACTION_TOOLBAR_CONTROLS::footprintFilter( "control.FootprintFilters", _( "Footprint filters" ), + _( "Footprint filtering controls" ) ); diff --git a/cvpcb/toolbars_cvpcb.h b/cvpcb/toolbars_cvpcb.h new file mode 100644 index 0000000000..acbef3b4e2 --- /dev/null +++ b/cvpcb/toolbars_cvpcb.h @@ -0,0 +1,47 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_CVPCB_H_ +#define TOOLBARS_CVPCB_H_ + +#include +#include + +class CVPCB_ACTION_TOOLBAR_CONTROLS : public ACTION_TOOLBAR_CONTROLS +{ +public: + static ACTION_TOOLBAR_CONTROL footprintFilter; +}; + +/** + * Toolbar configuration for cvpcb. + */ +class CVPCB_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + CVPCB_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "cvpcb" ) + {} + + ~CVPCB_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_CVPCB_H_ */ diff --git a/cvpcb/toolbars_display_footprints.cpp b/cvpcb/toolbars_display_footprints.cpp new file mode 100644 index 0000000000..1d791ba6ab --- /dev/null +++ b/cvpcb/toolbars_display_footprints.cpp @@ -0,0 +1,81 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include + +#include +#include +#include +#include + +std::optional DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) +{ + TOOLBAR_CONFIGURATION config; + + // clang-format off + switch( aToolbar ) + { + // Currently, no top aux or right toolbars + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; + + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::selectionTool ) + .AppendAction( ACTIONS::measureTool ); + + config.AppendSeparator() + .AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::togglePolarCoords ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::showPadNumbers ) + .AppendAction( PCB_ACTIONS::padDisplayMode ) + .AppendAction( PCB_ACTIONS::textOutlines ) + .AppendAction( PCB_ACTIONS::graphicsOutlines ); + break; + + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); + + config.AppendSeparator() + .AppendAction( ACTIONS::show3DViewer ); + + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect ); + + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::fpAutoZoom ); + break; + } + + // clang-format on + return config; +} diff --git a/cvpcb/toolbars_display_footprints.h b/cvpcb/toolbars_display_footprints.h new file mode 100644 index 0000000000..386f0bdda2 --- /dev/null +++ b/cvpcb/toolbars_display_footprints.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + #ifndef TOOLBARS_DISPLAY_FOOTPRINTS_H_ + #define TOOLBARS_DISPLAY_FOOTPRINTS_H_ + +#include + +/** + * Toolbar configuration for the Display Footprints frame. + */ +class DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "display-footprints" ) + {} + + ~DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_DISPLAY_FOOTPRINTS_H_ */ diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 02d2ead955..6c4a302a7b 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -104,6 +104,7 @@ #include #include #include +#include #ifdef KICAD_IPC_API #include @@ -190,6 +191,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupUIConditions(); ReCreateMenuBar(); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index d6787fd209..719dc75005 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -176,11 +176,6 @@ public: void CreateScreens(); - // Currently no top auxillary toolbar - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultRightToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - void setupUIConditions() override; /** diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index 31ff17423b..5983b3922f 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include @@ -168,6 +169,8 @@ SIMULATOR_FRAME::SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // was created. m_tbTopMain->SetToolManager( m_toolManager ); + m_toolbarSettings = std::make_unique(); + configureToolbars(); RecreateToolbars(); ReCreateMenuBar(); diff --git a/eeschema/sim/simulator_frame.h b/eeschema/sim/simulator_frame.h index 8b1534aa25..562d5ba116 100644 --- a/eeschema/sim/simulator_frame.h +++ b/eeschema/sim/simulator_frame.h @@ -150,8 +150,6 @@ public: void ShowChangedLanguage() override; - std::optional DefaultTopMainToolbarConfig() override; - /** * Load plot, signal, cursor, measurement, etc. settings from a file. */ diff --git a/eeschema/sim/toolbars_simulator_frame.cpp b/eeschema/sim/toolbars_simulator_frame.cpp index 3b010e1212..642c56b354 100644 --- a/eeschema/sim/toolbars_simulator_frame.cpp +++ b/eeschema/sim/toolbars_simulator_frame.cpp @@ -18,6 +18,8 @@ * with this program. If not, see . */ +#include + #include #include #include @@ -27,38 +29,48 @@ #include -std::optional SIMULATOR_FRAME::DefaultTopMainToolbarConfig() +std::optional SIMULATOR_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( EE_ACTIONS::openWorkbook ) - .AppendAction( EE_ACTIONS::saveWorkbook ); + switch( aToolbar ) + { + case TOOLBAR_LOC::LEFT: + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - config.AppendSeparator() - .AppendAction( EE_ACTIONS::newAnalysisTab ) - .AppendAction( EE_ACTIONS::simAnalysisProperties ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( EE_ACTIONS::openWorkbook ) + .AppendAction( EE_ACTIONS::saveWorkbook ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::runSimulation ) - .AppendAction( EE_ACTIONS::stopSimulation ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::newAnalysisTab ) + .AppendAction( EE_ACTIONS::simAnalysisProperties ); - config.AppendSeparator() - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomInHorizontally ) - .AppendAction( ACTIONS::zoomOutHorizontally ) - .AppendAction( ACTIONS::zoomInVertically ) - .AppendAction( ACTIONS::zoomOutVertically ) - .AppendAction( ACTIONS::zoomFitScreen ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::runSimulation ) + .AppendAction( EE_ACTIONS::stopSimulation ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::simProbe ) - .AppendAction( EE_ACTIONS::simTune ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomInHorizontally ) + .AppendAction( ACTIONS::zoomOutHorizontally ) + .AppendAction( ACTIONS::zoomInVertically ) + .AppendAction( ACTIONS::zoomOutVertically ) + .AppendAction( ACTIONS::zoomFitScreen ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::editUserDefinedSignals ) - .AppendAction( EE_ACTIONS::showNetlist ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::simProbe ) + .AppendAction( EE_ACTIONS::simTune ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::editUserDefinedSignals ) + .AppendAction( EE_ACTIONS::showNetlist ); + break; + } // clang-format on return config; diff --git a/eeschema/sim/toolbars_simulator_frame.h b/eeschema/sim/toolbars_simulator_frame.h new file mode 100644 index 0000000000..90236d7948 --- /dev/null +++ b/eeschema/sim/toolbars_simulator_frame.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_SIMULATOR_FRAME_H_ +#define TOOLBARS_SIMULATOR_FRAME_H_ + +#include + +/** + * Toolbar configuration for the simulator frame. + */ +class SIMULATOR_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + SIMULATOR_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "sim" ) + {} + + ~SIMULATOR_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_SIMULATOR_FRAME_H_ */ diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 4ae48ff206..58b93f18b1 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -179,6 +180,8 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupUIConditions(); ReCreateMenuBar(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index ac30c3458d..44f9727e13 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -199,11 +199,6 @@ public: void doCloseWindow() override; void OnExitKiCad( wxCommandEvent& event ); - // Currently no top auxillary toolbar - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultRightToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index 85dc579d20..a46f6a3b22 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -44,117 +45,111 @@ #endif -std::optional SYMBOL_EDIT_FRAME::DefaultLeftToolbarConfig() +std::optional SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::toggleGridOverrides ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); + switch( aToolbar ) + { + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showElectricalTypes ) - .AppendAction( EE_ACTIONS::showHiddenPins ) - .AppendAction( EE_ACTIONS::showHiddenFields ); - // .AppendAction( EE_ACTIONS::togglePinAltIcons ); + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::toggleGridOverrides ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - config.AppendAction( ACTIONS::toggleBoundingBoxes ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showElectricalTypes ) + .AppendAction( EE_ACTIONS::showHiddenPins ) + .AppendAction( EE_ACTIONS::showHiddenFields ); + // .AppendAction( EE_ACTIONS::togglePinAltIcons ); - config.AppendSeparator() - .AppendAction( ACTIONS::showLibraryTree ) - .AppendAction( ACTIONS::showProperties ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + config.AppendAction( ACTIONS::toggleBoundingBoxes ); - /* TODO: Implement context menus - EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - std::unique_ptr gridMenu = std::make_unique( false, selTool ); - gridMenu->Add( ACTIONS::gridProperties ); - m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); - */ + config.AppendSeparator() + .AppendAction( ACTIONS::showLibraryTree ) + .AppendAction( ACTIONS::showProperties ); - // clang-format on - return config; -} + /* TODO: Implement context menus + EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + std::unique_ptr gridMenu = std::make_unique( false, selTool ); + gridMenu->Add( ACTIONS::gridProperties ); + m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + */ + break; + case TOOLBAR_LOC::RIGHT: + config.AppendAction( ACTIONS::selectionTool ); -std::optional SYMBOL_EDIT_FRAME::DefaultRightToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( EE_ACTIONS::placeSymbolPin ) + .AppendAction( EE_ACTIONS::placeSymbolText ) + .AppendAction( EE_ACTIONS::drawSymbolTextBox ) + .AppendAction( EE_ACTIONS::drawRectangle ) + .AppendAction( EE_ACTIONS::drawCircle ) + .AppendAction( EE_ACTIONS::drawArc ) + .AppendAction( EE_ACTIONS::drawBezier ) + .AppendAction( EE_ACTIONS::drawSymbolLines ) + .AppendAction( EE_ACTIONS::drawSymbolPolygon ) + .AppendAction( EE_ACTIONS::placeSymbolAnchor ) + .AppendAction( ACTIONS::deleteTool); + break; - // clang-format off - config.AppendAction( ACTIONS::selectionTool ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( EE_ACTIONS::newSymbol ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::placeSymbolPin ) - .AppendAction( EE_ACTIONS::placeSymbolText ) - .AppendAction( EE_ACTIONS::drawSymbolTextBox ) - .AppendAction( EE_ACTIONS::drawRectangle ) - .AppendAction( EE_ACTIONS::drawCircle ) - .AppendAction( EE_ACTIONS::drawArc ) - .AppendAction( EE_ACTIONS::drawBezier ) - .AppendAction( EE_ACTIONS::drawSymbolLines ) - .AppendAction( EE_ACTIONS::drawSymbolPolygon ) - .AppendAction( EE_ACTIONS::placeSymbolAnchor ) - .AppendAction( ACTIONS::deleteTool); +/* TODO (ISM): Handle visibility changes + if( !IsSymbolFromSchematic() ) + config.AppendAction( ACTIONS::saveAll ); + else + config.AppendAction( ACTIONS::save ); +*/ - // clang-format on - return config; -} + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); -std::optional SYMBOL_EDIT_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( EE_ACTIONS::rotateCCW ) + .AppendAction( EE_ACTIONS::rotateCW ) + .AppendAction( EE_ACTIONS::mirrorV ) + .AppendAction( EE_ACTIONS::mirrorH ); - // clang-format off - config.AppendAction( EE_ACTIONS::newSymbol ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::symbolProperties ) + .AppendAction( EE_ACTIONS::pinTable ); - if( !IsSymbolFromSchematic() ) - config.AppendAction( ACTIONS::saveAll ); - else - config.AppendAction( ACTIONS::save ); + config.AppendSeparator() + .AppendAction( ACTIONS::showDatasheet ) + .AppendAction( EE_ACTIONS::checkSymbol ); - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showDeMorganStandard ) + .AppendAction( EE_ACTIONS::showDeMorganAlternate ); - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::unitSelector ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::rotateCCW ) - .AppendAction( EE_ACTIONS::rotateCW ) - .AppendAction( EE_ACTIONS::mirrorV ) - .AppendAction( EE_ACTIONS::mirrorH ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::toggleSyncedPinsMode ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::symbolProperties ) - .AppendAction( EE_ACTIONS::pinTable ); - - config.AppendSeparator() - .AppendAction( ACTIONS::showDatasheet ) - .AppendAction( EE_ACTIONS::checkSymbol ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showDeMorganStandard ) - .AppendAction( EE_ACTIONS::showDeMorganAlternate ); - - config.AppendSeparator() - .AppendControl( "control.SymEditUnitSelector" ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::toggleSyncedPinsMode ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::addSymbolToSchematic ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::addSymbolToSchematic ); + break; + } // clang-format on return config; @@ -179,7 +174,6 @@ void SYMBOL_EDIT_FRAME::configureToolbars() aToolbar->Add( m_unitSelectBox ); }; - RegisterCustomToolbarControlFactory("control.SymEditUnitSelector", _( "Unit number display" ), - _( "Displays the unit being currently edited" ), - unitDisplayFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::unitSelector, unitDisplayFactory ); } + diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.h b/eeschema/symbol_editor/toolbars_symbol_editor.h new file mode 100644 index 0000000000..04532ddc66 --- /dev/null +++ b/eeschema/symbol_editor/toolbars_symbol_editor.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_CVPCB_H_ +#define TOOLBARS_CVPCB_H_ + +#include + +/** + * Toolbar configuration for the symbol editor frame. + */ +class SYMBOL_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + SYMBOL_EDIT_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "symbol_editor" ) + {} + + ~SYMBOL_EDIT_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_CVPCB_H_ */ diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 8418ba9a82..23c18a2dea 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -142,6 +143,7 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupTools(); setupUIConditions(); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); diff --git a/eeschema/symbol_viewer_frame.h b/eeschema/symbol_viewer_frame.h index 8031625653..8a64d72fbd 100644 --- a/eeschema/symbol_viewer_frame.h +++ b/eeschema/symbol_viewer_frame.h @@ -77,9 +77,6 @@ public: void doCloseWindow() override; void CloseLibraryViewer( wxCommandEvent& event ); - // Only top main toolbar - std::optional DefaultTopMainToolbarConfig() override; - void ClickOnLibList( wxCommandEvent& event ); void ClickOnSymbolList( wxCommandEvent& event ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index f6ad3eff7a..9503ef6003 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -42,166 +42,163 @@ #include #include #include +#include -std::optional SCH_EDIT_FRAME::DefaultLeftToolbarConfig() +std::optional SCH_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::toggleGridOverrides ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::toggleHiddenPins ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::lineModeFree ) - .AppendAction( EE_ACTIONS::lineMode90 ) - .AppendAction( EE_ACTIONS::lineMode45 ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::toggleAnnotateAuto ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showHierarchy ) - .AppendAction( ACTIONS::showProperties ); - - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - config.AppendAction( ACTIONS::toggleBoundingBoxes ); - - /* TODO (ISM): Handle context menus - EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - std::unique_ptr gridMenu = std::make_unique( false, selTool ); - gridMenu->Add( ACTIONS::gridProperties ); - m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); - */ - - // clang-format on - return config; -} - - -std::optional SCH_EDIT_FRAME::DefaultRightToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( ACTIONS::selectionTool ) - .AppendAction( EE_ACTIONS::highlightNetTool ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::placeSymbol ) - .AppendAction( EE_ACTIONS::placePower ) - .AppendAction( EE_ACTIONS::drawWire ) - .AppendAction( EE_ACTIONS::drawBus ) - .AppendAction( EE_ACTIONS::placeBusWireEntry ) - .AppendAction( EE_ACTIONS::placeNoConnect ) - .AppendAction( EE_ACTIONS::placeJunction ) - .AppendAction( EE_ACTIONS::placeLabel ) - .AppendAction( EE_ACTIONS::placeClassLabel ) - .AppendAction( EE_ACTIONS::drawRuleArea ) - .AppendAction( EE_ACTIONS::placeGlobalLabel ) - .AppendAction( EE_ACTIONS::placeHierLabel ) - .AppendAction( EE_ACTIONS::drawSheet ) - .AppendAction( EE_ACTIONS::placeSheetPin ) - .AppendAction( EE_ACTIONS::syncAllSheetsPins ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::placeSchematicText ) - .AppendAction( EE_ACTIONS::drawTextBox ) - .AppendAction( EE_ACTIONS::drawTable ) - .AppendAction( EE_ACTIONS::drawRectangle ) - .AppendAction( EE_ACTIONS::drawCircle ) - .AppendAction( EE_ACTIONS::drawArc ) - .AppendAction( EE_ACTIONS::drawBezier ) - .AppendAction( EE_ACTIONS::drawLines ) - .AppendAction( EE_ACTIONS::placeImage ) - .AppendAction( ACTIONS::deleteTool ); - - // clang-format on - return config; -} - - -std::optional SCH_EDIT_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - if( Kiface().IsSingle() ) // not when under a project mgr + switch( aToolbar ) { - config.AppendAction( ACTIONS::doNew ); - config.AppendAction( ACTIONS::open ); + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; + + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::toggleGridOverrides ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::toggleHiddenPins ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::lineModeFree ) + .AppendAction( EE_ACTIONS::lineMode90 ) + .AppendAction( EE_ACTIONS::lineMode45 ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::toggleAnnotateAuto ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showHierarchy ) + .AppendAction( ACTIONS::showProperties ); + + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + config.AppendAction( ACTIONS::toggleBoundingBoxes ); + + /* TODO (ISM): Handle context menus + EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + std::unique_ptr gridMenu = std::make_unique( false, selTool ); + gridMenu->Add( ACTIONS::gridProperties ); + m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + */ + break; + + case TOOLBAR_LOC::RIGHT: + config.AppendAction( ACTIONS::selectionTool ) + .AppendAction( EE_ACTIONS::highlightNetTool ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::placeSymbol ) + .AppendAction( EE_ACTIONS::placePower ) + .AppendAction( EE_ACTIONS::drawWire ) + .AppendAction( EE_ACTIONS::drawBus ) + .AppendAction( EE_ACTIONS::placeBusWireEntry ) + .AppendAction( EE_ACTIONS::placeNoConnect ) + .AppendAction( EE_ACTIONS::placeJunction ) + .AppendAction( EE_ACTIONS::placeLabel ) + .AppendAction( EE_ACTIONS::placeClassLabel ) + .AppendAction( EE_ACTIONS::drawRuleArea ) + .AppendAction( EE_ACTIONS::placeGlobalLabel ) + .AppendAction( EE_ACTIONS::placeHierLabel ) + .AppendAction( EE_ACTIONS::drawSheet ) + .AppendAction( EE_ACTIONS::placeSheetPin ) + .AppendAction( EE_ACTIONS::syncAllSheetsPins ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::placeSchematicText ) + .AppendAction( EE_ACTIONS::drawTextBox ) + .AppendAction( EE_ACTIONS::drawTable ) + .AppendAction( EE_ACTIONS::drawRectangle ) + .AppendAction( EE_ACTIONS::drawCircle ) + .AppendAction( EE_ACTIONS::drawArc ) + .AppendAction( EE_ACTIONS::drawBezier ) + .AppendAction( EE_ACTIONS::drawLines ) + .AppendAction( EE_ACTIONS::placeImage ) + .AppendAction( ACTIONS::deleteTool ); + + break; + + case TOOLBAR_LOC::TOP_MAIN: + if( Kiface().IsSingle() ) // not when under a project mgr + { + config.AppendAction( ACTIONS::doNew ); + config.AppendAction( ACTIONS::open ); + } + + config.AppendAction( ACTIONS::save ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::schematicSetup ); + + config.AppendSeparator() + .AppendAction( ACTIONS::pageSettings ) + .AppendAction( ACTIONS::print ) + .AppendAction( ACTIONS::plot ); + + config.AppendSeparator() + .AppendAction( ACTIONS::paste ); + + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ); + + config.AppendSeparator() + .AppendAction( ACTIONS::find ) + .AppendAction( ACTIONS::findAndReplace ); + + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomFitObjects ) + .AppendAction( ACTIONS::zoomTool ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::navigateBack ) + .AppendAction( EE_ACTIONS::navigateUp ) + .AppendAction( EE_ACTIONS::navigateForward ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::rotateCCW ) + .AppendAction( EE_ACTIONS::rotateCW ) + .AppendAction( EE_ACTIONS::mirrorV ) + .AppendAction( EE_ACTIONS::mirrorH ); + + config.AppendSeparator() + .AppendAction( ACTIONS::showSymbolEditor ) + .AppendAction( ACTIONS::showSymbolBrowser ) + .AppendAction( ACTIONS::showFootprintEditor ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::annotate ) + .AppendAction( EE_ACTIONS::runERC ) + .AppendAction( EE_ACTIONS::showSimulator ) + .AppendAction( EE_ACTIONS::assignFootprints ) + .AppendAction( EE_ACTIONS::editSymbolFields ) + .AppendAction( EE_ACTIONS::generateBOM ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showPcbNew ); + + // Insert all the IPC plugins here on the toolbar + // TODO (ISM): Move this to individual actions for each script + config.AppendControl( ACTION_TOOLBAR_CONTROLS::ipcScripting ); + + break; } - config.AppendAction( ACTIONS::save ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::schematicSetup ); - - config.AppendSeparator() - .AppendAction( ACTIONS::pageSettings ) - .AppendAction( ACTIONS::print ) - .AppendAction( ACTIONS::plot ); - - config.AppendSeparator() - .AppendAction( ACTIONS::paste ); - - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ); - - config.AppendSeparator() - .AppendAction( ACTIONS::find ) - .AppendAction( ACTIONS::findAndReplace ); - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomFitObjects ) - .AppendAction( ACTIONS::zoomTool ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::navigateBack ) - .AppendAction( EE_ACTIONS::navigateUp ) - .AppendAction( EE_ACTIONS::navigateForward ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::rotateCCW ) - .AppendAction( EE_ACTIONS::rotateCW ) - .AppendAction( EE_ACTIONS::mirrorV ) - .AppendAction( EE_ACTIONS::mirrorH ); - - config.AppendSeparator() - .AppendAction( ACTIONS::showSymbolEditor ) - .AppendAction( ACTIONS::showSymbolBrowser ) - .AppendAction( ACTIONS::showFootprintEditor ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::annotate ) - .AppendAction( EE_ACTIONS::runERC ) - .AppendAction( EE_ACTIONS::showSimulator ) - .AppendAction( EE_ACTIONS::assignFootprints ) - .AppendAction( EE_ACTIONS::editSymbolFields ) - .AppendAction( EE_ACTIONS::generateBOM ); - - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showPcbNew ); - - // Insert all the IPC plugins here on the toolbar - config.AppendControl( "control.SCHPlugin" ); - // clang-format on return config; } + void SCH_EDIT_FRAME::configureToolbars() { SCH_BASE_FRAME::configureToolbars(); @@ -231,8 +228,6 @@ void SCH_EDIT_FRAME::configureToolbars() } }; - RegisterCustomToolbarControlFactory( "control.SCHPlugin", _( "IPC/Scripting plugins" ), - _( "Region to hold the IPC/Scripting action buttons" ), - pluginControlFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::ipcScripting, pluginControlFactory ); } \ No newline at end of file diff --git a/eeschema/toolbars_sch_editor.h b/eeschema/toolbars_sch_editor.h new file mode 100644 index 0000000000..ef107008d2 --- /dev/null +++ b/eeschema/toolbars_sch_editor.h @@ -0,0 +1,41 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_SCH_EDITOR_H_ +#define TOOLBARS_SCH_EDITOR_H_ + +#include + +/** + * Toolbar configuration for the schematic editor frame. + */ +class SCH_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + SCH_EDIT_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "eeschema" ) + {} + + ~SCH_EDIT_TOOLBAR_SETTINGS + () {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_SCH_EDITOR_H_ */ diff --git a/eeschema/toolbars_symbol_viewer.cpp b/eeschema/toolbars_symbol_viewer.cpp index 02bde0fa63..50afa986aa 100644 --- a/eeschema/toolbars_symbol_viewer.cpp +++ b/eeschema/toolbars_symbol_viewer.cpp @@ -31,45 +31,55 @@ #include #include #include +#include - -std::optional SYMBOL_VIEWER_FRAME::DefaultTopMainToolbarConfig() +std::optional SYMBOL_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - /* TODO: Move these to actions - m_tbTopMain->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString, - KiScaledBitmap( BITMAPS::lib_previous, this ), - _( "Display previous symbol" ) ); + switch( aToolbar ) + { + case TOOLBAR_LOC::LEFT: + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - m_tbTopMain->AddTool( ID_LIBVIEW_NEXT, wxEmptyString, - KiScaledBitmap( BITMAPS::lib_next, this ), - _( "Display next symbol" ) ); - */ + case TOOLBAR_LOC::TOP_MAIN: + /* TODO (ISM): Move these to actions + m_tbTopMain->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString, + KiScaledBitmap( BITMAPS::lib_previous, this ), + _( "Display previous symbol" ) ); - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ); + m_tbTopMain->AddTool( ID_LIBVIEW_NEXT, wxEmptyString, + KiScaledBitmap( BITMAPS::lib_next, this ), + _( "Display next symbol" ) ); + */ - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showElectricalTypes ) - .AppendAction( EE_ACTIONS::showPinNumbers ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::showDeMorganStandard ) - .AppendAction( EE_ACTIONS::showDeMorganAlternate ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showElectricalTypes ) + .AppendAction( EE_ACTIONS::showPinNumbers ); - config.AppendSeparator() - .AppendControl( "control.SymViewUnitSelector" ); + config.AppendSeparator() + .AppendAction( EE_ACTIONS::showDeMorganStandard ) + .AppendAction( EE_ACTIONS::showDeMorganAlternate ); - config.AppendSeparator() - .AppendAction( ACTIONS::showDatasheet ); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::unitSelector ); - config.AppendSeparator() - .AppendAction( EE_ACTIONS::addSymbolToSchematic ); + config.AppendSeparator() + .AppendAction( ACTIONS::showDatasheet ); + + config.AppendSeparator() + .AppendAction( EE_ACTIONS::addSymbolToSchematic ); + break; + } // clang-format on return config; @@ -93,9 +103,7 @@ void SYMBOL_VIEWER_FRAME::configureToolbars() aToolbar->Add( m_unitChoice ); }; - RegisterCustomToolbarControlFactory("control.SymViewUnitSelector", _( "Symbol unit selector" ), - _( "Displays the unit being currently edited" ), - unitChoiceFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::unitSelector, unitChoiceFactory ); } diff --git a/eeschema/toolbars_symbol_viewer.h b/eeschema/toolbars_symbol_viewer.h new file mode 100644 index 0000000000..1cd45f7c07 --- /dev/null +++ b/eeschema/toolbars_symbol_viewer.h @@ -0,0 +1,41 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_SYMBOL_VIEWER_H_ +#define TOOLBARS_SYMBOL_VIEWER_H_ + +#include +#include + +/** + * Toolbar configuration for the symbol viewer frame. + */ +class SYMBOL_VIEWER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + SYMBOL_VIEWER_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "symbol_viewer" ) + {} + + ~SYMBOL_VIEWER_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_SYMBOL_VIEWER_H_ */ diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 277abf1213..836c6cf669 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -149,6 +150,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupUIConditions(); ReCreateMenuBar(); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 01a3a2d6a8..c00aa45540 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -76,11 +76,6 @@ public: bool LoadListOfGerberAndDrillFiles( const wxString& aPath, const wxArrayString& aFilenameList, std::vector* aFileType ); - // No right toolbar in gerbview - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - std::optional DefaultTopAuxToolbarConfig() override; - void UpdateStatusBar() override; GERBVIEW_SETTINGS* gvconfig() const; diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index cec801f345..b51c3e3f9e 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -34,91 +34,85 @@ #include #include "widgets/gbr_layer_box_selector.h" #include "widgets/dcode_selection_box.h" +#include -std::optional GERBVIEW_FRAME::DefaultLeftToolbarConfig() +std::optional GERBVIEW_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::selectionTool ) - .AppendAction( ACTIONS::measureTool ); + switch( aToolbar ) + { + // No right toolbar + case TOOLBAR_LOC::RIGHT: + return std::nullopt; - config.AppendSeparator() - .AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::togglePolarCoords ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::selectionTool ) + .AppendAction( ACTIONS::measureTool ); - config.AppendSeparator() - .AppendAction( GERBVIEW_ACTIONS::flashedDisplayOutlines ) - .AppendAction( GERBVIEW_ACTIONS::linesDisplayOutlines ) - .AppendAction( GERBVIEW_ACTIONS::polygonsDisplayOutlines ) - .AppendAction( GERBVIEW_ACTIONS::negativeObjectDisplay ) - .AppendAction( GERBVIEW_ACTIONS::dcodeDisplay ); + config.AppendSeparator() + .AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::togglePolarCoords ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); - config.AppendSeparator() - .AppendAction( GERBVIEW_ACTIONS::toggleForceOpacityMode ) - .AppendAction( GERBVIEW_ACTIONS::toggleXORMode ) - .AppendAction( ACTIONS::highContrastMode ) - .AppendAction( GERBVIEW_ACTIONS::flipGerberView ); + config.AppendSeparator() + .AppendAction( GERBVIEW_ACTIONS::flashedDisplayOutlines ) + .AppendAction( GERBVIEW_ACTIONS::linesDisplayOutlines ) + .AppendAction( GERBVIEW_ACTIONS::polygonsDisplayOutlines ) + .AppendAction( GERBVIEW_ACTIONS::negativeObjectDisplay ) + .AppendAction( GERBVIEW_ACTIONS::dcodeDisplay ); - config.AppendSeparator() - .AppendAction( GERBVIEW_ACTIONS::toggleLayerManager ); + config.AppendSeparator() + .AppendAction( GERBVIEW_ACTIONS::toggleForceOpacityMode ) + .AppendAction( GERBVIEW_ACTIONS::toggleXORMode ) + .AppendAction( ACTIONS::highContrastMode ) + .AppendAction( GERBVIEW_ACTIONS::flipGerberView ); - // clang-format on - return config; -} + config.AppendSeparator() + .AppendAction( GERBVIEW_ACTIONS::toggleLayerManager ); + break; + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( GERBVIEW_ACTIONS::clearAllLayers ) + .AppendAction( GERBVIEW_ACTIONS::reloadAllLayers ) + .AppendAction( GERBVIEW_ACTIONS::openAutodetected ) + .AppendAction( GERBVIEW_ACTIONS::openGerber ) + .AppendAction( GERBVIEW_ACTIONS::openDrillFile ); -std::optional GERBVIEW_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( ACTIONS::print ); - // clang-format off - config.AppendAction( GERBVIEW_ACTIONS::clearAllLayers ) - .AppendAction( GERBVIEW_ACTIONS::reloadAllLayers ) - .AppendAction( GERBVIEW_ACTIONS::openAutodetected ) - .AppendAction( GERBVIEW_ACTIONS::openGerber ) - .AppendAction( GERBVIEW_ACTIONS::openDrillFile ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); - config.AppendSeparator() - .AppendAction( ACTIONS::print ); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::layerSelector ) + .AppendControl( GERBVIEW_ACTION_TOOLBAR_CONTROLS::textInfo ); + break; - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); - - config.AppendSeparator() - .AppendControl( "control.GerberLayerBox" ) - .AppendControl( "control.GerberTextInfo" ); - - // clang-format on - return config; -} - - -std::optional GERBVIEW_FRAME::DefaultTopAuxToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendControl( "control.GerberComponentHighlight" ) - .AppendSpacer( 5 ) - .AppendControl( "control.GerberNetHighlight" ) - .AppendSpacer( 5 ) - .AppendControl( "control.GerberAppertureHighlight" ) - .AppendSpacer( 5 ) - .AppendControl( "control.GerberDcodeSelector" ) - .AppendSeparator() - .AppendControl( m_tbGridSelectName ) - .AppendSeparator() - .AppendControl( m_tbZoomSelectName ); + case TOOLBAR_LOC::TOP_AUX: + config.AppendControl( GERBVIEW_ACTION_TOOLBAR_CONTROLS::componentHighlight ) + .AppendSpacer( 5 ) + .AppendControl( GERBVIEW_ACTION_TOOLBAR_CONTROLS::netHighlight ) + .AppendSpacer( 5 ) + .AppendControl( GERBVIEW_ACTION_TOOLBAR_CONTROLS::appertureHighlight ) + .AppendSpacer( 5 ) + .AppendControl( GERBVIEW_ACTION_TOOLBAR_CONTROLS::dcodeSelector ) + .AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect ) + .AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ); + break; + } // clang-format on return config; @@ -157,8 +151,7 @@ void GERBVIEW_FRAME::configureToolbars() m_SelLayerBox->GetId() ); }; - RegisterCustomToolbarControlFactory("control.GerberLayerBox", _( "Layer selector widget" ), - _( "Layer selection" ), layerBoxFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::layerSelector, layerBoxFactory ); auto textInfoFactory = @@ -173,8 +166,7 @@ void GERBVIEW_FRAME::configureToolbars() aToolbar->Add( m_TextInfo ); }; - RegisterCustomToolbarControlFactory("control.GerberTextInfo", _( "Text info entry" ), - _( "Text info entry" ), textInfoFactory ); + RegisterCustomToolbarControlFactory( GERBVIEW_ACTION_TOOLBAR_CONTROLS::textInfo, textInfoFactory ); // Creates box to display and choose components: @@ -198,10 +190,7 @@ void GERBVIEW_FRAME::configureToolbars() aToolbar->Add( m_SelComponentBox ); }; - RegisterCustomToolbarControlFactory( "control.GerberComponentHighlight", - _( "Component highlight" ), - _( "Highlight items belonging to this component" ), - componentBoxFactory ); + RegisterCustomToolbarControlFactory( GERBVIEW_ACTION_TOOLBAR_CONTROLS::componentHighlight, componentBoxFactory ); // Creates choice box to display net names and highlight selected: @@ -223,8 +212,7 @@ void GERBVIEW_FRAME::configureToolbars() aToolbar->Add( m_SelNetnameBox ); }; - RegisterCustomToolbarControlFactory( "control.GerberNetHighlight", _( "Net highlight" ), - _( "Highlight items belonging to this net" ), netBoxFactory ); + RegisterCustomToolbarControlFactory( GERBVIEW_ACTION_TOOLBAR_CONTROLS::netHighlight, netBoxFactory ); // Creates choice box to display aperture attributes and highlight selected: @@ -249,9 +237,7 @@ void GERBVIEW_FRAME::configureToolbars() aToolbar->Add( m_SelAperAttributesBox ); }; - RegisterCustomToolbarControlFactory( "control.GerberAppertureHighlight", _( "Aperture highlight" ), - _( "Highlight items with this aperture attribute" ), - appertureBoxFactory ); + RegisterCustomToolbarControlFactory( GERBVIEW_ACTION_TOOLBAR_CONTROLS::appertureHighlight, appertureBoxFactory ); // D-code selection @@ -276,11 +262,21 @@ void GERBVIEW_FRAME::configureToolbars() aToolbar->Add( m_DCodeSelector ); }; - RegisterCustomToolbarControlFactory( "control.GerberDcodeSelector", _( "DCode Selector" ), - _( "Select all items with the selected DCode" ), - dcodeSelectorFactory ); + RegisterCustomToolbarControlFactory( GERBVIEW_ACTION_TOOLBAR_CONTROLS::dcodeSelector, dcodeSelectorFactory ); } +ACTION_TOOLBAR_CONTROL GERBVIEW_ACTION_TOOLBAR_CONTROLS::textInfo( "control.TextInfo", _( "Text info entry" ), + _( "Text info entry" ) ); +ACTION_TOOLBAR_CONTROL GERBVIEW_ACTION_TOOLBAR_CONTROLS::componentHighlight( "control.ComponentHighlight", + _( "Component highlight" ), + _( "Highlight items belonging to this component" ) ); +ACTION_TOOLBAR_CONTROL GERBVIEW_ACTION_TOOLBAR_CONTROLS::netHighlight( "control.NetHighlight", _( "Net highlight" ), + _( "Highlight items belonging to this net" ) ); +ACTION_TOOLBAR_CONTROL GERBVIEW_ACTION_TOOLBAR_CONTROLS::appertureHighlight( "control.AppertureHighlight", _( "Aperture highlight" ), + _( "Highlight items with this aperture attribute" )); +ACTION_TOOLBAR_CONTROL GERBVIEW_ACTION_TOOLBAR_CONTROLS::dcodeSelector( "control.GerberDcodeSelector", _( "DCode Selector" ), + _( "Select all items with the selected DCode" ) ); + #define NO_SELECTION_STRING _("") diff --git a/gerbview/toolbars_gerber.h b/gerbview/toolbars_gerber.h new file mode 100644 index 0000000000..4d8185037e --- /dev/null +++ b/gerbview/toolbars_gerber.h @@ -0,0 +1,51 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_GERBER_H_ +#define TOOLBARS_GERBER_H_ + +#include +#include + +class GERBVIEW_ACTION_TOOLBAR_CONTROLS : public ACTION_TOOLBAR_CONTROLS +{ +public: + static ACTION_TOOLBAR_CONTROL textInfo; + static ACTION_TOOLBAR_CONTROL componentHighlight; + static ACTION_TOOLBAR_CONTROL netHighlight; + static ACTION_TOOLBAR_CONTROL appertureHighlight; + static ACTION_TOOLBAR_CONTROL dcodeSelector; +}; + +/** + * Toolbar configuration for gerbview. + */ +class GERBVIEW_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + GERBVIEW_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "gerbview" ) + {} + + ~GERBVIEW_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_GERBER_H_ */ diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index b2434f2e7e..4cfd07b39d 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -436,34 +436,6 @@ public: */ virtual wxString GetCurrentFileName() const { return wxEmptyString; } - /** - * Get the default actions to show on the left canvas toolbar. - * - * @return default config, or nullopt if the toolbar isn't used. - */ - virtual std::optional DefaultLeftToolbarConfig() { return std::nullopt; }; - - /** - * Get the default actions to show on the right canvas toolbar. - * - * @return default config, or nullopt if the toolbar isn't used. - */ - virtual std::optional DefaultRightToolbarConfig() { return std::nullopt; }; - - /** - * Get the default actions to show on the top main canvas toolbar. - * - * @return default config, or nullopt if the toolbar isn't used. - */ - virtual std::optional DefaultTopMainToolbarConfig() { return std::nullopt; }; - - /** - * Get the default actions to show on the top aux canvas toolbar. - * - * @return default config, or nullopt if the toolbar isn't used. - */ - virtual std::optional DefaultTopAuxToolbarConfig() { return std::nullopt; }; - virtual void RecreateToolbars(); /** @@ -482,12 +454,10 @@ public: * The factory function takes a single argument of type `ACTION_TOOLBAR*`, which is the toolbar * to add the controls to. * - * @param aName is the unique name for this control - must be prefixed with "control." - * @param aDescription is a short user-facing description for the + * @param aControlDesc is the control descriptor * @param aControlFactory A functor that creates the custom controls and then adds them to the toolbar */ - void RegisterCustomToolbarControlFactory( const std::string& aName, const wxString& aUiName, - const wxString& aDescription, + void RegisterCustomToolbarControlFactory( const ACTION_TOOLBAR_CONTROL& aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY& aControlFactory ); /** @@ -860,11 +830,8 @@ private: */ std::map m_acceptedExts; - // Current toolbar configuration - std::optional m_tbConfigLeft; - std::optional m_tbConfigRight; - std::optional m_tbConfigTopAux; - std::optional m_tbConfigTopMain; + // Toolbar Settings + std::unique_ptr m_toolbarSettings; // Toolbar UI elements ACTION_TOOLBAR* m_tbTopMain; @@ -872,8 +839,7 @@ private: ACTION_TOOLBAR* m_tbRight; // Drawing tools (typically on right edge of window) ACTION_TOOLBAR* m_tbLeft; // Options (typically on left edge of window) - std::vector m_toolbarControlFactories; - + std::map m_toolbarControlFactories; }; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 37ed1fa420..b0eabc43f4 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -594,9 +594,6 @@ protected: static bool m_openGLFailureOccured; ///< Has any failure occurred when switching to OpenGL in ///< any EDA_DRAW_FRAME? - const std::string m_tbGridSelectName = "control.GridSelector"; - const std::string m_tbZoomSelectName = "control.ZoomSelector"; - private: BASE_SCREEN* m_currentScreen; ///< current used SCREEN EDA_DRAW_PANEL_GAL* m_canvas; diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index d1580819b6..de48d293d4 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -188,6 +188,8 @@ protected: std::map m_buttons; }; +// Forward declare this because the toolbar wants it +class ACTION_TOOLBAR_CONTROL; /** * Define the structure of a toolbar with buttons that invoke ACTIONs. @@ -340,6 +342,15 @@ public: */ void RefreshBitmaps(); + /** + * Get the list of custom controls that could be used on toolbars. + */ + static std::list& GetCustomControlList() + { + static std::list m_controls; + return m_controls; + } + static constexpr bool TOGGLE = true; static constexpr bool CANCEL = true; @@ -409,27 +420,53 @@ protected: */ typedef std::function ACTION_TOOLBAR_CONTROL_FACTORY; -struct ACTION_TOOLBAR_CONTROL + +/** + * Class to hold basic information about controls that can be added to the toolbars. + */ +class ACTION_TOOLBAR_CONTROL { +public: + ACTION_TOOLBAR_CONTROL( std::string aName, wxString aUiName, wxString aDescription ) : + m_name( aName ), + m_uiname( aUiName ), + m_description( aDescription ) + { + wxASSERT_MSG( aName.starts_with( "control" ), + wxString::Format( "Control name \"%s\" must start with \"control\"", aName ) ); + + ACTION_TOOLBAR::GetCustomControlList().push_back( this ); + } + + const std::string& GetName() const { return m_name; } + const wxString& GetUiName() const { return m_uiname; } + const wxString& GetDescription() const { return m_description; } + +protected: /** * Name of the control - must start with "control." */ - std::string name; + std::string m_name; /** * Short description to show for the control */ - wxString uiname; + wxString m_uiname; /** * User-visible tooltip for the control */ - wxString description; + wxString m_description; +}; - /** - * Factory function to create the control when required - */ - ACTION_TOOLBAR_CONTROL_FACTORY factory; +class ACTION_TOOLBAR_CONTROLS +{ +public: + static ACTION_TOOLBAR_CONTROL gridSelect; + static ACTION_TOOLBAR_CONTROL zoomSelect; + static ACTION_TOOLBAR_CONTROL ipcScripting; + static ACTION_TOOLBAR_CONTROL unitSelector; + static ACTION_TOOLBAR_CONTROL layerSelector; }; #endif diff --git a/include/tool/ui/toolbar_configuration.h b/include/tool/ui/toolbar_configuration.h index 91e2739577..10c94d42ca 100644 --- a/include/tool/ui/toolbar_configuration.h +++ b/include/tool/ui/toolbar_configuration.h @@ -30,6 +30,7 @@ #include #include +#include #include @@ -110,12 +111,19 @@ public: return *this; } + TOOLBAR_CONFIGURATION& AppendControl( std::string aControlName ) { m_toolbarItems.push_back( aControlName ); return *this; } + TOOLBAR_CONFIGURATION& AppendControl( const ACTION_TOOLBAR_CONTROL& aControl ) + { + m_toolbarItems.push_back( aControl.GetName() ); + return *this; + } + std::vector GetToolbarItems() const { return m_toolbarItems; @@ -146,6 +154,14 @@ public: }; +enum class TOOLBAR_LOC +{ + LEFT, ///< Toolbar on the left side of the canvas + RIGHT, ///< Toolbar on the right side of the canvas + TOP_MAIN, ///< Toolbar on the top of the canvas + TOP_AUX ///< Toolbar on the top of the canvas +}; + class KICOMMON_API TOOLBAR_SETTINGS : public JSON_SETTINGS { public: @@ -153,9 +169,24 @@ public: virtual ~TOOLBAR_SETTINGS() {} -public: - // The toolbars - std::map m_Toolbars; + /** + * Get the default tools to show on the specified canvas toolbar. + */ + virtual std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) + { + return std::nullopt; + } + + /** + * Get the tools to show on the specified canvas toolbar. + * + * Returns the user-configured tools, and if not customized, the default tools. + */ + std::optional GetToolbarConfig( TOOLBAR_LOC aToolbar, bool aForceDefault ); + +protected: + // The toolbars - only public to aid in JSON serialization/deserialization + std::map m_toolbars; }; #endif /* TOOLBAR_CONFIGURATION_H_ */ diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index be03121b73..2a0c0285b3 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -44,6 +44,7 @@ set( KICAD_SRCS project_tree.cpp project_tree_item.cpp update_manager.cpp + toolbars_kicad_manager.cpp tools/kicad_manager_actions.cpp tools/kicad_manager_control.cpp ) diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 38cc043f91..836bac33f3 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -201,6 +202,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl setupTools(); setupUIConditions(); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); ReCreateMenuBar(); diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index 1ce91e929f..990aaa29f2 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -194,9 +194,6 @@ public: // Used only on Windows: stores the info message about file watcher wxString m_FileWatcherInfo; - // Toolbar defaults - std::optional DefaultLeftToolbarConfig() override; - DECLARE_EVENT_TABLE() protected: diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 98a5203d01..be9eae9ba0 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -228,26 +228,3 @@ void KICAD_MANAGER_FRAME::doReCreateMenuBar() SetMenuBar( menuBar ); delete oldMenuBar; } - - -std::optional KICAD_MANAGER_FRAME::DefaultLeftToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( KICAD_MANAGER_ACTIONS::newProject ) - .AppendAction( KICAD_MANAGER_ACTIONS::openProject ); - - config.AppendSeparator() - .AppendAction( KICAD_MANAGER_ACTIONS::archiveProject ) - .AppendAction( KICAD_MANAGER_ACTIONS::unarchiveProject ); - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ); - - config.AppendSeparator() - .AppendAction( KICAD_MANAGER_ACTIONS::openProjectDirectory ); - - // clang-format on - return config; -} diff --git a/kicad/toolbars_kicad_manager.cpp b/kicad/toolbars_kicad_manager.cpp new file mode 100644 index 0000000000..f18d4f561d --- /dev/null +++ b/kicad/toolbars_kicad_manager.cpp @@ -0,0 +1,60 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + + +std::optional KICAD_MANAGER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) +{ + TOOLBAR_CONFIGURATION config; + + // clang-format off + switch( aToolbar ) + { + // No other toolbars + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + case TOOLBAR_LOC::TOP_MAIN: + return std::nullopt; + + case TOOLBAR_LOC::LEFT: + config.AppendAction( KICAD_MANAGER_ACTIONS::newProject ) + .AppendAction( KICAD_MANAGER_ACTIONS::openProject ); + + config.AppendSeparator() + .AppendAction( KICAD_MANAGER_ACTIONS::archiveProject ) + .AppendAction( KICAD_MANAGER_ACTIONS::unarchiveProject ); + + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ); + + config.AppendSeparator() + .AppendAction( KICAD_MANAGER_ACTIONS::openProjectDirectory ); + + break; + } + + // clang-format on + return config; +} diff --git a/kicad/toolbars_kicad_manager.h b/kicad/toolbars_kicad_manager.h new file mode 100644 index 0000000000..94b30cd894 --- /dev/null +++ b/kicad/toolbars_kicad_manager.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_KICAD_MANAGER_H_ +#define TOOLBARS_KICAD_MANAGER_H_ + +#include + +/** + * Toolbar configuration for the project manager frame. + */ +class KICAD_MANAGER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + KICAD_MANAGER_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "kicad" ) + {} + + ~KICAD_MANAGER_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_KICAD_MANAGER_H_ */ diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index deb04709b2..daf474dd5c 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -49,6 +49,7 @@ #include "pl_editor_id.h" #include "pl_editor_settings.h" #include "properties_frame.h" +#include #include "tools/pl_actions.h" #include "tools/pl_selection_tool.h" #include "tools/pl_drawing_tools.h" @@ -135,6 +136,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupUIConditions(); ReCreateMenuBar(); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index b9b5b47b58..ac191d8614 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -98,11 +98,6 @@ public: // The Tool Framework initialization void setupTools(); - // Currently no top auxillary toolbar - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultRightToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - void UpdateToolbarControlSizes() override; void SetPageSettings(const PAGE_INFO&) override; diff --git a/pagelayout_editor/toolbars_pl_editor.cpp b/pagelayout_editor/toolbars_pl_editor.cpp index 9cf6852fa4..27f6f70f6e 100644 --- a/pagelayout_editor/toolbars_pl_editor.cpp +++ b/pagelayout_editor/toolbars_pl_editor.cpp @@ -28,87 +28,81 @@ #include "pl_editor_id.h" #include "pl_editor_frame.h" +#include -std::optional PL_EDITOR_FRAME::DefaultLeftToolbarConfig() +std::optional PL_EDITOR_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ); + switch( aToolbar ) + { + // No aux toolbar + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - /* TODO: Implement context menus - PL_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - std::unique_ptr gridMenu = std::make_unique( false, selTool ); - gridMenu->Add( ACTIONS::gridProperties ); - m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); - */ + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ); - // clang-format on - return config; -} + /* TODO: Implement context menus + PL_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + std::unique_ptr gridMenu = std::make_unique( false, selTool ); + gridMenu->Add( ACTIONS::gridProperties ); + m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + */ + break; + case TOOLBAR_LOC::RIGHT: + config.AppendAction( ACTIONS::selectionTool ); -std::optional PL_EDITOR_FRAME::DefaultRightToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( PL_ACTIONS::drawLine ) + .AppendAction( PL_ACTIONS::drawRectangle ) + .AppendAction( PL_ACTIONS::placeText ) + .AppendAction( PL_ACTIONS::placeImage ) + .AppendAction( PL_ACTIONS::appendImportedDrawingSheet ); - // clang-format off - config.AppendAction( ACTIONS::selectionTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::deleteTool ); + break; - config.AppendSeparator() - .AppendAction( PL_ACTIONS::drawLine ) - .AppendAction( PL_ACTIONS::drawRectangle ) - .AppendAction( PL_ACTIONS::placeText ) - .AppendAction( PL_ACTIONS::placeImage ) - .AppendAction( PL_ACTIONS::appendImportedDrawingSheet ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( ACTIONS::doNew ) + .AppendAction( ACTIONS::open ) + .AppendAction( ACTIONS::save ); - config.AppendSeparator() - .AppendAction( ACTIONS::deleteTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::print ); - // clang-format on - return config; -} + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); -std::optional PL_EDITOR_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( PL_ACTIONS::showInspector ) + .AppendAction( PL_ACTIONS::previewSettings ); - // clang-format off - config.AppendAction( ACTIONS::doNew ) - .AppendAction( ACTIONS::open ) - .AppendAction( ACTIONS::save ); + // Display mode switch + config.AppendSeparator() + .AppendAction( PL_ACTIONS::layoutNormalMode ) + .AppendAction( PL_ACTIONS::layoutEditMode ); - config.AppendSeparator() - .AppendAction( ACTIONS::print ); - - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ); - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); - - config.AppendSeparator() - .AppendAction( PL_ACTIONS::showInspector ) - .AppendAction( PL_ACTIONS::previewSettings ); - - // Display mode switch - config.AppendSeparator() - .AppendAction( PL_ACTIONS::layoutNormalMode ) - .AppendAction( PL_ACTIONS::layoutEditMode ); - - config.AppendSeparator() - .AppendControl( "control.PLEditorOrigin" ) - .AppendControl( "control.PLEditorPageSelect" ); + config.AppendSeparator() + .AppendControl( PL_EDITOR_ACTION_TOOLBAR_CONTROLS::originSelector ) + .AppendControl( PL_EDITOR_ACTION_TOOLBAR_CONTROLS::pageSelect ); + break; + } // clang-format on return config; @@ -134,9 +128,7 @@ void PL_EDITOR_FRAME::configureToolbars() aToolbar->Add( m_originSelectBox ); }; - RegisterCustomToolbarControlFactory( "control.PLEditorOrigin", _( "Origin Selector" ), - _( "Select the origin of the status bar coordinates" ), - originSelectorFactory ); + RegisterCustomToolbarControlFactory( PL_EDITOR_ACTION_TOOLBAR_CONTROLS::originSelector, originSelectorFactory ); auto pageSelectorFactory = @@ -161,12 +153,17 @@ void PL_EDITOR_FRAME::configureToolbars() aToolbar->Add( m_pageSelectBox ); }; - RegisterCustomToolbarControlFactory( "control.PLEditorPageSelect", _( "Page Selector" ), - _( "Select the page to simulate item displays" ), - pageSelectorFactory ); + RegisterCustomToolbarControlFactory( PL_EDITOR_ACTION_TOOLBAR_CONTROLS::pageSelect, pageSelectorFactory ); } +ACTION_TOOLBAR_CONTROL PL_EDITOR_ACTION_TOOLBAR_CONTROLS::originSelector( "control.OriginSelector", _( "Origin Selector" ), + _( "Select the origin of the status bar coordinates" ) ); +ACTION_TOOLBAR_CONTROL PL_EDITOR_ACTION_TOOLBAR_CONTROLS::pageSelect( "control.PageSelect", _( "Page Selector" ), + _( "Select the page to simulate item displays" )); + + + void PL_EDITOR_FRAME::UpdateToolbarControlSizes() { // Ensure the origin selector is a minimum size diff --git a/pagelayout_editor/toolbars_pl_editor.h b/pagelayout_editor/toolbars_pl_editor.h new file mode 100644 index 0000000000..ca97657ef1 --- /dev/null +++ b/pagelayout_editor/toolbars_pl_editor.h @@ -0,0 +1,47 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_PL_EDITOR_H_ +#define TOOLBARS_PL_EDITOR_H_ + +#include +#include + +class PL_EDITOR_ACTION_TOOLBAR_CONTROLS : public ACTION_TOOLBAR_CONTROLS +{ +public: + static ACTION_TOOLBAR_CONTROL originSelector; + static ACTION_TOOLBAR_CONTROL pageSelect; +}; + +/** + * Toolbar configuration for the page layout editor frame. + */ +class PL_EDITOR_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + PL_EDITOR_TOOLBAR_SETTINGS() : TOOLBAR_SETTINGS( "pl_editor" ) + {} + + ~PL_EDITOR_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_PL_EDITOR_H_ */ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index effa09bdcd..bf9e1a8b20 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -372,6 +372,7 @@ set( PCBNEW_CLASS_SRCS pcb_fields_grid_table.cpp toolbars_footprint_editor.cpp toolbars_footprint_viewer.cpp + toolbars_footprint_wizard.cpp toolbars_pcb_editor.cpp tracks_cleaner.cpp undo_redo.cpp diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 533a992a4f..b0c41c1d7c 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -164,8 +165,11 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : initLibraryTree(); m_treePane = new FOOTPRINT_TREE_PANE( this ); + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); + ReCreateLayerBox( false ); + ReCreateMenuBar(); m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this ); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 042eeea614..052d3ddb7d 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -114,11 +114,6 @@ public: */ void HardRedraw() override; - // Default toolbar configuration - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultRightToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - /** * Re create the layer Box by clearing the old list, and building a new one from the new * layers names and layer colors.. diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 02da9d1ff2..73573a4aea 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -218,6 +219,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); setupUIConditions(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); ReCreateMenuBar(); diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 05a8d5caf2..521c5ea4fd 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -105,10 +105,6 @@ public: void HardRedraw() override; - // Toolbar defaults - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - protected: FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index a4cafb24dc..1cc814e20d 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -53,6 +53,7 @@ #include "tools/pcb_selection_tool.h" #include "tools/pcb_control.h" #include "tools/pcb_actions.h" +#include #include @@ -151,6 +152,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); // Create the toolbars + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); @@ -569,52 +571,6 @@ void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const } -std::optional FOOTPRINT_WIZARD_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - /* TODO (ISM): Convert to action - m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString, - KiBitmap( BITMAPS::module_wizard ), - _( "Select wizard script to run" ) ); -*/ - - config.AppendSeparator(); - /* TODO (ISM): Convert to action - m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString, - KiBitmap( BITMAPS::reload ), - _( "Reset wizard parameters to default") ); -*/ - config.AppendSeparator(); - /* TODO (ISM): Convert to action - m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString, - KiBitmap( BITMAPS::lib_previous ), - _( "Select previous parameters page" ) ); - m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString, - KiBitmap( BITMAPS::lib_next ), - _( "Select next parameters page" ) ); -*/ - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ); - - // The footprint wizard always can export the current footprint - config.AppendSeparator(); - /* TODO (ISM): Convert to action - m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_DONE, - wxEmptyString, KiBitmap( BITMAPS::export_footprint_names ), - _( "Export footprint to editor" ) ); -*/ - - // clang-format on - return config; -} - - BOARD_ITEM_CONTAINER* FOOTPRINT_WIZARD_FRAME::GetModel() const { return GetBoard()->GetFirstFootprint(); diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index db1ef7fea0..65c367430b 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -147,9 +147,6 @@ private: */ void DisplayWizardInfos(); - // Toolbar defaults - std::optional DefaultTopMainToolbarConfig() override; - void doCloseWindow() override; void ClickOnPageList( wxCommandEvent& event ); diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 3e7234c2d4..2d189b7aba 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -405,7 +405,5 @@ void PCB_BASE_EDIT_FRAME::configureToolbars() m_SelLayerBox->GetId() ); }; - RegisterCustomToolbarControlFactory( m_tbPcbLayerSelectorName, _( "Layer selector" ), - _( "Control to select the layer" ), - layerSelectorFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::layerSelector, layerSelectorFactory ); } \ No newline at end of file diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 557dd2f835..6aa22e35c0 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -265,7 +265,6 @@ protected: std::unique_ptr m_layerPairSettings; PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer - const std::string m_tbPcbLayerSelectorName = "control.PCBLayerSelector"; wxAuiNotebook* m_tabbedPanel; /// Panel with Layers and Object Inspector tabs diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 9532064246..150281afda 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -116,6 +116,7 @@ #include #include #include +#include #ifdef KICAD_IPC_API #include @@ -266,8 +267,12 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : setupTools(); setupUIConditions(); + + m_toolbarSettings = std::make_unique(); configureToolbars(); RecreateToolbars(); + PrepareLayerIndicator( true ); + ReCreateMenuBar(); #ifdef KICAD_IPC_API diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 21a0942d80..45598dfab5 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -725,11 +725,6 @@ public: DIALOG_BOOK_REPORTER* GetFootprintDiffDialog(); - std::optional DefaultLeftToolbarConfig() override; - std::optional DefaultRightToolbarConfig() override; - std::optional DefaultTopMainToolbarConfig() override; - std::optional DefaultTopAuxToolbarConfig() override; - DECLARE_EVENT_TABLE() protected: diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 9bc25d32c8..1eac05cf4e 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -34,156 +34,149 @@ #include #include -std::optional FOOTPRINT_EDIT_FRAME::DefaultLeftToolbarConfig() +#include + +std::optional FOOTPRINT_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::toggleGridOverrides ) - .AppendAction( PCB_ACTIONS::togglePolarCoords ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::toggleHV45Mode ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::padDisplayMode ) - .AppendAction( PCB_ACTIONS::graphicsOutlines ) - .AppendAction( PCB_ACTIONS::textOutlines ) - .AppendAction( ACTIONS::highContrastMode ); - - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - config.AppendAction( ACTIONS::toggleBoundingBoxes ); - - config.AppendSeparator() - .AppendAction( ACTIONS::showLibraryTree ) - .AppendAction( PCB_ACTIONS::showLayersManager ) - .AppendAction( ACTIONS::showProperties ); - - /* TODO (ISM): Implement context menus - PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - std::unique_ptr gridMenu = std::make_unique( false, selTool ); - gridMenu->Add( ACTIONS::gridProperties ); - gridMenu->Add( ACTIONS::gridOrigin ); - m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); -*/ - - // clang-format on - return config; -} - - -std::optional FOOTPRINT_EDIT_FRAME::DefaultRightToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendAction( ACTIONS::selectionTool ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::placePad ) - .AppendAction( PCB_ACTIONS::drawRuleArea ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::drawLine ) - .AppendAction( PCB_ACTIONS::drawArc ) - .AppendAction( PCB_ACTIONS::drawRectangle ) - .AppendAction( PCB_ACTIONS::drawCircle ) - .AppendAction( PCB_ACTIONS::drawPolygon ) - .AppendAction( PCB_ACTIONS::drawBezier ) - .AppendAction( PCB_ACTIONS::placeReferenceImage ) - .AppendAction( PCB_ACTIONS::placeText ) - .AppendAction( PCB_ACTIONS::drawTextBox ) - .AppendAction( PCB_ACTIONS::drawTable ) - .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbDimensions" ) - .AddAction( PCB_ACTIONS::drawOrthogonalDimension ) - .AddAction( PCB_ACTIONS::drawAlignedDimension ) - .AddAction( PCB_ACTIONS::drawCenterDimension ) - .AddAction( PCB_ACTIONS::drawRadialDimension ) - .AddAction( PCB_ACTIONS::drawLeader ) ) - .AppendAction( ACTIONS::deleteTool ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::setAnchor ) - .AppendAction( ACTIONS::gridSetOrigin ) - .AppendAction( ACTIONS::measureTool ); - - /* TODO (ISM): Implement context menus - PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - - auto makeArcMenu = [&]() + switch( aToolbar ) { - std::unique_ptr arcMenu = std::make_unique( false, selTool ); + // No Aux toolbar + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK ); - arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK ); + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::toggleGridOverrides ) + .AppendAction( PCB_ACTIONS::togglePolarCoords ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); - return arcMenu; - }; + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::toggleHV45Mode ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() ); -*/ + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::padDisplayMode ) + .AppendAction( PCB_ACTIONS::graphicsOutlines ) + .AppendAction( PCB_ACTIONS::textOutlines ) + .AppendAction( ACTIONS::highContrastMode ); - // clang-format on - return config; -} + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + config.AppendAction( ACTIONS::toggleBoundingBoxes ); + config.AppendSeparator() + .AppendAction( ACTIONS::showLibraryTree ) + .AppendAction( PCB_ACTIONS::showLayersManager ) + .AppendAction( ACTIONS::showProperties ); -std::optional FOOTPRINT_EDIT_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + /* TODO (ISM): Implement context menus + PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + std::unique_ptr gridMenu = std::make_unique( false, selTool ); + gridMenu->Add( ACTIONS::gridProperties ); + gridMenu->Add( ACTIONS::gridOrigin ); + m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + */ + break; - // clang-format off - config.AppendAction( PCB_ACTIONS::newFootprint ) - .AppendAction( PCB_ACTIONS::createFootprint ) - .AppendAction( ACTIONS::save ); + case TOOLBAR_LOC::RIGHT: + config.AppendAction( ACTIONS::selectionTool ); - config.AppendSeparator() - .AppendAction( ACTIONS::print ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::placePad ) + .AppendAction( PCB_ACTIONS::drawRuleArea ); - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::drawLine ) + .AppendAction( PCB_ACTIONS::drawArc ) + .AppendAction( PCB_ACTIONS::drawRectangle ) + .AppendAction( PCB_ACTIONS::drawCircle ) + .AppendAction( PCB_ACTIONS::drawPolygon ) + .AppendAction( PCB_ACTIONS::drawBezier ) + .AppendAction( PCB_ACTIONS::placeReferenceImage ) + .AppendAction( PCB_ACTIONS::placeText ) + .AppendAction( PCB_ACTIONS::drawTextBox ) + .AppendAction( PCB_ACTIONS::drawTable ) + .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbDimensions" ) + .AddAction( PCB_ACTIONS::drawOrthogonalDimension ) + .AddAction( PCB_ACTIONS::drawAlignedDimension ) + .AddAction( PCB_ACTIONS::drawCenterDimension ) + .AddAction( PCB_ACTIONS::drawRadialDimension ) + .AddAction( PCB_ACTIONS::drawLeader ) ) + .AppendAction( ACTIONS::deleteTool ); - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::setAnchor ) + .AppendAction( ACTIONS::gridSetOrigin ) + .AppendAction( ACTIONS::measureTool ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::rotateCcw ) - .AppendAction( PCB_ACTIONS::rotateCw ) - .AppendAction( PCB_ACTIONS::mirrorH ) - .AppendAction( PCB_ACTIONS::mirrorV ) - .AppendAction( PCB_ACTIONS::group ) - .AppendAction( PCB_ACTIONS::ungroup ); + /* TODO (ISM): Implement context menus + PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::footprintProperties ) - .AppendAction( PCB_ACTIONS::defaultPadProperties ) - .AppendAction( ACTIONS::showDatasheet ) - .AppendAction( PCB_ACTIONS::checkFootprint ); + auto makeArcMenu = [&]() + { + std::unique_ptr arcMenu = std::make_unique( false, selTool ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::loadFpFromBoard ) - .AppendAction( PCB_ACTIONS::saveFpToBoard ); + arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK ); + arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK ); - config.AppendSeparator() - .AppendControl( m_tbGridSelectName ); + return arcMenu; + }; - config.AppendSeparator() - .AppendControl( m_tbZoomSelectName ); + m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() ); + */ + break; - config.AppendSeparator() - .AppendControl( m_tbPcbLayerSelectorName ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( PCB_ACTIONS::newFootprint ) + .AppendAction( PCB_ACTIONS::createFootprint ) + .AppendAction( ACTIONS::save ); - ReCreateLayerBox( false ); + config.AppendSeparator() + .AppendAction( ACTIONS::print ); + + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ); + + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::rotateCcw ) + .AppendAction( PCB_ACTIONS::rotateCw ) + .AppendAction( PCB_ACTIONS::mirrorH ) + .AppendAction( PCB_ACTIONS::mirrorV ) + .AppendAction( PCB_ACTIONS::group ) + .AppendAction( PCB_ACTIONS::ungroup ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::footprintProperties ) + .AppendAction( PCB_ACTIONS::defaultPadProperties ) + .AppendAction( ACTIONS::showDatasheet ) + .AppendAction( PCB_ACTIONS::checkFootprint ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::loadFpFromBoard ) + .AppendAction( PCB_ACTIONS::saveFpToBoard ); + + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect ); + + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ); + + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::layerSelector ); + break; + } // clang-format on return config; diff --git a/pcbnew/toolbars_footprint_editor.h b/pcbnew/toolbars_footprint_editor.h new file mode 100644 index 0000000000..9d7e497534 --- /dev/null +++ b/pcbnew/toolbars_footprint_editor.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_FOOTPRINT_EDITOR_H_ +#define TOOLBARS_FOOTPRINT_EDITOR_H_ + +#include + +/** + * Toolbar configuration for the footprint edit frame. + */ +class FOOTPRINT_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + FOOTPRINT_EDIT_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "fpedit" ) + {} + + ~FOOTPRINT_EDIT_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_FOOTPRINT_EDITOR_H_ */ diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index bd6802a688..ab4ee09e53 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -34,62 +34,65 @@ #include #include +#include -std::optional FOOTPRINT_VIEWER_FRAME::DefaultTopMainToolbarConfig() +std::optional FOOTPRINT_VIEWER_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( PCB_ACTIONS::previousFootprint ) - .AppendAction( PCB_ACTIONS::nextFootprint ); + switch( aToolbar ) + { + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomTool ); + case TOOLBAR_LOC::TOP_MAIN: + config.AppendAction( PCB_ACTIONS::previousFootprint ) + .AppendAction( PCB_ACTIONS::nextFootprint ); - config.AppendSeparator() - .AppendAction( ACTIONS::show3DViewer ) - .AppendAction( PCB_ACTIONS::saveFpToBoard ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomTool ); - config.AppendSeparator() - .AppendControl( m_tbGridSelectName ); + config.AppendSeparator() + .AppendAction( ACTIONS::show3DViewer ) + .AppendAction( PCB_ACTIONS::saveFpToBoard ); - config.AppendSeparator() - .AppendControl( m_tbZoomSelectName ) - .AppendAction( PCB_ACTIONS::fpAutoZoom); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect ); - // clang-format on - return config; -} + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ) + .AppendAction( PCB_ACTIONS::fpAutoZoom); + break; + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::selectionTool ) + .AppendAction( ACTIONS::measureTool ); -std::optional FOOTPRINT_VIEWER_FRAME::DefaultLeftToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::togglePolarCoords ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); - // clang-format off - config.AppendAction( ACTIONS::selectionTool ) - .AppendAction( ACTIONS::measureTool ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::showPadNumbers ) + .AppendAction( PCB_ACTIONS::padDisplayMode ) + .AppendAction( PCB_ACTIONS::textOutlines ) + .AppendAction( PCB_ACTIONS::graphicsOutlines ); - config.AppendSeparator() - .AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::togglePolarCoords ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + config.AppendAction( ACTIONS::toggleBoundingBoxes ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showPadNumbers ) - .AppendAction( PCB_ACTIONS::padDisplayMode ) - .AppendAction( PCB_ACTIONS::textOutlines ) - .AppendAction( PCB_ACTIONS::graphicsOutlines ); - - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - config.AppendAction( ACTIONS::toggleBoundingBoxes ); + break; + } // clang-format on return config; diff --git a/pcbnew/toolbars_footprint_viewer.h b/pcbnew/toolbars_footprint_viewer.h new file mode 100644 index 0000000000..32212cd376 --- /dev/null +++ b/pcbnew/toolbars_footprint_viewer.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_FOOTPRINT_VIEWER_H_ +#define TOOLBARS_FOOTPRINT_VIEWER_H_ + +#include + +/** + * Toolbar configuration for the footprint viewer frame. + */ +class FOOTPRINT_VIEWER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + FOOTPRINT_VIEWER_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "fpviewer" ) + {} + + ~FOOTPRINT_VIEWER_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_FOOTPRINT_VIEWER_H_ */ diff --git a/pcbnew/toolbars_footprint_wizard.cpp b/pcbnew/toolbars_footprint_wizard.cpp new file mode 100644 index 0000000000..7a88ec747e --- /dev/null +++ b/pcbnew/toolbars_footprint_wizard.cpp @@ -0,0 +1,81 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + + +std::optional FOOTPRINT_WIZARD_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) +{ + TOOLBAR_CONFIGURATION config; + + // clang-format off + switch( aToolbar ) + { + case TOOLBAR_LOC::LEFT: + case TOOLBAR_LOC::RIGHT: + case TOOLBAR_LOC::TOP_AUX: + return std::nullopt; + + case TOOLBAR_LOC::TOP_MAIN: + /* TODO (ISM): Convert to action + m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString, + KiBitmap( BITMAPS::module_wizard ), + _( "Select wizard script to run" ) ); + */ + + config.AppendSeparator(); + /* TODO (ISM): Convert to action + m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString, + KiBitmap( BITMAPS::reload ), + _( "Reset wizard parameters to default") ); + */ + config.AppendSeparator(); + /* TODO (ISM): Convert to action + m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString, + KiBitmap( BITMAPS::lib_previous ), + _( "Select previous parameters page" ) ); + m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString, + KiBitmap( BITMAPS::lib_next ), + _( "Select next parameters page" ) ); + */ + + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ); + + // The footprint wizard always can export the current footprint + config.AppendSeparator(); + /* TODO (ISM): Convert to action + m_tbTopMain->AddTool( ID_FOOTPRINT_WIZARD_DONE, + wxEmptyString, KiBitmap( BITMAPS::export_footprint_names ), + _( "Export footprint to editor" ) ); + */ + break; + } + + // clang-format on + return config; +} diff --git a/pcbnew/toolbars_footprint_wizard.h b/pcbnew/toolbars_footprint_wizard.h new file mode 100644 index 0000000000..7834cf217a --- /dev/null +++ b/pcbnew/toolbars_footprint_wizard.h @@ -0,0 +1,40 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_FOOTPRINT_WIZARD_H_ +#define TOOLBARS_FOOTPRINT_WIZARD_H_ + +#include + +/** + * Toolbar configuration for the footprint wizard frame. + */ +class FOOTPRINT_WIZARD_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + FOOTPRINT_WIZARD_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "fpwizard" ) + {} + + ~FOOTPRINT_WIZARD_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_FOOTPRINT_WIZARD_H_ */ diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 12f56cb1f3..cefe7828db 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -58,7 +58,7 @@ #include #include #include - +#include #include #include "../scripting/python_scripting.h" @@ -120,253 +120,239 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild ) } -std::optional PCB_EDIT_FRAME::DefaultLeftToolbarConfig() +ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::trackWidth( "control.PCBTrackWidth", _( "Track width selector" ), + _( "Control to select the track width" ) ); +ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::viaDiameter( "control.PCBViaDia", _( "Via diameter selector" ), + _( "Control to select the via diameter" ) ); + + +std::optional PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) { TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendAction( ACTIONS::toggleGrid ) - .AppendAction( ACTIONS::toggleGridOverrides ) - .AppendAction( PCB_ACTIONS::togglePolarCoords ) - .AppendAction( ACTIONS::inchesUnits ) - .AppendAction( ACTIONS::milsUnits ) - .AppendAction( ACTIONS::millimetersUnits ) - .AppendAction( ACTIONS::toggleCursorStyle ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::toggleHV45Mode ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showRatsnest ) - .AppendAction( PCB_ACTIONS::ratsnestLineMode ); - - config.AppendSeparator() - .AppendAction( ACTIONS::highContrastMode ) - .AppendAction( PCB_ACTIONS::toggleNetHighlight ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::zoneDisplayFilled ) - .AppendAction( PCB_ACTIONS::zoneDisplayOutline ); - - if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + switch( aToolbar ) { - config.AppendAction( PCB_ACTIONS::zoneDisplayFractured ); - config.AppendAction( PCB_ACTIONS::zoneDisplayTriangulated ); - } + case TOOLBAR_LOC::LEFT: + config.AppendAction( ACTIONS::toggleGrid ) + .AppendAction( ACTIONS::toggleGridOverrides ) + .AppendAction( PCB_ACTIONS::togglePolarCoords ) + .AppendAction( ACTIONS::inchesUnits ) + .AppendAction( ACTIONS::milsUnits ) + .AppendAction( ACTIONS::millimetersUnits ) + .AppendAction( ACTIONS::toggleCursorStyle ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::padDisplayMode ) - .AppendAction( PCB_ACTIONS::viaDisplayMode ) - .AppendAction( PCB_ACTIONS::trackDisplayMode ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::toggleHV45Mode ); - if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - config.AppendAction( ACTIONS::toggleBoundingBoxes ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::showRatsnest ) + .AppendAction( PCB_ACTIONS::ratsnestLineMode ); - // Tools to show/hide toolbars: - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showLayersManager ) - .AppendAction( ACTIONS::showProperties ); + config.AppendSeparator() + .AppendAction( ACTIONS::highContrastMode ) + .AppendAction( PCB_ACTIONS::toggleNetHighlight ); - /* TODO (ISM): Support context menus in toolbars - PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); - std::unique_ptr gridMenu = std::make_unique( false, selTool ); - gridMenu->Add( ACTIONS::gridProperties ); - gridMenu->Add( ACTIONS::gridOrigin ); - m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::zoneDisplayFilled ) + .AppendAction( PCB_ACTIONS::zoneDisplayOutline ); + + if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + { + config.AppendAction( PCB_ACTIONS::zoneDisplayFractured ); + config.AppendAction( PCB_ACTIONS::zoneDisplayTriangulated ); + } + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::padDisplayMode ) + .AppendAction( PCB_ACTIONS::viaDisplayMode ) + .AppendAction( PCB_ACTIONS::trackDisplayMode ); + + if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) + config.AppendAction( ACTIONS::toggleBoundingBoxes ); + + // Tools to show/hide toolbars: + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::showLayersManager ) + .AppendAction( ACTIONS::showProperties ); + + /* TODO (ISM): Support context menus in toolbars + PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + std::unique_ptr gridMenu = std::make_unique( false, selTool ); + gridMenu->Add( ACTIONS::gridProperties ); + gridMenu->Add( ACTIONS::gridOrigin ); + m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); + */ + break; + + case TOOLBAR_LOC::RIGHT: + config.AppendAction( ACTIONS::selectionTool ) + .AppendAction( PCB_ACTIONS::localRatsnestTool ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::placeFootprint ) + .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbRouting" ) + .AddAction( PCB_ACTIONS::routeSingleTrack ) + .AddAction( PCB_ACTIONS::routeDiffPair ) ) + .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbTune" ) + .AddAction( PCB_ACTIONS::tuneSingleTrack ) + .AddAction( PCB_ACTIONS::tuneDiffPair ) + .AddAction( PCB_ACTIONS::tuneSkew ) ) + .AppendAction( PCB_ACTIONS::drawVia ) + .AppendAction( PCB_ACTIONS::drawZone ) + .AppendAction( PCB_ACTIONS::drawRuleArea ); + + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::drawLine ) + .AppendAction( PCB_ACTIONS::drawArc ) + .AppendAction( PCB_ACTIONS::drawRectangle ) + .AppendAction( PCB_ACTIONS::drawCircle ) + .AppendAction( PCB_ACTIONS::drawPolygon ) + .AppendAction( PCB_ACTIONS::drawBezier ) + .AppendAction( PCB_ACTIONS::placeReferenceImage ) + .AppendAction( PCB_ACTIONS::placeText ) + .AppendAction( PCB_ACTIONS::drawTextBox ) + .AppendAction( PCB_ACTIONS::drawTable ) + .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbDimensions" ) + .AddAction( PCB_ACTIONS::drawOrthogonalDimension ) + .AddAction( PCB_ACTIONS::drawAlignedDimension ) + .AddAction( PCB_ACTIONS::drawCenterDimension ) + .AddAction( PCB_ACTIONS::drawRadialDimension ) + .AddAction( PCB_ACTIONS::drawLeader ) ) + .AppendAction( ACTIONS::deleteTool ); + + config.AppendSeparator() + .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbOrigins" ) + .AddAction( ACTIONS::gridSetOrigin ) + .AddAction( PCB_ACTIONS::tuneDiffPair ) + .AddAction( PCB_ACTIONS::drillOrigin ) ) + .AppendAction( ACTIONS::measureTool ); + + /* TODO (ISM): Support context menus + PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + + auto makeArcMenu = [&]() + { + std::unique_ptr arcMenu = std::make_unique( false, selTool ); + + arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK ); + arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK ); + + return arcMenu; + }; + + m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() ); + + auto makeRouteMenu = [&]() + { + std::unique_ptr routeMenu = std::make_unique( false, selTool ); + + routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK ); + routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK ); + routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK ); + + routeMenu->AppendSeparator(); + routeMenu->Add( PCB_ACTIONS::routerSettingsDialog ); + + return routeMenu; + }; + + m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() ); + m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() ); + + std::unique_ptr zoneMenu = std::make_unique( false, selTool ); + zoneMenu->Add( PCB_ACTIONS::zoneFillAll ); + zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll ); + m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) ); + + std::unique_ptr lineMenu = std::make_unique( false, selTool ); + m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) ); */ + break; - // clang-format on - return config; -} + case TOOLBAR_LOC::TOP_MAIN: + if( Kiface().IsSingle() ) + { + config.AppendAction( ACTIONS::doNew ); + config.AppendAction( ACTIONS::open ); + } + config.AppendAction( ACTIONS::save ); -std::optional PCB_EDIT_FRAME::DefaultRightToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::boardSetup ); - // clang-format off - config.AppendAction( ACTIONS::selectionTool ) - .AppendAction( PCB_ACTIONS::localRatsnestTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::pageSettings ) + .AppendAction( ACTIONS::print ) + .AppendAction( ACTIONS::plot ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::placeFootprint ) - .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbRouting" ) - .AddAction( PCB_ACTIONS::routeSingleTrack ) - .AddAction( PCB_ACTIONS::routeDiffPair ) ) - .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbTune" ) - .AddAction( PCB_ACTIONS::tuneSingleTrack ) - .AddAction( PCB_ACTIONS::tuneDiffPair ) - .AddAction( PCB_ACTIONS::tuneSkew ) ) - .AppendAction( PCB_ACTIONS::drawVia ) - .AppendAction( PCB_ACTIONS::drawZone ) - .AppendAction( PCB_ACTIONS::drawRuleArea ); + config.AppendSeparator() + .AppendAction( ACTIONS::undo ) + .AppendAction( ACTIONS::redo ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::drawLine ) - .AppendAction( PCB_ACTIONS::drawArc ) - .AppendAction( PCB_ACTIONS::drawRectangle ) - .AppendAction( PCB_ACTIONS::drawCircle ) - .AppendAction( PCB_ACTIONS::drawPolygon ) - .AppendAction( PCB_ACTIONS::drawBezier ) - .AppendAction( PCB_ACTIONS::placeReferenceImage ) - .AppendAction( PCB_ACTIONS::placeText ) - .AppendAction( PCB_ACTIONS::drawTextBox ) - .AppendAction( PCB_ACTIONS::drawTable ) - .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbDimensions" ) - .AddAction( PCB_ACTIONS::drawOrthogonalDimension ) - .AddAction( PCB_ACTIONS::drawAlignedDimension ) - .AddAction( PCB_ACTIONS::drawCenterDimension ) - .AddAction( PCB_ACTIONS::drawRadialDimension ) - .AddAction( PCB_ACTIONS::drawLeader ) ) - .AppendAction( ACTIONS::deleteTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::find ); - config.AppendSeparator() - .AppendGroup( TOOLBAR_GROUP_CONFIG( "group.pcbOrigins" ) - .AddAction( ACTIONS::gridSetOrigin ) - .AddAction( PCB_ACTIONS::tuneDiffPair ) - .AddAction( PCB_ACTIONS::drillOrigin ) ) - .AppendAction( ACTIONS::measureTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::zoomRedraw ) + .AppendAction( ACTIONS::zoomInCenter ) + .AppendAction( ACTIONS::zoomOutCenter ) + .AppendAction( ACTIONS::zoomFitScreen ) + .AppendAction( ACTIONS::zoomFitObjects ) + .AppendAction( ACTIONS::zoomTool ); - /* TODO (ISM): Support context menus - PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool(); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::rotateCcw ) + .AppendAction( PCB_ACTIONS::rotateCw ) + .AppendAction( PCB_ACTIONS::mirrorV ) + .AppendAction( PCB_ACTIONS::mirrorH ) + .AppendAction( PCB_ACTIONS::group ) + .AppendAction( PCB_ACTIONS::ungroup ) + .AppendAction( PCB_ACTIONS::lock ) + .AppendAction( PCB_ACTIONS::unlock ); - auto makeArcMenu = [&]() - { - std::unique_ptr arcMenu = std::make_unique( false, selTool ); + config.AppendSeparator() + .AppendAction( ACTIONS::showFootprintEditor ) + .AppendAction( ACTIONS::showFootprintBrowser ) + .AppendAction( ACTIONS::show3DViewer ); - arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK ); - arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK ); + config.AppendSeparator(); - return arcMenu; - }; + if( !Kiface().IsSingle() ) + config.AppendAction( ACTIONS::updatePcbFromSchematic ); + else + config.AppendAction( PCB_ACTIONS::importNetlist ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() ); + config.AppendAction( PCB_ACTIONS::runDRC ); - auto makeRouteMenu = [&]() - { - std::unique_ptr routeMenu = std::make_unique( false, selTool ); + config.AppendSeparator() + .AppendAction( PCB_ACTIONS::showEeschema ); - routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK ); - routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK ); - routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK ); + config.AppendControl( ACTION_TOOLBAR_CONTROLS::ipcScripting ); - routeMenu->AppendSeparator(); - routeMenu->Add( PCB_ACTIONS::routerSettingsDialog ); + break; - return routeMenu; - }; + case TOOLBAR_LOC::TOP_AUX: + config.AppendControl( PCB_ACTION_TOOLBAR_CONTROLS::trackWidth ) + .AppendAction( PCB_ACTIONS::autoTrackWidth ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() ); + config.AppendSeparator() + .AppendControl( PCB_ACTION_TOOLBAR_CONTROLS::viaDiameter ); - std::unique_ptr zoneMenu = std::make_unique( false, selTool ); - zoneMenu->Add( PCB_ACTIONS::zoneFillAll ); - zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) ); + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::layerSelector ) + .AppendAction( PCB_ACTIONS::selectLayerPair ); - std::unique_ptr lineMenu = std::make_unique( false, selTool ); - m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) ); -*/ + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect ); - // clang-format on - return config; -} + config.AppendSeparator() + .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect ); - -std::optional PCB_EDIT_FRAME::DefaultTopMainToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - if( Kiface().IsSingle() ) - { - config.AppendAction( ACTIONS::doNew ); - config.AppendAction( ACTIONS::open ); + break; } - config.AppendAction( ACTIONS::save ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::boardSetup ); - - config.AppendSeparator() - .AppendAction( ACTIONS::pageSettings ) - .AppendAction( ACTIONS::print ) - .AppendAction( ACTIONS::plot ); - - config.AppendSeparator() - .AppendAction( ACTIONS::undo ) - .AppendAction( ACTIONS::redo ); - - config.AppendSeparator() - .AppendAction( ACTIONS::find ); - - config.AppendSeparator() - .AppendAction( ACTIONS::zoomRedraw ) - .AppendAction( ACTIONS::zoomInCenter ) - .AppendAction( ACTIONS::zoomOutCenter ) - .AppendAction( ACTIONS::zoomFitScreen ) - .AppendAction( ACTIONS::zoomFitObjects ) - .AppendAction( ACTIONS::zoomTool ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::rotateCcw ) - .AppendAction( PCB_ACTIONS::rotateCw ) - .AppendAction( PCB_ACTIONS::mirrorV ) - .AppendAction( PCB_ACTIONS::mirrorH ) - .AppendAction( PCB_ACTIONS::group ) - .AppendAction( PCB_ACTIONS::ungroup ) - .AppendAction( PCB_ACTIONS::lock ) - .AppendAction( PCB_ACTIONS::unlock ); - - config.AppendSeparator() - .AppendAction( ACTIONS::showFootprintEditor ) - .AppendAction( ACTIONS::showFootprintBrowser ) - .AppendAction( ACTIONS::show3DViewer ); - - config.AppendSeparator(); - - if( !Kiface().IsSingle() ) - config.AppendAction( ACTIONS::updatePcbFromSchematic ); - else - config.AppendAction( PCB_ACTIONS::importNetlist ); - - config.AppendAction( PCB_ACTIONS::runDRC ); - - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showEeschema ); - - config.AppendControl( "control.PCBPlugin" ); - - // clang-format on - return config; -} - - -std::optional PCB_EDIT_FRAME::DefaultTopAuxToolbarConfig() -{ - TOOLBAR_CONFIGURATION config; - - // clang-format off - config.AppendControl( "control.PCBTrackWidth" ) - .AppendAction( PCB_ACTIONS::autoTrackWidth ); - - config.AppendSeparator() - .AppendControl( "control.PCBViaDia" ); - - config.AppendSeparator() - .AppendControl( m_tbPcbLayerSelectorName ) - .AppendAction( PCB_ACTIONS::selectLayerPair ); - - // TODO (ISM): Figure out this part - PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors - - config.AppendSeparator() - .AppendControl( m_tbGridSelectName ); - - config.AppendSeparator() - .AppendControl( m_tbZoomSelectName ); - // clang-format on return config; } @@ -396,9 +382,7 @@ void PCB_EDIT_FRAME::configureToolbars() aToolbar->Add( m_SelTrackWidthBox ); }; - RegisterCustomToolbarControlFactory( "control.PCBTrackWidth", _( "Track width selector" ), - _( "Control to select the track width" ), - trackWidthSelectorFactory ); + RegisterCustomToolbarControlFactory( PCB_ACTION_TOOLBAR_CONTROLS::trackWidth, trackWidthSelectorFactory ); // Box to display and choose vias diameters @@ -415,9 +399,7 @@ void PCB_EDIT_FRAME::configureToolbars() aToolbar->Add( m_SelViaSizeBox ); }; - RegisterCustomToolbarControlFactory( "control.PCBViaDia", _( "Via diameter selector" ), - _( "Control to select the via diameter" ), - viaDiaSelectorFactory ); + RegisterCustomToolbarControlFactory( PCB_ACTION_TOOLBAR_CONTROLS::viaDiameter, viaDiaSelectorFactory ); // IPC/Scripting plugin control // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire @@ -450,9 +432,7 @@ void PCB_EDIT_FRAME::configureToolbars() } }; - RegisterCustomToolbarControlFactory( "control.PCBPlugin", _( "IPC/Scripting plugins" ), - _( "Region to hold the IPC/Scripting action buttons" ), - pluginControlFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::ipcScripting, pluginControlFactory ); /* TOOLBAR_SETTINGS tb( "pcbnew-toolbars" ); diff --git a/pcbnew/toolbars_pcb_editor.h b/pcbnew/toolbars_pcb_editor.h new file mode 100644 index 0000000000..4846927847 --- /dev/null +++ b/pcbnew/toolbars_pcb_editor.h @@ -0,0 +1,48 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The 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 as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TOOLBARS_PCB_EDITOR_H_ +#define TOOLBARS_PCB_EDITOR_H_ + +#include +#include + +class PCB_ACTION_TOOLBAR_CONTROLS : public ACTION_TOOLBAR_CONTROLS +{ +public: + static ACTION_TOOLBAR_CONTROL trackWidth; + static ACTION_TOOLBAR_CONTROL viaDiameter; +}; + +/** + * Toolbar configuration for the PCB editor frame. + */ +class PCB_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS +{ +public: + PCB_EDIT_TOOLBAR_SETTINGS() : + TOOLBAR_SETTINGS( "pcbnew" ) + {} + + ~PCB_EDIT_TOOLBAR_SETTINGS() {} + + std::optional DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override; +}; + +#endif /* TOOLBARS_PCB_EDITOR_H_ */