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

Tweak toolbar settings a bit

* Manage the settings using the settings manager for better lifetimes
* Better architect the internals and JSON to make it easier to identify
  the various tool types
This commit is contained in:
Ian McInerney 2025-02-27 02:51:29 +00:00
parent ab114c4159
commit 85810510f4
44 changed files with 463 additions and 242 deletions

View File

@ -149,7 +149,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<EDA_3D_VIEWER_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<EDA_3D_VIEWER_TOOLBAR_SETTINGS>( "3d_viewer-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -29,7 +29,7 @@ class EDA_3D_VIEWER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
EDA_3D_VIEWER_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "3d_viewer" )
TOOLBAR_SETTINGS( "3d_viewer-toolbars" )
{}
~EDA_3D_VIEWER_TOOLBAR_SETTINGS() {}

View File

@ -603,8 +603,8 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
m_GitProjectStatusRefreshInterval, 0, 100000 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ConfigurableToolbars,
&m_ConfigurableToolbars,
m_ConfigurableToolbars ) );
&m_ConfigurableToolbars,
m_ConfigurableToolbars ) );
// Special case for trace mask setting...we just grab them and set them immediately
// Because we even use wxLogTrace inside of advanced config

View File

@ -41,27 +41,15 @@ enum
};
enum class TOOLBAR_TREE_ITEM_TYPE
{
TOOL,
GROUP,
SPACER,
SEPARATOR
};
class TOOLBAR_TREE_ITEM_DATA : public wxTreeItemData
{
public:
TOOLBAR_TREE_ITEM_DATA( TOOLBAR_TREE_ITEM_TYPE aType ) :
TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE aType ) :
wxTreeItemData(),
m_name( "" ),
m_action( nullptr ),
m_type( aType )
{
// Hard-code the name for the separator
if( aType == TOOLBAR_TREE_ITEM_TYPE::SEPARATOR )
m_name = "separator";
}
{}
void SetAction( TOOL_ACTION* aAction ) { m_action = aAction; }
TOOL_ACTION* GetAction() const { return m_action; }
@ -69,13 +57,17 @@ public:
void SetName( std::string aName ) { m_name = aName; }
std::string GetName() const { return m_name; }
TOOLBAR_TREE_ITEM_TYPE GetType() const { return m_type; }
void SetToolbarItem( TOOLBAR_ITEM& aItem ) { m_item = aItem; }
TOOLBAR_ITEM GetToolbarItem() const { return m_item; }
TOOLBAR_ITEM_TYPE GetType() const { return m_type; }
private:
std::string m_name;
TOOL_ACTION* m_action;
TOOLBAR_ITEM m_item;
TOOLBAR_TREE_ITEM_TYPE m_type;
TOOLBAR_ITEM_TYPE m_type;
};
@ -154,6 +146,8 @@ bool PANEL_TOOLBAR_CUSTOMIZATION::TransferDataToWindow()
bool PANEL_TOOLBAR_CUSTOMIZATION::TransferDataFromWindow()
{
m_appSettings->m_CustomToolbars = m_customToolbars->GetValue();
return true;
}
@ -167,30 +161,67 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree( const TOOLBAR_CONFIGURATI
for( auto& item : aToolbar.GetToolbarItems() )
{
if( item == "separator" )
switch( item.m_Type )
{
// Add a separator
TOOLBAR_TREE_ITEM_DATA* sepTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_TREE_ITEM_TYPE::SEPARATOR );
m_toolbarTree->AppendItem( root, "Separator", -1, -1, sepTreeItem );
}
else if( item.starts_with( "group" ) )
{
// Add a group of items to the toolbar
const TOOLBAR_GROUP_CONFIG* groupConfig = aToolbar.GetGroup( item );
if( !groupConfig )
case TOOLBAR_ITEM_TYPE::SEPARATOR:
{
wxASSERT_MSG( false, wxString::Format( "Unable to find group %s", item ) );
// Add a separator
TOOLBAR_TREE_ITEM_DATA* sepTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::SEPARATOR );
sepTreeItem->SetToolbarItem( item );
m_toolbarTree->AppendItem( root, "Separator", -1, -1, sepTreeItem );
break;
}
case TOOLBAR_ITEM_TYPE::SPACER:
{
// Add a spacer
TOOLBAR_TREE_ITEM_DATA* spacerTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::SPACER );
spacerTreeItem->SetToolbarItem( item );
m_toolbarTree->AppendItem( root, wxString::Format( "Spacer: %s", item.m_Size ), -1, -1, spacerTreeItem );
break;
}
case TOOLBAR_ITEM_TYPE::CONTROL:
// TODO
break;
case TOOLBAR_ITEM_TYPE::TOOL:
{
// Add a tool
auto toolMap = m_availableTools.find( item.m_ActionName );
if( toolMap == m_availableTools.end() )
{
wxASSERT_MSG( false, wxString::Format( "Unable to find tool %s", item.m_ActionName ) );
continue;
}
TOOLBAR_TREE_ITEM_DATA* groupTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_TREE_ITEM_TYPE::GROUP );
groupTreeItem->SetName( item );
TOOLBAR_TREE_ITEM_DATA* toolTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::TOOL );
toolTreeItem->SetName( item.m_ActionName );
toolTreeItem->SetAction( toolMap->second );
toolTreeItem->SetToolbarItem( item );
wxTreeItemId groupId = m_toolbarTree->AppendItem( root, item, -1, -1, groupTreeItem );
int imgIdx = -1;
auto imgMap = m_actionImageListMap.find( item.m_ActionName );
if( imgMap != m_actionImageListMap.end() )
imgIdx = imgMap->second;
m_toolbarTree->AppendItem( root, toolMap->second->GetFriendlyName(),
imgIdx, -1, toolTreeItem );
break;
}
case TOOLBAR_ITEM_TYPE::GROUP:
{
// Add a group of items to the toolbar
TOOLBAR_TREE_ITEM_DATA* groupTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::GROUP );
groupTreeItem->SetToolbarItem( item );
wxTreeItemId groupId = m_toolbarTree->AppendItem( root, item.m_GroupName, -1, -1, groupTreeItem );
// Add the elements below the group
for( auto& groupItem : groupConfig->GetGroupItems() )
for( auto& groupItem : item.m_GroupItems )
{
auto toolMap = m_availableTools.find( groupItem );
@ -200,7 +231,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree( const TOOLBAR_CONFIGURATI
continue;
}
TOOLBAR_TREE_ITEM_DATA* toolTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_TREE_ITEM_TYPE::TOOL );
TOOLBAR_TREE_ITEM_DATA* toolTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::TOOL );
toolTreeItem->SetName( groupItem );
toolTreeItem->SetAction( toolMap->second );
@ -213,39 +244,8 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree( const TOOLBAR_CONFIGURATI
m_toolbarTree->AppendItem( groupId, toolMap->second->GetFriendlyName(),
imgIdx, -1, toolTreeItem );
}
}
else if( item.starts_with( "control" ) )
{
// Add a custom control to the toolbar
}
else if( item.starts_with( "spacer" ) )
{
}
else
{
// Add a tool
auto toolMap = m_availableTools.find( item );
if( toolMap == m_availableTools.end() )
{
wxASSERT_MSG( false, wxString::Format( "Unable to find tool %s", item ) );
continue;
break;
}
TOOLBAR_TREE_ITEM_DATA* toolTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_TREE_ITEM_TYPE::TOOL );
toolTreeItem->SetName( item );
toolTreeItem->SetAction( toolMap->second );
int imgIdx = -1;
auto imgMap = m_actionImageListMap.find( item );
if( imgMap != m_actionImageListMap.end() )
imgIdx = imgMap->second;
m_toolbarTree->AppendItem( root, toolMap->second->GetFriendlyName(),
imgIdx, -1, toolTreeItem );
}
}

View File

@ -514,7 +514,6 @@ ACTION_TOOLBAR_CONTROL_FACTORY* EDA_BASE_FRAME::GetCustomToolbarControlFactory(
void EDA_BASE_FRAME::configureToolbars()
{
m_toolbarSettings->LoadFromFile( Pgm().GetSettingsManager().GetToolbarSettingsPath() );
}
@ -522,7 +521,7 @@ void EDA_BASE_FRAME::RecreateToolbars()
{
wxWindowUpdateLocker dummy( this );
wxASSERT( m_toolbarSettings.get() );
wxASSERT( m_toolbarSettings );
std::optional<TOOLBAR_CONFIGURATION> tbConfig;
@ -1300,6 +1299,9 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_COLORS ), _( "Colors" ) );
if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_TOOLBARS ), _( "Toolbars" ) );
if( GetFrameType() == FRAME_SCH )
expand.push_back( (int) book->GetPageCount() );
@ -1339,6 +1341,10 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_ORIGINS_AXES ), _( "Origins & Axes" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_COLORS ), _( "Colors" ) );
if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_TOOLBARS ), _( "Toolbars" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_FIELDS ), _( "Footprint Defaults" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_GRAPHICS_VALUES ),
_( "Graphics Defaults" ) );
@ -1363,6 +1369,10 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_TOOLBARS ), _( "Toolbars" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
}
@ -1385,6 +1395,10 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_COLORS ), _( "Colors" ) );
if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_TOOLBARS ), _( "Toolbars" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_GRIDS ), _( "Grids" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_EXCELLON_OPTIONS ),
_( "Excellon Options" ) );
@ -1410,6 +1424,9 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddLazySubPage( LAZY_CTOR( PANEL_DS_GRIDS ), _( "Grids" ) );
book->AddLazySubPage( LAZY_CTOR( PANEL_DS_COLORS ), _( "Colors" ) );
if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
book->AddLazySubPage( LAZY_CTOR( PANEL_DS_TOOLBARS ), _( "Toolbars" ) );
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{

View File

@ -458,6 +458,9 @@ wxString SETTINGS_MANAGER::GetPathForSettingsFile( JSON_SETTINGS* aSettings )
case SETTINGS_LOC::COLORS:
return GetColorSettingsPath();
case SETTINGS_LOC::TOOLBARS:
return GetToolbarSettingsPath();
case SETTINGS_LOC::NONE:
return "";

View File

@ -265,79 +265,73 @@ void ACTION_TOOLBAR::ApplyConfiguration( const TOOLBAR_CONFIGURATION& aConfig )
// Remove existing tools
ClearToolbar();
std::vector<std::string> items = aConfig.GetToolbarItems();
std::vector<TOOLBAR_ITEM> items = aConfig.GetToolbarItems();
// Add all the items to the toolbar
for( auto& actionName : items )
for( auto& item : items )
{
if( actionName == "separator" )
switch( item.m_Type )
{
// Add a separator
case TOOLBAR_ITEM_TYPE::SEPARATOR:
AddScaledSeparator( GetParent() );
}
else if( actionName.starts_with( "group" ) )
{
// Add a group of items to the toolbar
const TOOLBAR_GROUP_CONFIG* groupConfig = aConfig.GetGroup( actionName );
break;
if( !groupConfig )
case TOOLBAR_ITEM_TYPE::SPACER:
AddSpacer( item.m_Size );
break;
case TOOLBAR_ITEM_TYPE::GROUP:
{
wxASSERT_MSG( false, wxString::Format( "Unable to find group %s", actionName ) );
continue;
}
// Add a group of items to the toolbar
std::vector<const TOOL_ACTION*> tools;
for( auto& groupItem : groupConfig->GetGroupItems() )
for( auto& groupItem : item.m_GroupItems )
{
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( groupItem );
if( !action )
{
wxASSERT_MSG( false, wxString::Format( "Unable to find group tool %s", actionName ) );
wxASSERT_MSG( false, wxString::Format( "Unable to find group tool %s", groupItem ) );
continue;
}
tools.push_back( action );
}
AddGroup( std::make_unique<ACTION_GROUP>( groupConfig->GetName(), tools ) );
}
else if( actionName.starts_with( "control" ) )
{
AddGroup( std::make_unique<ACTION_GROUP>( item.m_GroupName.ToStdString(), tools ) );
break;
}
case TOOLBAR_ITEM_TYPE::CONTROL:
{
// Add a custom control to the toolbar
EDA_BASE_FRAME* frame = static_cast<EDA_BASE_FRAME*>( GetParent() );
ACTION_TOOLBAR_CONTROL_FACTORY* factory = frame->GetCustomToolbarControlFactory( actionName );
ACTION_TOOLBAR_CONTROL_FACTORY* factory = frame->GetCustomToolbarControlFactory( item.m_ControlName );
if( !factory )
{
wxASSERT_MSG( false, wxString::Format( "Unable to find control factory for %s", actionName ) );
wxASSERT_MSG( false, wxString::Format( "Unable to find control factory for %s", item.m_ControlName ) );
continue;
}
// The factory functions are responsible for adding the controls to the toolbar themselves
(*factory)( this );
}
else if( actionName.starts_with( "spacer" ) )
{
// Extract the spacer size from the text, it is the form "spacer:x", with "x" being the size
int sep = actionName.find_last_of( ":" );
int spacerSize = std::stoi( actionName.substr( sep+1 ) );
break;
}
AddSpacer( spacerSize );
}
else
{
// Assume anything else is an action
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName );
case TOOLBAR_ITEM_TYPE::TOOL:
{
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( item.m_ActionName );
if( !action )
{
wxASSERT_MSG( false, wxString::Format( "Unable to find toolbar tool %s", actionName ) );
wxASSERT_MSG( false, wxString::Format( "Unable to find toolbar tool %s", item.m_ActionName ) );
continue;
}
Add( *action );
break;
}
}
}

