37 m_toolMgr( aToolManager )
44 if( action->m_id == -1 )
48 std::string groupName =
"none";
50 std::optional<TOOL_ACTION_GROUP>
group = action->GetActionGroup();
52 if(
group.has_value() )
54 groupID =
group.value().GetGroupID();
55 groupName =
group.value().GetName();
59 "ACTION_MANAGER::ACTION_MANAGER: Registering action %s with ID %d, UI ID %d, and group %s(%d)",
60 action->m_name, action->m_id, action->GetUIId(), groupName, groupID );
76 wxASSERT( aAction->
GetName().find(
'.', 0 ) != std::string::npos );
99 wxS(
"ACTION_MANAGER::SetConditions: Registering conditions for ID %d - %s" ),
122 static int currentActionId = 1;
124 return currentActionId++;
130 std::map<std::string, TOOL_ACTION*>::const_iterator it =
m_actionNameIndex.find( aActionName );
141 int key = aHotKey & ~MD_MODIFIER_MASK;
144 if( key >=
'a' && key <=
'z' )
145 key = std::toupper( key );
160 wxS(
"ACTION_MANAGER::RunHotKey No actions found, searching with key: %s" ),
170 const std::list<TOOL_ACTION*>& actions = it->second;
174 int highestPriority = -1, priority = -1;
176 std::vector<const TOOL_ACTION*> global;
184 global.emplace_back( action );
196 if( priority >= 0 && priority > highestPriority )
198 highestPriority = priority;
209 bool runAction =
true;
212 runAction = aCond->enableCondition( sel );
215 wxS(
"ACTION_MANAGER::RunHotKey %s context action: %s for hotkey %s" ),
216 runAction ? wxS(
"Running" ) : wxS(
"Not running" ),
223 else if( !global.empty() )
227 bool runAction =
true;
230 runAction = aCond->enableCondition( sel );
233 wxS(
"ACTION_MANAGER::RunHotKey %s global action: %s for hotkey %s" ),
234 runAction ? wxS(
"Running" ) : wxS(
"Not running" ),
244 wxS(
"ACTION_MANAGER::RunHotKey No action found for key %s" ),
272 std::map<int, int>::const_iterator it =
m_hotkeys.find( aAction.
GetId() );
283 static std::map<std::string, int> legacyHotKeyMap;
284 static std::map<std::string, std::pair<int, int>> userHotKeyMap;
285 static bool mapsInitialized =
false;
294 mapsInitialized =
true;
321 const std::map<std::string, int>& aLegacyMap,
322 const std::map<std::string, std::pair<int, int>>& aHotKeyMap )
329 if( aHotKeyMap.count( aAction->
m_name ) )
331 std::pair<int, int> keys = aHotKeyMap.at( aAction->
m_name );
332 aAction->
SetHotKey( keys.first, keys.second );
~ACTION_MANAGER()
Unregister every registered action.
HOTKEY_LIST m_actionHotKeys
Quick action<->hot key lookup.
const ACTION_CONDITIONS * GetCondition(const TOOL_ACTION &aAction) const
Get the conditions to use for a specific tool action.
std::map< int, TOOL_ACTION * > m_customUIIdIndex
Map for indexing actions by their hotkeys.
TOOL_MANAGER * m_toolMgr
Map for indexing actions by their names.
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.
const std::map< std::string, TOOL_ACTION * > & GetActions() const
Get a list of currently-registered actions mapped by their name.
std::map< std::string, TOOL_ACTION * > m_actionNameIndex
Map for recording actions that have custom UI IDs.
std::map< int, int > m_hotkeys
bool RunHotKey(int aHotKey) const
Run an action associated with a hotkey (if there is one available).
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 t...
void RegisterAction(TOOL_ACTION *aAction)
Add a tool action to the manager and sets it up.
TOOL_ACTION * FindAction(const std::string &aActionName) const
Find an action with a given name (if there is one available).
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
bool IsActionUIId(int aId) const
Test if a UI ID corresponds to an action ID in our system.
int GetHotKey(const TOOL_ACTION &aAction) const
Return the hot key associated with a given action or 0 if there is none.
static int MakeActionId(const std::string &aActionName)
Generate an unique ID from for an action with given name.
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.
void UpdateHotKeys(bool aFullUpdate)
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
ACTION_MANAGER(TOOL_MANAGER *aToolManager)
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
void ReadHotKeyConfig(const wxString &aFileName, std::map< std::string, std::pair< int, int > > &aHotKeys)
Reads a hotkey config file into a map.
int ReadLegacyHotkeyConfig(const wxString &aAppname, std::map< std::string, int > &aMap)
Read configuration data and fill the current hotkey list with hotkeys.
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
wxLogTrace helper definitions.