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

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_ */

View File

@ -47,6 +47,7 @@
#include <sch_view.h>
#include <settings/settings_manager.h>
#include <symbol_lib_table.h>
#include <toolbars_symbol_editor.h>
#include <tool/action_manager.h>
#include <tool/action_toolbar.h>
#include <tool/common_control.h>
@ -179,6 +180,8 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupUIConditions();
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<SYMBOL_EDIT_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();

View File

@ -199,11 +199,6 @@ public:
void doCloseWindow() override;
void OnExitKiCad( wxCommandEvent& event );
// Currently no top auxillary toolbar
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultRightToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;

View File

@ -29,6 +29,7 @@
#include <sch_painter.h>
#include <symbol_editor_settings.h>
#include <symbol_library_manager.h>
#include <toolbars_symbol_editor.h>
#include <tool/action_toolbar.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
@ -44,117 +45,111 @@
#endif
std::optional<TOOLBAR_CONFIGURATION> SYMBOL_EDIT_FRAME::DefaultLeftToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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<EE_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<EE_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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 );
}

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_CVPCB_H_
#define TOOLBARS_CVPCB_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_CVPCB_H_ */

View File

@ -62,6 +62,7 @@
#include <view/view_controls.h>
#include <wx/srchctrl.h>
#include <wx/log.h>
#include <toolbars_symbol_viewer.h>
#include <default_values.h>
#include <string_utils.h>
@ -142,6 +143,7 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<SYMBOL_VIEWER_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();

View File

@ -77,9 +77,6 @@ public:
void doCloseWindow() override;
void CloseLibraryViewer( wxCommandEvent& event );
// Only top main toolbar
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void ClickOnLibList( wxCommandEvent& event );
void ClickOnSymbolList( wxCommandEvent& event );

View File

@ -42,166 +42,163 @@
#include <widgets/wx_aui_utils.h>
#include <widgets/sch_properties_panel.h>
#include <widgets/sch_search_pane.h>
#include <toolbars_sch_editor.h>
std::optional<TOOLBAR_CONFIGURATION> SCH_EDIT_FRAME::DefaultLeftToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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<EE_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
gridMenu->Add( ACTIONS::gridProperties );
m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
*/
// clang-format on
return config;
}
std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<EE_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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 );
}

View File

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

View File

@ -31,45 +31,55 @@
#include <tools/ee_actions.h>
#include <tools/symbol_editor_control.h>
#include <widgets/wx_menubar.h>
#include <toolbars_symbol_viewer.h>
std::optional<TOOLBAR_CONFIGURATION> SYMBOL_VIEWER_FRAME::DefaultTopMainToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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 );
}

View File

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

View File

@ -34,6 +34,7 @@
#include <drawing_sheet/ds_proxy_view_item.h>
#include <lset.h>
#include <settings/settings_manager.h>
#include <toolbars_gerber.h>
#include <tool/tool_manager.h>
#include <tool/action_toolbar.h>
#include <tool/tool_dispatcher.h>
@ -149,6 +150,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupUIConditions();
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<GERBVIEW_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();

View File

@ -76,11 +76,6 @@ public:
bool LoadListOfGerberAndDrillFiles( const wxString& aPath, const wxArrayString& aFilenameList,
std::vector<int>* aFileType );
// No right toolbar in gerbview
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopAuxToolbarConfig() override;
void UpdateStatusBar() override;
GERBVIEW_SETTINGS* gvconfig() const;

View File

@ -34,91 +34,85 @@
#include <tools/gerbview_actions.h>
#include "widgets/gbr_layer_box_selector.h"
#include "widgets/dcode_selection_box.h"
#include <toolbars_gerber.h>
std::optional<TOOLBAR_CONFIGURATION> GERBVIEW_FRAME::DefaultLeftToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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 _("<No selection>")

View File

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

View File

@ -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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<const wxString, TOOL_ACTION*> m_acceptedExts;
// Current toolbar configuration
std::optional<TOOLBAR_CONFIGURATION> m_tbConfigLeft;
std::optional<TOOLBAR_CONFIGURATION> m_tbConfigRight;
std::optional<TOOLBAR_CONFIGURATION> m_tbConfigTopAux;
std::optional<TOOLBAR_CONFIGURATION> m_tbConfigTopMain;
// Toolbar Settings
std::unique_ptr<TOOLBAR_SETTINGS> 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<ACTION_TOOLBAR_CONTROL> m_toolbarControlFactories;
std::map<std::string, ACTION_TOOLBAR_CONTROL_FACTORY> m_toolbarControlFactories;
};

View File

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

View File

@ -188,6 +188,8 @@ protected:
std::map<int, BITMAP_BUTTON*> 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<ACTION_TOOLBAR_CONTROL*>& GetCustomControlList()
{
static std::list<ACTION_TOOLBAR_CONTROL*> m_controls;
return m_controls;
}
static constexpr bool TOGGLE = true;
static constexpr bool CANCEL = true;
@ -409,27 +420,53 @@ protected:
*/
typedef std::function<void ( ACTION_TOOLBAR* )> 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

View File

@ -30,6 +30,7 @@
#include <settings/json_settings.h>
#include <settings/parameters.h>
#include <tool/action_toolbar.h>
#include <tool/tool_action.h>
@ -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<std::string> 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<std::string,TOOLBAR_CONFIGURATION> m_Toolbars;
/**
* Get the default tools to show on the specified canvas toolbar.
*/
virtual std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> GetToolbarConfig( TOOLBAR_LOC aToolbar, bool aForceDefault );
protected:
// The toolbars - only public to aid in JSON serialization/deserialization
std::map<TOOLBAR_LOC, TOOLBAR_CONFIGURATION> m_toolbars;
};
#endif /* TOOLBAR_CONFIGURATION_H_ */

View File

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

View File

@ -60,6 +60,7 @@
#include <tool/tool_manager.h>
#include <tools/kicad_manager_actions.h>
#include <tools/kicad_manager_control.h>
#include <toolbars_kicad_manager.h>
#include <wildcards_and_files_ext.h>
#include <widgets/app_progress_dialog.h>
#include <widgets/kistatusbar.h>
@ -201,6 +202,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<KICAD_MANAGER_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -194,9 +194,6 @@ public:
// Used only on Windows: stores the info message about file watcher
wxString m_FileWatcherInfo;
// Toolbar defaults
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
DECLARE_EVENT_TABLE()
protected:

View File

@ -228,26 +228,3 @@ void KICAD_MANAGER_FRAME::doReCreateMenuBar()
SetMenuBar( menuBar );
delete oldMenuBar;
}
std::optional<TOOLBAR_CONFIGURATION> 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;
}

View File

@ -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 <tools/kicad_manager_actions.h>
#include <toolbars_kicad_manager.h>
std::optional<TOOLBAR_CONFIGURATION> 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;
}

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_KICAD_MANAGER_H_
#define TOOLBARS_KICAD_MANAGER_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_KICAD_MANAGER_H_ */

View File

@ -49,6 +49,7 @@
#include "pl_editor_id.h"
#include "pl_editor_settings.h"
#include "properties_frame.h"
#include <toolbars_pl_editor.h>
#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<PL_EDITOR_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();

View File

@ -98,11 +98,6 @@ public:
// The Tool Framework initialization
void setupTools();
// Currently no top auxillary toolbar
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultRightToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void UpdateToolbarControlSizes() override;
void SetPageSettings(const PAGE_INFO&) override;

View File

@ -28,87 +28,81 @@
#include "pl_editor_id.h"
#include "pl_editor_frame.h"
#include <toolbars_pl_editor.h>
std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_FRAME::DefaultLeftToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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<PL_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<PL_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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

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_PL_EDITOR_H_
#define TOOLBARS_PL_EDITOR_H_
#include <tool/action_toolbar.h>
#include <tool/ui/toolbar_configuration.h>
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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_PL_EDITOR_H_ */

View File

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

View File

@ -75,6 +75,7 @@
#include <widgets/wx_progress_reporters.h>
#include <wildcards_and_files_ext.h>
#include <widgets/wx_aui_utils.h>
#include <toolbars_footprint_editor.h>
#include <wx/filedlg.h>
#include <wx/hyperlink.h>
@ -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<FOOTPRINT_EDIT_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
ReCreateLayerBox( false );
ReCreateMenuBar();
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );

View File

@ -114,11 +114,6 @@ public:
*/
void HardRedraw() override;
// Default toolbar configuration
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultRightToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> 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..

View File

@ -49,6 +49,7 @@
#include <project_pcb.h>
#include <project/project_file.h>
#include <settings/settings_manager.h>
#include <toolbars_footprint_viewer.h>
#include <tool/action_toolbar.h>
#include <tool/common_control.h>
#include <tool/common_tools.h>
@ -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<FOOTPRINT_VIEWER_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -105,10 +105,6 @@ public:
void HardRedraw() override;
// Toolbar defaults
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
protected:
FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent );

View File

