|
KiCad PCB EDA Suite
|
Manage TOOL_ACTION objects. More...
#include <action_manager.h>
Public Member Functions | |
| ACTION_MANAGER (TOOL_MANAGER *aToolManager) | |
| ~ACTION_MANAGER () | |
| Unregister every registered action. | |
| void | RegisterAction (TOOL_ACTION *aAction) |
| Add a tool action to the manager and sets it up. | |
| const std::map< std::string, TOOL_ACTION * > & | GetActions () const |
| Get a list of currently-registered actions mapped by their name. | |
| bool | IsActionUIId (int aId) const |
| Test if a UI ID corresponds to an action ID in our system. | |
| TOOL_ACTION * | FindAction (const std::string &aActionName) const |
| Find an action with a given name (if there is one available). | |
| bool | RunHotKey (int aHotKey) const |
| Run an action associated with a hotkey (if there is one available). | |
| int | GetHotKey (const TOOL_ACTION &aAction) const |
| Return the hot key associated with a given action or 0 if there is none. | |
| void | UpdateHotKeys (bool aFullUpdate) |
| Optionally read the hotkey config files and then rebuilds the internal hotkey maps. | |
| void | SetConditions (const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions) |
| Set the conditions the UI elements for activating a specific tool action should use for determining the current UI state (e.g. | |
| const ACTION_CONDITIONS * | GetCondition (const TOOL_ACTION &aAction) const |
| Get the conditions to use for a specific tool action. | |
Static Public Member Functions | |
| static int | MakeActionId (const std::string &aActionName) |
| Generate an unique ID from for an action with given name. | |
| static std::string | FrameNamespacePrefix (FRAME_T aFrameType) |
| Return the action-name namespace prefix (e.g. | |
| static void | PromoteUserBoundFrameAction (std::vector< const TOOL_ACTION * > &aGlobalActions, FRAME_T aFrameType, int aMatchedHotKey) |
| Reorder global actions sharing a hotkey so that one native to the given frame is tried first when the user has bound the matched slot away from its default. | |
| static std::list< TOOL_ACTION * > & | GetActionList () |
| Return list of TOOL_ACTIONs. | |
Private Types | |
| typedef std::map< int, std::list< TOOL_ACTION * > > | HOTKEY_LIST |
Private Member Functions | |
| void | processHotKey (TOOL_ACTION *aAction, const std::map< std::string, int > &aLegacyMap, const std::map< std::string, std::pair< int, int > > &aHotKeyMap) |
| Tool manager needed to run actions. | |
Private Attributes | |
| TOOL_MANAGER * | m_toolMgr |
| Map for indexing actions by their names. | |
| std::map< std::string, TOOL_ACTION * > | m_actionNameIndex |
| Map for recording actions that have custom UI IDs. | |
| std::map< int, TOOL_ACTION * > | m_customUIIdIndex |
| Map for indexing actions by their hotkeys. | |
| HOTKEY_LIST | m_actionHotKeys |
| Quick action<->hot key lookup. | |
| std::map< int, int > | m_hotkeys |
| std::map< int, ACTION_CONDITIONS > | m_uiConditions |
| Map the command ID that wx uses for the action to the UI conditions for the menu/toolbar items. | |
Manage TOOL_ACTION objects.
Registering them and allows one to run them using associated hot keys, names or ids.
Definition at line 83 of file action_manager.h.
|
private |
Definition at line 207 of file action_manager.h.
| ACTION_MANAGER::ACTION_MANAGER | ( | TOOL_MANAGER * | aToolManager | ) |
| aToolManager | is a tool manager instance that is used to pass events to tools. |
Definition at line 34 of file action_manager.cpp.
References GetActionList(), group, kicadTraceToolStack, m_toolMgr, MakeActionId(), and RegisterAction().
| ACTION_MANAGER::~ACTION_MANAGER | ( | ) |
Unregister every registered action.
Definition at line 67 of file action_manager.cpp.
| TOOL_ACTION * ACTION_MANAGER::FindAction | ( | const std::string & | aActionName | ) | const |
Find an action with a given name (if there is one available).
| aActionName | is the searched action. |
Definition at line 129 of file action_manager.cpp.
References m_actionNameIndex.
Referenced by TOOLS_HOLDER::ShowChangedLanguage().
|
static |
Return the action-name namespace prefix (e.g.
"pcbnew.", "eeschema.") shared by the actions native to a given frame, or an empty string when the frame has no namespace.
Definition at line 260 of file action_manager.cpp.
References FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_VIEWER, FRAME_GERBER, FRAME_PCB_EDITOR, FRAME_PL_EDITOR, FRAME_SCH, FRAME_SCH_SYMBOL_EDITOR, FRAME_SCH_VIEWER, and FRAME_SIMULATOR.
Referenced by PANEL_TOOLBAR_CUSTOMIZATION::isActionSupported(), and PromoteUserBoundFrameAction().
|
inlinestatic |
Return list of TOOL_ACTIONs.
#TOOL_ACTIONs add themselves to the list upon their creation.
Definition at line 167 of file action_manager.h.
Referenced by ACTION_MANAGER(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages(), NL_GERBVIEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_PL_EDITOR_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), KIFACE_BASE::GetActions(), KIWAY::GetActions(), SaveFileAs(), NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand(), NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand(), NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand(), NL_PL_EDITOR_PLUGIN_IMPL::SetActiveCommand(), NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand(), TOOL_ACTION::TOOL_ACTION(), TOOL_ACTION::TOOL_ACTION(), and TOOL_ACTION::~TOOL_ACTION().
| const std::map< std::string, TOOL_ACTION * > & ACTION_MANAGER::GetActions | ( | ) | const |
Get a list of currently-registered actions mapped by their name.
Definition at line 313 of file action_manager.cpp.
References m_actionNameIndex.
Referenced by DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS(), and EDA_BASE_FRAME::ShowPreferences().
| const ACTION_CONDITIONS * ACTION_MANAGER::GetCondition | ( | const TOOL_ACTION & | aAction | ) | const |
Get the conditions to use for a specific tool action.
| aAction | is the tool action. |
Definition at line 109 of file action_manager.cpp.
References TOOL_ACTION::GetId(), and m_uiConditions.
Referenced by RunHotKey(), NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand(), NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand(), NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand(), NL_PL_EDITOR_PLUGIN_IMPL::SetActiveCommand(), and NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand().
| int ACTION_MANAGER::GetHotKey | ( | const TOOL_ACTION & | aAction | ) | const |
Return the hot key associated with a given action or 0 if there is none.
| aAction | is the queried action. |
Definition at line 319 of file action_manager.cpp.
References TOOL_ACTION::GetId(), and m_hotkeys.
| bool ACTION_MANAGER::IsActionUIId | ( | int | aId | ) | const |
Test if a UI ID corresponds to an action ID in our system.
Definition at line 300 of file action_manager.cpp.
References TOOL_ACTION::GetBaseUIId(), and m_customUIIdIndex.
Referenced by ACTION_MENU::OnMenuEvent().
|
static |
Generate an unique ID from for an action with given name.
Definition at line 121 of file action_manager.cpp.
Referenced by ACTION_GROUP::ACTION_GROUP(), ACTION_GROUP::ACTION_GROUP(), and ACTION_MANAGER().
|
private |
Tool manager needed to run actions.
Definition at line 369 of file action_manager.cpp.
References TOOL_ACTION::m_defaultHotKey, TOOL_ACTION::m_hotKey, TOOL_ACTION::m_legacyName, TOOL_ACTION::m_name, and TOOL_ACTION::SetHotKey().
Referenced by UpdateHotKeys().
|
static |
Reorder global actions sharing a hotkey so that one native to the given frame is tried first when the user has bound the matched slot away from its default.
Definition at line 282 of file action_manager.cpp.
References FrameNamespacePrefix().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and RunHotKey().
| void ACTION_MANAGER::RegisterAction | ( | TOOL_ACTION * | aAction | ) |
Add a tool action to the manager and sets it up.
After that it is possible to invoke the action using hotkeys or sending a command event with its name.
| aAction | action to be added. Ownership is not transferred. |
Definition at line 72 of file action_manager.cpp.
References TOOL_ACTION::GetName(), TOOL_ACTION::GetUIId(), TOOL_ACTION::HasCustomUIId(), m_actionNameIndex, m_customUIIdIndex, and TOOL_ACTION::m_name.
Referenced by ACTION_MANAGER().
| bool ACTION_MANAGER::RunHotKey | ( | int | aHotKey | ) | const |
Run an action associated with a hotkey (if there is one available).
| aHotKey | is the hotkey to be handled. |
Definition at line 140 of file action_manager.cpp.
References AS_GLOBAL, GetCondition(), TOOL_BASE::GetId(), TOOL_ACTION::GetName(), KeyNameFromKeyCode(), kicadTraceToolStack, m_actionHotKeys, m_toolMgr, MD_MODIFIER_MASK, MD_SHIFT, and PromoteUserBoundFrameAction().
| void ACTION_MANAGER::SetConditions | ( | const TOOL_ACTION & | aAction, |
| const ACTION_CONDITIONS & | aConditions ) |
Set the conditions the UI elements for activating a specific tool action should use for determining the current UI state (e.g.
checked, enabled, shown)
| aAction | is the tool action using these conditions. |
| aConditions | are the conditions to use for the action. |
Definition at line 89 of file action_manager.cpp.
References TOOL_ACTION::GetId(), TOOL_ACTION::GetName(), kicadTraceToolStack, m_toolMgr, and m_uiConditions.
Referenced by EDIT_TOOL::Init(), ROUTER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_MAINFRAME::setupUIConditions(), DISPLAY_FOOTPRINTS_FRAME::setupUIConditions(), EDA_3D_VIEWER_FRAME::setupUIConditions(), EDA_DRAW_FRAME::setupUIConditions(), FOOTPRINT_CHOOSER_FRAME::setupUIConditions(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), FOOTPRINT_VIEWER_FRAME::setupUIConditions(), GERBVIEW_FRAME::setupUIConditions(), KICAD_MANAGER_FRAME::setupUIConditions(), PCB_EDIT_FRAME::setupUIConditions(), PL_EDITOR_FRAME::setupUIConditions(), SCH_EDIT_FRAME::setupUIConditions(), SIMULATOR_FRAME::setupUIConditions(), SYMBOL_EDIT_FRAME::setupUIConditions(), and SYMBOL_VIEWER_FRAME::setupUIConditions().
| void ACTION_MANAGER::UpdateHotKeys | ( | bool | aFullUpdate | ) |
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
Definition at line 330 of file action_manager.cpp.
References TOOL_ACTION::GetHotKey(), TOOL_ACTION::GetHotKeyAlt(), TOOL_ACTION::GetId(), m_actionHotKeys, m_actionNameIndex, m_hotkeys, m_toolMgr, processHotKey(), ReadHotKeyConfig(), and ReadLegacyHotkeyConfig().
Referenced by TOOLS_HOLDER::CommonSettingsChanged().
|
private |
Quick action<->hot key lookup.
Definition at line 208 of file action_manager.h.
Referenced by RunHotKey(), and UpdateHotKeys().
|
private |
Map for recording actions that have custom UI IDs.
Definition at line 201 of file action_manager.h.
Referenced by FindAction(), GetActions(), RegisterAction(), and UpdateHotKeys().
|
private |
Map for indexing actions by their hotkeys.
Definition at line 204 of file action_manager.h.
Referenced by IsActionUIId(), and RegisterAction().
|
private |
Definition at line 211 of file action_manager.h.
Referenced by GetHotKey(), and UpdateHotKeys().
|
private |
Map for indexing actions by their names.
Definition at line 198 of file action_manager.h.
Referenced by ACTION_MANAGER(), RunHotKey(), SetConditions(), and UpdateHotKeys().
|
private |
Map the command ID that wx uses for the action to the UI conditions for the menu/toolbar items.
Definition at line 215 of file action_manager.h.
Referenced by GetCondition(), and SetConditions().