KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TOOLBAR_CONTEXT_MENU_REGISTRY Class Reference

Registry for toolbar context menu factories. More...

#include <toolbar_context_menu_registry.h>

Public Types

using MENU_FACTORY = std::function<std::unique_ptr<ACTION_MENU>( TOOL_MANAGER* )>
 Factory function type: takes TOOL_MANAGER, returns owned ACTION_MENU.
 

Static Public Member Functions

static void RegisterMenuFactory (const std::string &aActionName, MENU_FACTORY aFactory)
 Register a context menu factory for an action.
 
static void RegisterGroupMenuFactory (const std::string &aGroupName, MENU_FACTORY aFactory)
 Register a context menu factory for a toolbar group.
 
static MENU_FACTORY GetMenuFactory (const std::string &aActionName)
 Get the menu factory for an action, if one is registered.
 
static MENU_FACTORY GetGroupMenuFactory (const std::string &aGroupName)
 Get the menu factory for a group, if one is registered.
 

Static Private Member Functions

static std::map< std::string, MENU_FACTORY > & getActionMenus ()
 
static std::map< std::string, MENU_FACTORY > & getGroupMenus ()
 

Detailed Description

Registry for toolbar context menu factories.

This allows context menus to be associated with actions and groups by name, so that JSON-loaded toolbar configurations can get the same menus as code-defined default configurations.

Definition at line 44 of file toolbar_context_menu_registry.h.

Member Typedef Documentation

◆ MENU_FACTORY

using TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY = std::function<std::unique_ptr<ACTION_MENU>( TOOL_MANAGER* )>

Factory function type: takes TOOL_MANAGER, returns owned ACTION_MENU.

Definition at line 48 of file toolbar_context_menu_registry.h.

Member Function Documentation

◆ getActionMenus()

std::map< std::string, TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY > & TOOLBAR_CONTEXT_MENU_REGISTRY::getActionMenus ( )
staticprivate

Definition at line 28 of file toolbar_context_menu_registry.cpp.

Referenced by GetMenuFactory(), and RegisterMenuFactory().

◆ GetGroupMenuFactory()

KICOMMON_API TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY TOOLBAR_CONTEXT_MENU_REGISTRY::GetGroupMenuFactory ( const std::string & aGroupName)
static

Get the menu factory for a group, if one is registered.

Parameters
aGroupNameThe group name to look up
Returns
The factory function, or nullptr if not registered

Definition at line 71 of file toolbar_context_menu_registry.cpp.

References getGroupMenus().

Referenced by ACTION_TOOLBAR::ApplyConfiguration().

◆ getGroupMenus()

std::map< std::string, TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY > & TOOLBAR_CONTEXT_MENU_REGISTRY::getGroupMenus ( )
staticprivate

◆ GetMenuFactory()

KICOMMON_API TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY TOOLBAR_CONTEXT_MENU_REGISTRY::GetMenuFactory ( const std::string & aActionName)
static

Get the menu factory for an action, if one is registered.

Parameters
aActionNameThe action name to look up
Returns
The factory function, or nullptr if not registered

Definition at line 58 of file toolbar_context_menu_registry.cpp.

References getActionMenus().

Referenced by ACTION_TOOLBAR::ApplyConfiguration().

◆ RegisterGroupMenuFactory()

KICOMMON_API void TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterGroupMenuFactory ( const std::string & aGroupName,
MENU_FACTORY aFactory )
static

Register a context menu factory for a toolbar group.

Parameters
aGroupNameThe group name (from TOOLBAR_GROUP_CONFIG)
aFactoryFactory function that creates the menu

Definition at line 50 of file toolbar_context_menu_registry.cpp.

References getGroupMenus(), and KICOMMON_API.

Referenced by TOOLBAR_GROUP_CONFIG::AddContextMenu().

◆ RegisterMenuFactory()

KICOMMON_API void TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterMenuFactory ( const std::string & aActionName,
MENU_FACTORY aFactory )
static

Register a context menu factory for an action.

Parameters
aActionNameThe action name (from TOOL_ACTION::GetName())
aFactoryFactory function that creates the menu

Definition at line 43 of file toolbar_context_menu_registry.cpp.

References getActionMenus(), and KICOMMON_API.

Referenced by TOOLBAR_ITEM_REF::WithContextMenu().


The documentation for this class was generated from the following files: