KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbar_context_menu_registry.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include <
tool/ui/toolbar_context_menu_registry.h
>
21
22
23
std::map<std::string, TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY>&
24
TOOLBAR_CONTEXT_MENU_REGISTRY::getActionMenus
()
25
{
26
static
std::map<std::string, MENU_FACTORY> s_actionMenus;
27
return
s_actionMenus;
28
}
29
30
31
std::map<std::string, TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY>&
32
TOOLBAR_CONTEXT_MENU_REGISTRY::getGroupMenus
()
33
{
34
static
std::map<std::string, MENU_FACTORY> s_groupMenus;
35
return
s_groupMenus;
36
}
37
38
39
KICOMMON_API
void
TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterMenuFactory
(
const
std::string& aActionName,
40
MENU_FACTORY
aFactory )
41
{
42
getActionMenus
()[aActionName] = std::move( aFactory );
43
}
44
45
46
KICOMMON_API
void
TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterGroupMenuFactory
(
const
std::string& aGroupName,
47
MENU_FACTORY
aFactory )
48
{
49
getGroupMenus
()[aGroupName] = std::move( aFactory );
50
}
51
52
53
KICOMMON_API
TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY
54
TOOLBAR_CONTEXT_MENU_REGISTRY::GetMenuFactory
(
const
std::string& aActionName )
55
{
56
auto
& menus =
getActionMenus
();
57
auto
it = menus.find( aActionName );
58
59
if
( it != menus.end() )
60
return
it->second;
61
62
return
nullptr
;
63
}
64
65
66
KICOMMON_API
TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY
67
TOOLBAR_CONTEXT_MENU_REGISTRY::GetGroupMenuFactory
(
const
std::string& aGroupName )
68
{
69
auto
& menus =
getGroupMenus
();
70
auto
it = menus.find( aGroupName );
71
72
if
( it != menus.end() )
73
return
it->second;
74
75
return
nullptr
;
76
}
TOOLBAR_CONTEXT_MENU_REGISTRY::GetMenuFactory
static MENU_FACTORY GetMenuFactory(const std::string &aActionName)
Get the menu factory for an action, if one is registered.
Definition
toolbar_context_menu_registry.cpp:54
TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterGroupMenuFactory
static void RegisterGroupMenuFactory(const std::string &aGroupName, MENU_FACTORY aFactory)
Register a context menu factory for a toolbar group.
Definition
toolbar_context_menu_registry.cpp:46
TOOLBAR_CONTEXT_MENU_REGISTRY::RegisterMenuFactory
static void RegisterMenuFactory(const std::string &aActionName, MENU_FACTORY aFactory)
Register a context menu factory for an action.
Definition
toolbar_context_menu_registry.cpp:39
TOOLBAR_CONTEXT_MENU_REGISTRY::MENU_FACTORY
std::function< std::unique_ptr< ACTION_MENU >(TOOL_MANAGER *)> MENU_FACTORY
Factory function type: takes TOOL_MANAGER, returns owned ACTION_MENU.
Definition
toolbar_context_menu_registry.h:44
TOOLBAR_CONTEXT_MENU_REGISTRY::GetGroupMenuFactory
static MENU_FACTORY GetGroupMenuFactory(const std::string &aGroupName)
Get the menu factory for a group, if one is registered.
Definition
toolbar_context_menu_registry.cpp:67
TOOLBAR_CONTEXT_MENU_REGISTRY::getActionMenus
static std::map< std::string, MENU_FACTORY > & getActionMenus()
Definition
toolbar_context_menu_registry.cpp:24
TOOLBAR_CONTEXT_MENU_REGISTRY::getGroupMenus
static std::map< std::string, MENU_FACTORY > & getGroupMenus()
Definition
toolbar_context_menu_registry.cpp:32
KICOMMON_API
#define KICOMMON_API
Definition
kicommon.h:27
toolbar_context_menu_registry.h
src
common
tool
ui
toolbar_context_menu_registry.cpp
Generated on Fri Jun 26 2026 00:05:33 for KiCad PCB EDA Suite by
1.13.2