View File

@ -34,35 +34,47 @@ const int toolbarSchemaVersion = 1;
void to_json( nlohmann::json& aJson, const TOOLBAR_CONFIGURATION& aConfig )
{
nlohmann::json groups = nlohmann::json::array();
aJson = nlohmann::json::array();
// Serialize the group object
for( const TOOLBAR_GROUP_CONFIG& grp : aConfig.m_toolbarGroups )
for( const TOOLBAR_ITEM& item : aConfig.m_toolbarItems )
{
nlohmann::json jsGrp = {
{ "name", grp.m_groupName }
nlohmann::json jsItem = {
{ "type", magic_enum::enum_name( item.m_Type ) }
};
nlohmann::json grpItems = nlohmann::json::array();
switch( item.m_Type )
{
case TOOLBAR_ITEM_TYPE::SEPARATOR:
// Nothing to add for a separator
break;
for( const auto& it : grp.m_groupItems )
grpItems.push_back( it );
case TOOLBAR_ITEM_TYPE::SPACER:
jsItem["size"] = item.m_Size;
break;
jsGrp["items"] = grpItems;
case TOOLBAR_ITEM_TYPE::CONTROL:
jsItem["name"] = item.m_ControlName;
break;
groups.push_back( jsGrp );
case TOOLBAR_ITEM_TYPE::TOOL:
jsItem["name"] = item.m_ActionName;
break;
case TOOLBAR_ITEM_TYPE::GROUP:
jsItem["group_name"] = item.m_GroupName;
nlohmann::json grpItems = nlohmann::json::array();
for( const auto& it : item.m_GroupItems )
grpItems.push_back( it );
jsItem["group_items"] = grpItems;
break;
}
aJson.push_back( jsItem );
}
// Serialize the items
nlohmann::json tbItems = nlohmann::json::array();
for( const auto& it : aConfig.m_toolbarItems )
tbItems.push_back( it );
aJson = {
{ "groups", groups },
{ "items", tbItems }
};
}
@ -72,47 +84,70 @@ void from_json( const nlohmann::json& aJson, TOOLBAR_CONFIGURATION& aConfig )
return;
aConfig.m_toolbarItems.clear();
aConfig.m_toolbarGroups.clear();
// Deserialize the groups
if( aJson.contains( "groups" ) && aJson.at( "groups" ).is_array())
if( aJson.is_array() )
{
for( const nlohmann::json& grp : aJson.at( "groups" ) )
for( const nlohmann::json& item : aJson )
{
std::string name = "";
TOOLBAR_ITEM tbItem;
if( grp.contains( "name" ) )
name = grp.at( "name" ).get<std::string>();
TOOLBAR_GROUP_CONFIG cfg( name );
// Deserialize the items
if( grp.contains( "items" ) )
if( item.contains( "type" ) )
{
for( const nlohmann::json& it : grp.at( "items" ) )
{
if( it.is_string() )
cfg.m_groupItems.push_back( it.get<std::string>() );
}
}
aConfig.m_toolbarGroups.push_back( cfg );
}
}
auto type = magic_enum::enum_cast<TOOLBAR_ITEM_TYPE>( item["type"].get<std::string>(),
magic_enum::case_insensitive );
// Deserialize the items
if( aJson.contains( "items" ) )
{
for( const nlohmann::json& it : aJson.at( "items" ) )
{
if( it.is_string() )
aConfig.m_toolbarItems.push_back( it.get<std::string>() );
if( type.has_value() )
tbItem.m_Type = type.value();
}
switch( tbItem.m_Type )
{
case TOOLBAR_ITEM_TYPE::SEPARATOR:
// Nothing to read for a separator
break;
case TOOLBAR_ITEM_TYPE::SPACER:
if( item.contains( "size" ) )
tbItem.m_Size = item["size"].get<int>();
break;
case TOOLBAR_ITEM_TYPE::CONTROL:
if( item.contains( "name" ) )
tbItem.m_ControlName = item["name"].get<std::string>();
break;
case TOOLBAR_ITEM_TYPE::TOOL:
if( item.contains( "name" ) )
tbItem.m_ActionName = item["name"].get<std::string>();
break;
case TOOLBAR_ITEM_TYPE::GROUP:
if( item.contains( "group_name" ) )
tbItem.m_GroupName = item["group_name"].get<wxString>();
if( item.contains( "group_items" ) )
{
for( const nlohmann::json& it : item["group_items"].at( "group_items" ) )
{
if( it.is_string() )
tbItem.m_GroupItems.push_back( it.get<std::string>() );
}
}
break;
}
// We just directly add the item to the config
aConfig.m_toolbarItems.push_back( tbItem );
}
}
}
TOOLBAR_SETTINGS::TOOLBAR_SETTINGS( const wxString& aFullPath ) :
JSON_SETTINGS( aFullPath, SETTINGS_LOC::NONE, toolbarSchemaVersion )
JSON_SETTINGS( aFullPath, SETTINGS_LOC::TOOLBARS, toolbarSchemaVersion )
{
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "toolbars",
[&]() -> nlohmann::json

View File

@ -47,6 +47,7 @@
#include <cvpcb_association.h>
#include <cvpcb_id.h>
#include <cvpcb_mainframe.h>
#include <settings/settings_manager.h>
#include <settings/cvpcb_settings.h>
#include <display_footprints_frame.h>
#include <kiplatform/ui.h>
@ -93,7 +94,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<CVPCB_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<CVPCB_TOOLBAR_SETTINGS>( "cvpcb-toolbars" );
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -116,7 +116,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
setupUIConditions();
m_toolbarSettings = std::make_unique<DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS>( "display_footprints-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -36,7 +36,7 @@ class CVPCB_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
CVPCB_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "cvpcb" )
TOOLBAR_SETTINGS( "cvpcb-toolbars" )
{}
~CVPCB_TOOLBAR_SETTINGS() {}

View File

@ -29,7 +29,7 @@ class DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "display-footprints" )
TOOLBAR_SETTINGS( "display_footprints-toolbars" )
{}
~DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS() {}

