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::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 85 of file action_manager.h.
|
private |
Definition at line 196 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 36 of file action_manager.cpp.
References GetActionList(), group, kicadTraceToolStack, 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 128 of file action_manager.cpp.
References m_actionNameIndex.
Referenced by TOOL_MANAGER::doRunAction(), TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), and TOOLS_HOLDER::ShowChangedLanguage().
|
inlinestatic |
Return list of TOOL_ACTIONs.
#TOOL_ACTIONs add themselves to the list upon their creation.
Definition at line 156 of file action_manager.h.
Referenced by ACTION_MANAGER(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_GERBVIEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_PL_EDITOR_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages(), KIWAY::GetActions(), KIFACE_BASE::GetActions(), NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand(), NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand(), NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand(), NL_PL_EDITOR_PLUGIN_IMPL::SetActiveCommand(), NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand(), 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 262 of file action_manager.cpp.
References m_actionNameIndex.
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 108 of file action_manager.cpp.
References TOOL_ACTION::GetId(), and m_uiConditions.
Referenced by ACTION_TOOLBAR::doSelectAction(), RunHotKey(), NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand(), NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand(), NL_GERBVIEW_PLUGIN_IMPL::SetActiveCommand(), NL_PL_EDITOR_PLUGIN_IMPL::SetActiveCommand(), and NL_PCBNEW_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 268 of file action_manager.cpp.
References TOOL_ACTION::GetId(), and m_hotkeys.
Referenced by TOOL_MANAGER::GetHotKey().
bool ACTION_MANAGER::IsActionUIId | ( | int | aId | ) | const |
Test if a UI ID corresponds to an action ID in our system.
Definition at line 249 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 120 of file action_manager.cpp.
Referenced by ACTION_GROUP::ACTION_GROUP(), and ACTION_MANAGER().
|
private |
Tool manager needed to run actions.
Definition at line 318 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().
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 139 of file action_manager.cpp.
References AS_GLOBAL, TOOL_MANAGER::FindTool(), GetCondition(), TOOLS_HOLDER::GetCurrentSelection(), TOOL_BASE::GetId(), TOOL_ACTION::GetName(), TOOL_MANAGER::GetPriority(), TOOL_MANAGER::GetToolHolder(), KeyNameFromKeyCode(), kicadTraceToolStack, m_actionHotKeys, m_toolMgr, MD_MODIFIER_MASK, MD_SHIFT, and TOOL_MANAGER::RunAction().
Referenced by TOOL_MANAGER::DispatchHotKey().
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 88 of file action_manager.cpp.
References TOOL_ACTION::GetId(), TOOL_ACTION::GetName(), TOOL_MANAGER::GetToolHolder(), kicadTraceToolStack, m_toolMgr, m_uiConditions, TOOLS_HOLDER::RegisterUIUpdateHandler(), and TOOLS_HOLDER::UnregisterUIUpdateHandler().
Referenced by EDA_3D_VIEWER_FRAME::setupUIConditions(), CVPCB_MAINFRAME::setupUIConditions(), DISPLAY_FOOTPRINTS_FRAME::setupUIConditions(), SCH_EDIT_FRAME::setupUIConditions(), SIMULATOR_FRAME::setupUIConditions(), SYMBOL_EDIT_FRAME::setupUIConditions(), SYMBOL_VIEWER_FRAME::setupUIConditions(), GERBVIEW_FRAME::setupUIConditions(), KICAD_MANAGER_FRAME::setupUIConditions(), PL_EDITOR_FRAME::setupUIConditions(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), FOOTPRINT_VIEWER_FRAME::setupUIConditions(), and PCB_EDIT_FRAME::setupUIConditions().
void ACTION_MANAGER::UpdateHotKeys | ( | bool | aFullUpdate | ) |
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
Definition at line 279 of file action_manager.cpp.
References TOOLS_HOLDER::ConfigBaseName(), TOOL_ACTION::GetHotKey(), TOOL_ACTION::GetHotKeyAlt(), TOOL_ACTION::GetId(), TOOL_MANAGER::GetToolHolder(), m_actionHotKeys, m_actionNameIndex, m_hotkeys, m_toolMgr, processHotKey(), ReadHotKeyConfig(), and ReadLegacyHotkeyConfig().
Referenced by TOOLS_HOLDER::CommonSettingsChanged(), and TOOL_MANAGER::InitTools().
|
private |
Quick action<->hot key lookup.
Definition at line 197 of file action_manager.h.
Referenced by RunHotKey(), and UpdateHotKeys().
|
private |
Map for recording actions that have custom UI IDs.
Definition at line 190 of file action_manager.h.
Referenced by FindAction(), GetActions(), RegisterAction(), and UpdateHotKeys().
|
private |
Map for indexing actions by their hotkeys.
Definition at line 193 of file action_manager.h.
Referenced by IsActionUIId(), and RegisterAction().
|
private |
Definition at line 200 of file action_manager.h.
Referenced by GetHotKey(), and UpdateHotKeys().
|
private |
Map for indexing actions by their names.
Definition at line 187 of file action_manager.h.
Referenced by 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 204 of file action_manager.h.
Referenced by GetCondition(), and SetConditions().