7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 23:13:43 +00:00

Load toolbar configuration from settings

This commit is contained in:
Ian McInerney 2025-02-26 03:22:49 +00:00
parent caa03ab59e
commit 548334b4e2
72 changed files with 1975 additions and 1260 deletions
3d-viewer
common
cvpcb
eeschema
gerbview
include
kicad
pagelayout_editor
pcbnew

View File

@ -1,87 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <wx/wupdlock.h>
#include <wx/choice.h>
#include <bitmaps.h>
#include <dialogs/eda_view_switcher.h>
#include <eda_3d_viewer_frame.h>
#include <tool/action_toolbar.h>
#include <tools/eda_3d_actions.h>
#include <3d_viewer_id.h>
std::optional<TOOLBAR_CONFIGURATION> 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;
}

View File

@ -58,6 +58,7 @@
#include <widgets/wx_aui_utils.h>
#include <wildcards_and_files_ext.h>
#include <project_pcb.h>
#include <toolbars_3d.h>
#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<EDA_3D_VIEWER_TOOLBAR_SETTINGS>();
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<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );

View File

@ -130,8 +130,6 @@ public:
void OnDarkModeToggle();
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
/**
* Create a Screenshot of the current 3D view.
* Output file format is png or jpeg, or image is copied to the clipboard

View File

@ -0,0 +1,98 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <wx/wupdlock.h>
#include <wx/choice.h>
#include <bitmaps.h>
#include <dialogs/eda_view_switcher.h>
#include <eda_3d_viewer_frame.h>
#include <tool/action_toolbar.h>
#include <tools/eda_3d_actions.h>
#include <3d_viewer_id.h>
#include <toolbars_3d.h>
std::optional<TOOLBAR_CONFIGURATION> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TOOLBARS_3D_H_
#define TOOLBARS_3D_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_3D_H_ */

View File

@ -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

View File

@ -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<TOOLBAR_CONFIGURATION> 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();
}

View File

@ -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 );
}

View File

@ -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" ) );

View File

@ -22,6 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <magic_enum.hpp>
#include <nlohmann/json.hpp>
#include <tool/action_toolbar.h>
@ -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<std::string>(),
entry["contents"].get<TOOLBAR_CONFIGURATION>() ) );
auto loc = magic_enum::enum_cast<TOOLBAR_LOC>( entry["name"].get<std::string>(),
magic_enum::case_insensitive );
if( loc.has_value() )
{
m_toolbars.emplace(
std::make_pair( loc.value(),
entry["contents"].get<TOOLBAR_CONFIGURATION>() ) );
}
}
},
nlohmann::json::array() ) );
}
std::optional<TOOLBAR_CONFIGURATION> 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 );
}

View File

@ -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

View File

@ -55,6 +55,7 @@
#include <tools/cvpcb_association_tool.h>
#include <tools/cvpcb_control.h>
#include <project_pcb.h>
#include <toolbars_cvpcb.h>
#include <wx/statline.h>
#include <wx/stattext.h>
@ -91,6 +92,8 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<CVPCB_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -139,8 +139,6 @@ public:
*/
void OnSelectComponent( wxListEvent& event );
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void ShowChangedLanguage() override;
/**

View File

@ -54,6 +54,7 @@
#include <tools/pcb_editor_conditions.h> // Shared conditions with other Pcbnew frames
#include <tools/pcb_viewer_tools.h> // shared tools with other Pcbnew frames
#include <tools/cvpcb_fpviewer_selection_tool.h>
#include <toolbars_display_footprints.h>
#include <wx/choice.h>
#include <wx/debug.h>
#include <cvpcb_id.h>
@ -114,6 +115,8 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
m_toolManager->InitTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
@ -213,61 +216,6 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
}
std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<CVPCB_SETTINGS*>( aCfg );

View File

@ -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<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
/**
* Refresh the full display for this frame.
*

View File

@ -19,6 +19,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <toolbars_cvpcb.h>
#include <tool/action_toolbar.h>
#include <tool/actions.h>
@ -30,33 +32,43 @@
#include <settings/settings_manager.h>
std::optional<TOOLBAR_CONFIGURATION> CVPCB_MAINFRAME::DefaultTopMainToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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" ) );

47
cvpcb/toolbars_cvpcb.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TOOLBARS_CVPCB_H_
#define TOOLBARS_CVPCB_H_
#include <tool/action_toolbar.h>
#include <tool/ui/toolbar_configuration.h>
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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_CVPCB_H_ */

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <toolbars_display_footprints.h>
#include <tool/action_toolbar.h>
#include <tool/actions.h>
#include <tool/ui/toolbar_configuration.h>
#include <tools/pcb_actions.h>
std::optional<TOOLBAR_CONFIGURATION> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TOOLBARS_DISPLAY_FOOTPRINTS_H_
#define TOOLBARS_DISPLAY_FOOTPRINTS_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_DISPLAY_FOOTPRINTS_H_ */

View File

@ -104,6 +104,7 @@
#include <widgets/wx_aui_utils.h>
#include <drawing_sheet/ds_proxy_view_item.h>
#include <project/project_local_settings.h>
#include <toolbars_sch_editor.h>
#ifdef KICAD_IPC_API
#include <api/api_plugin_manager.h>
@ -190,6 +191,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupUIConditions();
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<SCH_EDIT_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();

View File

@ -176,11 +176,6 @@ public:
void CreateScreens();
// Currently no top auxillary toolbar
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultRightToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void setupUIConditions() override;
/**

View File

@ -57,6 +57,7 @@
#include <sim/simulator_reporter.h>
#include <eeschema_settings.h>
#include <advanced_config.h>
#include <sim/toolbars_simulator_frame.h>
#include <memory>
@ -168,6 +169,8 @@ SIMULATOR_FRAME::SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// was created.
m_tbTopMain->SetToolManager( m_toolManager );
m_toolbarSettings = std::make_unique<SIMULATOR_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -150,8 +150,6 @@ public:
void ShowChangedLanguage() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
/**
* Load plot, signal, cursor, measurement, etc. settings from a file.
*/

View File

@ -18,6 +18,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sim/toolbars_simulator_frame.h>
#include <sim/simulator_frame.h>
#include <tool/action_menu.h>
#include <tool/action_toolbar.h>
@ -27,38 +29,48 @@
#include <widgets/wx_menubar.h>
std::optional<TOOLBAR_CONFIGURATION> SIMULATOR_FRAME::DefaultTopMainToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TOOLBARS_SIMULATOR_FRAME_H_
#define TOOLBARS_SIMULATOR_FRAME_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_SIMULATOR_FRAME_H_ */

Some files were not shown because too many files have changed in this diff Show More