View File

@ -259,6 +259,24 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
}
case PANEL_SYM_TOOLBARS:
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
TOOLBAR_SETTINGS* tb = mgr.GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
std::vector<TOOL_ACTION*> actions;
std::vector<ACTION_TOOLBAR_CONTROL*> controls;
for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
actions.push_back( action );
for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
controls.push_back( control );
return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
}
case PANEL_SYM_COLORS:
return new PANEL_SYM_COLOR_SETTINGS( aParent );
@ -314,8 +332,8 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
case PANEL_SCH_TOOLBARS:
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
TOOLBAR_SETTINGS* tb = new SCH_EDIT_TOOLBAR_SETTINGS();
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
TOOLBAR_SETTINGS* tb = mgr.GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
std::vector<TOOL_ACTION*> actions;
std::vector<ACTION_TOOLBAR_CONTROL*> controls;

View File

@ -191,7 +191,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupUIConditions();
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<SCH_EDIT_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>( "eeschema-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -58,6 +58,7 @@
#include <eeschema_settings.h>
#include <advanced_config.h>
#include <sim/toolbars_simulator_frame.h>
#include <settings/settings_manager.h>
#include <memory>
@ -169,7 +170,7 @@ SIMULATOR_FRAME::SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// was created.
m_tbTopMain->SetToolManager( m_toolManager );
m_toolbarSettings = std::make_unique<SIMULATOR_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<SIMULATOR_TOOLBAR_SETTINGS>( "sim-toolbars" );
configureToolbars();
RecreateToolbars();
ReCreateMenuBar();

View File

@ -29,7 +29,7 @@ class SIMULATOR_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
SIMULATOR_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "sim" )
TOOLBAR_SETTINGS( "sim-toolbars" )
{}
~SIMULATOR_TOOLBAR_SETTINGS() {}