@ -53,6 +53,7 @@
#include "tools/pcb_selection_tool.h"
#include "tools/pcb_control.h"
#include "tools/pcb_actions.h"
#include <toolbars_footprint_wizard.h>
#include <python/scripting/pcb_scripting_tool.h>
@ -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<FOOTPRINT_WIZARD_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
@ -569,52 +571,6 @@ void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const
}
std::optional<TOOLBAR_CONFIGURATION> 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();

View File

@ -147,9 +147,6 @@ private:
*/
void DisplayWizardInfos();
// Toolbar defaults
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
void doCloseWindow() override;
void ClickOnPageList( wxCommandEvent& event );

View File

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

View File

@ -265,7 +265,6 @@ protected:
std::unique_ptr<LAYER_PAIR_SETTINGS> 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

View File

@ -116,6 +116,7 @@
#include <view/wx_view_controls.h>
#include <footprint_viewer_frame.h>
#include <footprint_chooser_frame.h>
#include <toolbars_pcb_editor.h>
#ifdef KICAD_IPC_API
#include <api/api_server.h>
@ -266,8 +267,12 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<PCB_EDIT_TOOLBAR_SETTINGS>();
configureToolbars();
RecreateToolbars();
PrepareLayerIndicator( true );
ReCreateMenuBar();
#ifdef KICAD_IPC_API

View File

@ -725,11 +725,6 @@ public:
DIALOG_BOOK_REPORTER* GetFootprintDiffDialog();
std::optional<TOOLBAR_CONFIGURATION> DefaultLeftToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultRightToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopMainToolbarConfig() override;
std::optional<TOOLBAR_CONFIGURATION> DefaultTopAuxToolbarConfig() override;
DECLARE_EVENT_TABLE()
protected:

View File

@ -34,156 +34,149 @@
#include <wx/wupdlock.h>
#include <advanced_config.h>
std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_FRAME::DefaultLeftToolbarConfig()
#include <toolbars_footprint_editor.h>
std::optional<TOOLBAR_CONFIGURATION> 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<PCB_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> 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<PCB_SELECTION_TOOL>();
auto makeArcMenu = [&]()
switch( aToolbar )
{
std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_FRAME::DefaultTopMainToolbarConfig()
{
TOOLBAR_CONFIGURATION config;
/* TODO (ISM): Implement context menus
PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<PCB_SELECTION_TOOL>();
config.AppendSeparator()
.AppendAction( PCB_ACTIONS::footprintProperties )
.AppendAction( PCB_ACTIONS::defaultPadProperties )
.AppendAction( ACTIONS::showDatasheet )
.AppendAction( PCB_ACTIONS::checkFootprint );
auto makeArcMenu = [&]()
{
std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( 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;

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_FOOTPRINT_EDITOR_H_
#define TOOLBARS_FOOTPRINT_EDITOR_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_FOOTPRINT_EDITOR_H_ */

View File

@ -34,62 +34,65 @@
#include <widgets/wx_menubar.h>
#include <wx/choice.h>
#include <toolbars_footprint_viewer.h>
std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_VIEWER_FRAME::DefaultTopMainToolbarConfig()
std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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;

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_FOOTPRINT_VIEWER_H_
#define TOOLBARS_FOOTPRINT_VIEWER_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_FOOTPRINT_VIEWER_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 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 <tools/pcb_actions.h>
#include <toolbars_footprint_wizard.h>
std::optional<TOOLBAR_CONFIGURATION> 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;
}

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_FOOTPRINT_WIZARD_H_
#define TOOLBARS_FOOTPRINT_WIZARD_H_
#include <tool/ui/toolbar_configuration.h>
/**
* 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<TOOLBAR_CONFIGURATION> DefaultToolbarConfig( TOOLBAR_LOC aToolbar ) override;
};
#endif /* TOOLBARS_FOOTPRINT_WIZARD_H_ */

View File

@ -58,7 +58,7 @@
#include <widgets/wx_aui_utils.h>
#include <wx/wupdlock.h>
#include <wx/combobox.h>
#include <toolbars_pcb_editor.h>
#include <settings/settings_manager.h>
#include "../scripting/python_scripting.h"
@ -120,253 +120,239 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
}
std::optional<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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<PCB_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<PCB_SELECTION_TOOL>();
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( 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<PCB_SELECTION_TOOL>();
auto makeArcMenu = [&]()
{
std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( 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<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( 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<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> 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<PCB_SELECTION_TOOL>();
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<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( 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<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( 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<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( 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<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( 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<TOOLBAR_CONFIGURATION> 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<TOOLBAR_CONFIGURATION> 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" );

View File

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