KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbar_context_menu_registry.h
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, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#ifndef TOOLBAR_CONTEXT_MENU_REGISTRY_H_
25
#define TOOLBAR_CONTEXT_MENU_REGISTRY_H_
26
27
#include <functional>
28
#include <map>
29
#include <memory>
30
#include <string>
31
32
#include <
kicommon.h
>
33
34
class
ACTION_MENU
;
35
class
TOOL_MANAGER
;
36
44
class
KICOMMON_API
TOOLBAR_CONTEXT_MENU_REGISTRY
45
{
46
public
:
48
using
MENU_FACTORY
= std::function<std::unique_ptr<ACTION_MENU>(
TOOL_MANAGER
* )>;
49
56
static
void
RegisterMenuFactory
(
const
std::string& aActionName,
MENU_FACTORY
aFactory );
57
64
static
void
RegisterGroupMenuFactory
(
const
std::string& aGroupName,
MENU_FACTORY
aFactory );
65
72
static
MENU_FACTORY
GetMenuFactory
(
const
std::string& aActionName );
73
80
static
MENU_FACTORY
GetGroupMenuFactory
(
const
std::string& aGroupName );
81
82
private
:
83
// Use Meyer's singleton to prevent SIOF
84
static
std::map<std::string, MENU_FACTORY>&
getActionMenus
();
85
static
std::map<std::string, MENU_FACTORY>&
getGroupMenus
();
86
};
87
88
#endif
/* TOOLBAR_CONTEXT_MENU_REGISTRY_H_ */
ACTION_MENU
Define the structure of a menu based on ACTIONs.
Definition
action_menu.h:47
TOOLBAR_CONTEXT_MENU_REGISTRY
Registry for toolbar context menu factories.
Definition
toolbar_context_menu_registry.h:45
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:58
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:50
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:43
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:48
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:71
TOOLBAR_CONTEXT_MENU_REGISTRY::getActionMenus
static std::map< std::string, MENU_FACTORY > & getActionMenus()
Definition
toolbar_context_menu_registry.cpp:28
TOOLBAR_CONTEXT_MENU_REGISTRY::getGroupMenus
static std::map< std::string, MENU_FACTORY > & getGroupMenus()
Definition
toolbar_context_menu_registry.cpp:36
TOOL_MANAGER
Master controller class:
Definition
tool_manager.h:62
kicommon.h
KICOMMON_API
#define KICOMMON_API
Definition
kicommon.h:28
src
include
tool
ui
toolbar_context_menu_registry.h
Generated on Fri Jan 9 2026 00:06:42 for KiCad PCB EDA Suite by
1.13.2