View File

@ -181,7 +181,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<SYMBOL_EDIT_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>( "symbol_editor-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -29,7 +29,7 @@ class SYMBOL_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
SYMBOL_EDIT_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "symbol_editor" )
TOOLBAR_SETTINGS( "symbol_editor-toolbars" )
{}
~SYMBOL_EDIT_TOOLBAR_SETTINGS() {}

View File

@ -143,7 +143,7 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupTools();
setupUIConditions();
m_toolbarSettings = std::make_unique<SYMBOL_VIEWER_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<SYMBOL_VIEWER_TOOLBAR_SETTINGS>( "symbol_viewer-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -29,7 +29,7 @@ class SCH_EDIT_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
SCH_EDIT_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "eeschema" )
TOOLBAR_SETTINGS( "eeschema-toolbars" )
{}
~SCH_EDIT_TOOLBAR_SETTINGS

View File

@ -30,7 +30,7 @@ class SYMBOL_VIEWER_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
SYMBOL_VIEWER_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "symbol_viewer" )
TOOLBAR_SETTINGS( "symbol_viewer-toolbars" )
{}
~SYMBOL_VIEWER_TOOLBAR_SETTINGS() {}

View File

@ -44,6 +44,9 @@
#include <wildcards_and_files_ext.h>
#include <wx/ffile.h>
#include <dialogs/panel_toolbar_customization.h>
#include <toolbars_gerber.h>
using json = nlohmann::json;
@ -91,6 +94,24 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
case PANEL_GBR_COLORS:
return new PANEL_GERBVIEW_COLOR_SETTINGS( aParent );
case PANEL_GBR_TOOLBARS:
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
GERBVIEW_SETTINGS* cfg = mgr.GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
TOOLBAR_SETTINGS* tb = mgr.GetToolbarSettings<GERBVIEW_TOOLBAR_SETTINGS>( "gerbview-toolbars" );
std::vector<TOOL_ACTION*> actions;
std::vector<ACTION_TOOLBAR_CONTROL*> controls;
for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
actions.push_back( action );
for( ACTION_TOOLBAR_CONTROL* control : ACTION_TOOLBAR::GetCustomControlList() )
controls.push_back( control );
return new PANEL_TOOLBAR_CUSTOMIZATION( aParent, cfg, tb, actions, controls );
}
default:
;
}

