37 m_toolMgr( aToolManager )
44 if( action->m_id == -1 )
61 wxASSERT( aAction->
GetName().find(
'.', 0 ) != std::string::npos );
81 wxS(
"ACTION_MANAGER::SetConditions: Registering conditions for ID %d - %s" ),
104 static int currentActionId = 1;
106 return currentActionId++;
112 std::map<std::string, TOOL_ACTION*>::const_iterator it =
m_actionNameIndex.find( aActionName );
123 int key = aHotKey & ~MD_MODIFIER_MASK;
126 if( key >=
'a' && key <=
'z' )
127 key = std::toupper( key );
141 wxS(
"ACTION_MANAGER::RunHotKey No actions found, searching with key: %s" ),
150 const std::list<TOOL_ACTION*>& actions = it->second;
154 int highestPriority = -1, priority = -1;
156 std::vector<const TOOL_ACTION*> global;
164 global.emplace_back( action );
176 if( priority >= 0 && priority > highestPriority )
178 highestPriority = priority;
189 bool runAction =
true;
192 runAction = aCond->enableCondition( sel );
195 wxS(
"ACTION_MANAGER::RunHotKey %s context action: %s for hotkey %s" ),
196 runAction ? wxS(
"Running" ) : wxS(
"Not running" ),
203 else if( !global.empty() )
207 bool runAction =
true;
210 runAction = aCond->enableCondition( sel );
213 wxS(
"ACTION_MANAGER::RunHotKey %s global action: %s for hotkey %s" ),
214 runAction ? wxS(
"Running" ) : wxS(
"Not running" ),
224 wxS(
"ACTION_MANAGER::RunHotKey No action found for key %s" ),
239 std::map<int, int>::const_iterator it =
m_hotkeys.find( aAction.
GetId() );
250 static std::map<std::string, int> legacyHotKeyMap;
251 static std::map<std::string, int> userHotKeyMap;
252 static bool mapsInitialized =
false;
261 mapsInitialized =
true;
270 hotkey =
processHotKey( action, legacyHotKeyMap, userHotKeyMap );
283 const std::map<std::string, int>& aLegacyMap,
284 const std::map<std::string, int>& aHotKeyMap )
291 if( aHotKeyMap.count( aAction->
m_name ) )
~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.
TOOL_MANAGER * m_toolMgr
Map for indexing actions by their names.
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 indexing actions by their hotkeys.
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).
int processHotKey(TOOL_ACTION *aAction, const std::map< std::string, int > &aLegacyMap, const std::map< std::string, int > &aHotKeyMap)
Tool manager needed to run actions.
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
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.
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.
void ReadHotKeyConfig(const wxString &aFileName, std::map< std::string, int > &aHotKeys)
Reads a hotkey config file into a map.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
wxLogTrace helper definitions.