View File

@ -150,7 +150,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
setupUIConditions();
ReCreateMenuBar();
m_toolbarSettings = std::make_unique<GERBVIEW_TOOLBAR_SETTINGS>();
m_toolbarSettings = Pgm().GetSettingsManager().GetToolbarSettings<GERBVIEW_TOOLBAR_SETTINGS>( "gerbview-toolbars" );
configureToolbars();
RecreateToolbars();

View File

@ -40,7 +40,7 @@ class GERBVIEW_TOOLBAR_SETTINGS : public TOOLBAR_SETTINGS
{
public:
GERBVIEW_TOOLBAR_SETTINGS() :
TOOLBAR_SETTINGS( "gerbview" )
TOOLBAR_SETTINGS( "gerbview-toolbars" )
{}
~GERBVIEW_TOOLBAR_SETTINGS() {}

View File

@ -830,8 +830,8 @@ private:
*/
std::map<const wxString, TOOL_ACTION*> m_acceptedExts;
// Toolbar Settings
std::unique_ptr<TOOLBAR_SETTINGS> m_toolbarSettings;
// Toolbar Settings - this is not owned by the frame
TOOLBAR_SETTINGS* m_toolbarSettings;
// Toolbar UI elements
ACTION_TOOLBAR* m_tbTopMain;

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