KiCad PCB EDA Suite
|
Represent a single user action. More...
#include <tool_action.h>
Public Member Functions | |
TOOL_ACTION (const TOOL_ACTION_ARGS &aArgs) | |
TOOL_ACTION (const std::string &aName, TOOL_ACTION_SCOPE aScope=AS_CONTEXT, int aDefaultHotKey=0, const std::string &aLegacyHotKeyName="", const wxString &aMenuText=wxEmptyString, const wxString &aTooltip=wxEmptyString, BITMAPS aIcon=static_cast< BITMAPS >(0), TOOL_ACTION_FLAGS aFlags=AF_NONE) | |
~TOOL_ACTION () | |
TOOL_ACTION (const TOOL_ACTION &)=delete | |
TOOL_ACTION & | operator= (const TOOL_ACTION &)=delete |
bool | operator== (const TOOL_ACTION &aRhs) const |
bool | operator!= (const TOOL_ACTION &aRhs) const |
const std::string & | GetName () const |
Return name of the action. | |
int | GetDefaultHotKey () const |
Return the default hotkey (if any) for the action. | |
int | GetDefaultHotKeyAlt () const |
int | GetHotKey () const |
Return the hotkey keycode which initiates the action. | |
int | GetHotKeyAlt () const |
void | SetHotKey (int aKeycode, int aKeycodeAlt=0) |
int | GetId () const |
Return the unique id of the TOOL_ACTION object. | |
bool | HasCustomUIId () const |
Return true if this action has a custom UI ID set. | |
int | GetUIId () const |
Get the unique ID for this action in the user interface system. | |
TOOL_EVENT | MakeEvent () const |
Return the event associated with the action (i.e. | |
wxString | GetMenuLabel () const |
Return the translated label for the action. | |
wxString | GetMenuItem () const |
wxString | GetTooltip (bool aIncludeHotkey=true) const |
wxString | GetButtonTooltip () const |
wxString | GetDescription () const |
wxString | GetFriendlyName () const |
Return the translated user-friendly name of the action. | |
TOOL_ACTION_SCOPE | GetScope () const |
template<typename T > | |
T | GetParam () const |
Return a non-standard parameter assigned to the action. | |
const std::optional< TOOL_ACTION_GROUP > | GetActionGroup () const |
std::string | GetToolName () const |
Return name of the tool associated with the action. | |
bool | IsActivation () const |
Return true if the action is intended to activate a tool. | |
bool | IsNotification () const |
Return true if the action is a notification. | |
BITMAPS | GetIcon () const |
Return an icon associated with the action. | |
Static Public Member Functions | |
static int | GetBaseUIId () |
Get the base value used to offset the user interface IDs for the actions. | |
Protected Member Functions | |
TOOL_ACTION () | |
Protected Attributes | |
std::string | m_name |
Name of the action (convention is "app.tool.actionName") | |
TOOL_ACTION_SCOPE | m_scope |
std::optional< TOOL_ACTION_GROUP > | m_group |
Optional group for the action to belong to. | |
const int | m_defaultHotKey |
Default hot key. | |
const int | m_defaultHotKeyAlt |
Default hot key alternate. | |
int | m_hotKey |
The current hotkey (post-user-settings-application). | |
int | m_hotKeyAlt |
The alternate hotkey (post-user-settings-application). | |
const std::string | m_legacyName |
Name for reading legacy hotkey settings. | |
wxString | m_friendlyName |
User-friendly name. | |
std::optional< wxString > | m_menuLabel |
Menu label. | |
wxString | m_tooltip |
User facing tooltip help text. | |
std::optional< wxString > | m_description |
Description of the action. | |
BITMAPS | m_icon |
Icon for the menu entry. | |
int | m_id |
Unique ID for maps. Assigned by ACTION_MANAGER. | |
std::optional< int > | m_uiid |
ID to use when interacting with the UI (if empty, generate one). | |
TOOL_ACTION_FLAGS | m_flags |
ki::any | m_param |
Generic parameter. | |
Static Protected Attributes | |
static constexpr int | ACTION_BASE_UI_ID = 20000 |
Base ID to use inside the user interface system to offset the action IDs. | |
Friends | |
class | ACTION_MANAGER |
Represent a single user action.
For instance:
Action class groups all necessary properties of an action, including explanation, icons, hotkeys, menu items, etc.
Definition at line 268 of file tool_action.h.
TOOL_ACTION::TOOL_ACTION | ( | const TOOL_ACTION_ARGS & | aArgs | ) |
Definition at line 73 of file tool_action.cpp.
References ACTION_MANAGER::GetActionList(), ki::any::has_value(), TOOL_ACTION_ARGS::m_description, m_description, TOOL_ACTION_ARGS::m_group, m_group, m_menuLabel, TOOL_ACTION_ARGS::m_menuText, m_name, TOOL_ACTION_ARGS::m_param, m_param, TOOL_ACTION_ARGS::m_uiid, m_uiid, and TowxString().
TOOL_ACTION::TOOL_ACTION | ( | const std::string & | aName, |
TOOL_ACTION_SCOPE | aScope = AS_CONTEXT , |
||
int | aDefaultHotKey = 0 , |
||
const std::string & | aLegacyHotKeyName = "" , |
||
const wxString & | aMenuText = wxEmptyString , |
||
const wxString & | aTooltip = wxEmptyString , |
||
BITMAPS | aIcon = static_cast<BITMAPS>( 0 ) , |
||
TOOL_ACTION_FLAGS | aFlags = AF_NONE |
||
) |
Definition at line 39 of file tool_action.cpp.
References ACTION_MANAGER::GetActionList(), and SetHotKey().
TOOL_ACTION::~TOOL_ACTION | ( | ) |
Definition at line 110 of file tool_action.cpp.
References ACTION_MANAGER::GetActionList().
|
delete |
|
protected |
Definition at line 60 of file tool_action.cpp.
References SetHotKey().
|
inline |
Definition at line 394 of file tool_action.h.
References m_group.
|
inlinestatic |
Get the base value used to offset the user interface IDs for the actions.
Definition at line 344 of file tool_action.h.
References ACTION_BASE_UI_ID.
Referenced by ACTION_GROUP::GetUIId(), ACTION_MANAGER::IsActionUIId(), and ACTION_TOOLBAR::onToolEvent().
wxString TOOL_ACTION::GetButtonTooltip | ( | ) | const |
Definition at line 186 of file tool_action.cpp.
References GetFriendlyName(), GetHotKey(), GetTooltip(), and KeyNameFromKeyCode().
Referenced by ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), and ACTION_TOOLBAR::doSelectAction().
|
inline |
Return the default hotkey (if any) for the action.
Definition at line 307 of file tool_action.h.
References m_defaultHotKey.
|
inline |
Definition at line 308 of file tool_action.h.
References m_defaultHotKeyAlt.
wxString TOOL_ACTION::GetDescription | ( | ) | const |
Definition at line 165 of file tool_action.cpp.
References GetTooltip(), and m_description.
Referenced by NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), and NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages().
wxString TOOL_ACTION::GetFriendlyName | ( | ) | const |
Return the translated user-friendly name of the action.
Definition at line 139 of file tool_action.cpp.
References m_friendlyName.
Referenced by PANEL_KICAD_LAUNCHER::CreateLaunchers(), ALIGN_DISTRIBUTE_TOOL::DistributeItems(), GetButtonTooltip(), GetMenuLabel(), TOOLS_HOLDER::PushTool(), WIDGET_HOTKEY_LIST::resolveKeyConflicts(), and TOOLS_HOLDER::ShowChangedLanguage().
|
inline |
Return the hotkey keycode which initiates the action.
Definition at line 313 of file tool_action.h.
References m_hotKey.
Referenced by APPEARANCE_CONTROLS::createControls(), GetButtonTooltip(), PCB_ONE_LAYER_SELECTOR::getLayerHotKey(), GetTooltip(), PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS(), APPEARANCE_CONTROLS::rebuildLayers(), APPEARANCE_CONTROLS::rebuildNets(), PCB_LAYER_BOX_SELECTOR::Resync(), and ACTION_MANAGER::UpdateHotKeys().
|
inline |
Definition at line 314 of file tool_action.h.
References m_hotKeyAlt.
Referenced by ACTION_MANAGER::UpdateHotKeys().
|
inline |
Return an icon associated with the action.
It is used in context menu.
Definition at line 424 of file tool_action.h.
References m_icon.
Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::AddGroup(), ACTION_TOOLBAR::doSelectAction(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), and NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages().
|
inline |
Return the unique id of the TOOL_ACTION object.
It is valid only after registering the TOOL_ACTION by ACTION_MANAGER.
Definition at line 324 of file tool_action.h.
References m_id.
Referenced by CONDITIONAL_MENU::AddCheckItem(), CONDITIONAL_MENU::AddItem(), ACTION_MANAGER::GetCondition(), ACTION_MANAGER::GetHotKey(), APPEARANCE_CONTROLS::onNetclassContextMenu(), ACTION_MANAGER::SetConditions(), and ACTION_MANAGER::UpdateHotKeys().
wxString TOOL_ACTION::GetMenuItem | ( | ) | const |
Definition at line 157 of file tool_action.cpp.
References AddHotkeyName(), GetMenuLabel(), IS_HOTKEY, and m_hotKey.
Referenced by ACTION_MENU::Add().
wxString TOOL_ACTION::GetMenuLabel | ( | ) | const |
Return the translated label for the action.
Definition at line 148 of file tool_action.cpp.
References GetFriendlyName(), and m_menuLabel.
Referenced by NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages(), and GetMenuItem().
|
inline |
Return name of the action.
It is the same one that is contained in TOOL_EVENT that is sent by activating the TOOL_ACTION. Convention is "app.tool.actionName".
Definition at line 302 of file tool_action.h.
References m_name.
Referenced by TOOLS_HOLDER::CurrentToolName(), ACTION_TOOLBAR::doSelectAction(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages(), HOTKEY_STORE::GetAppName(), TOOLS_HOLDER::IsCurrentTool(), ACTION_MANAGER::RegisterAction(), ACTION_MANAGER::RunHotKey(), NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand(), NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand(), NL_PCBNEW_PLUGIN_IMPL::SetActiveCommand(), and ACTION_MANAGER::SetConditions().
|
inline |
Return a non-standard parameter assigned to the action.
Definition at line 372 of file tool_action.h.
References ki::any::has_value(), m_param, name, and ki::any::type().
|
inline |
Definition at line 366 of file tool_action.h.
References m_scope.
Referenced by HOTKEY_STORE::CheckKeyConflicts().
std::string TOOL_ACTION::GetToolName | ( | ) | const |
Return name of the tool associated with the action.
It is basically the action name stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is "pcbnew.InteractiveDrawing").
Definition at line 208 of file tool_action.cpp.
References m_name.
Referenced by HOTKEY_STORE::CheckKeyConflicts(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), and NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages().
wxString TOOL_ACTION::GetTooltip | ( | bool | aIncludeHotkey = true | ) | const |
Definition at line 175 of file tool_action.cpp.
References GetHotKey(), KeyNameFromKeyCode(), and m_tooltip.
Referenced by ACTION_MENU::Add(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), GetButtonTooltip(), and GetDescription().
|
inline |
Get the unique ID for this action in the user interface system.
This can be either set to a specific ID during creation or computed by offsetting the action ID by ACTION_BASE_UI_ID
.
Definition at line 339 of file tool_action.h.
References ACTION_BASE_UI_ID, m_id, and m_uiid.
Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::AddToolContextMenu(), ACTION_TOOLBAR_PALETTE::CheckAction(), ACTION_TOOLBAR_PALETTE::EnableAction(), EDA_BASE_FRAME::HandleUpdateUIEvent(), ACTION_TOOLBAR::popupPalette(), ACTION_MANAGER::RegisterAction(), TOOLS_HOLDER::RegisterUIUpdateHandler(), ACTION_TOOLBAR::SetToolBitmap(), ACTION_TOOLBAR::Toggle(), and TOOLS_HOLDER::UnregisterUIUpdateHandler().
|
inline |
Return true if this action has a custom UI ID set.
Definition at line 329 of file tool_action.h.
References m_uiid.
Referenced by ACTION_MANAGER::RegisterAction().
|
inline |
Return true if the action is intended to activate a tool.
Definition at line 406 of file tool_action.h.
References AF_ACTIVATE, and m_flags.
Referenced by MakeEvent().
|
inline |
Return true if the action is a notification.
Definition at line 414 of file tool_action.h.
References AF_NOTIFY, and m_flags.
Referenced by MakeEvent().
TOOL_EVENT TOOL_ACTION::MakeEvent | ( | ) | const |
Return the event associated with the action (i.e.
the event that will be sent after activating the action).
Definition at line 116 of file tool_action.cpp.
References ki::any::has_value(), IsActivation(), IsNotification(), m_group, m_name, m_param, m_scope, TOOL_EVENT::SetActionGroup(), TOOL_EVENT::SetParameter(), TA_ACTION, TA_ACTIVATE, TA_NONE, TC_COMMAND, and TC_MESSAGE.
Referenced by EE_SELECTION_TOOL::autostartEvent(), PCB_POINT_EDITOR::changeArcEditMode(), ALIGN_DISTRIBUTE_TOOL::DistributeItems(), TOOL_MANAGER::doRunAction(), TOOL_EVENT::IsAction(), SCH_EDIT_TOOL::JustifyText(), EDIT_TOOL::JustifyText(), EE_SELECTION_TOOL::Main(), PANEL_KICAD_LAUNCHER::onLauncherButtonClick(), ACTION_TOOLBAR::onPaletteEvent(), TOOLS_HOLDER::PopTool(), ROUTER_TOOL::setTransitions(), and BOARD_EDITOR_CONTROL::setTransitions().
|
inline |
Definition at line 289 of file tool_action.h.
References m_id.
|
delete |
|
inline |
Definition at line 284 of file tool_action.h.
References m_id.
void TOOL_ACTION::SetHotKey | ( | int | aKeycode, |
int | aKeycodeAlt = 0 |
||
) |
Definition at line 201 of file tool_action.cpp.
References m_hotKey, and m_hotKeyAlt.
Referenced by ACTION_MANAGER::processHotKey(), HOTKEY_STORE::SaveAllHotkeys(), and TOOL_ACTION().
|
friend |
Definition at line 432 of file tool_action.h.
|
staticconstexprprotected |
Base ID to use inside the user interface system to offset the action IDs.
Definition at line 435 of file tool_action.h.
Referenced by GetBaseUIId(), and GetUIId().
|
protected |
Default hot key.
Definition at line 443 of file tool_action.h.
Referenced by GetDefaultHotKey(), and ACTION_MANAGER::processHotKey().
|
protected |
Default hot key alternate.
Definition at line 444 of file tool_action.h.
Referenced by GetDefaultHotKeyAlt().
|
protected |
Description of the action.
Definition at line 454 of file tool_action.h.
Referenced by GetDescription(), and TOOL_ACTION().
|
protected |
Definition at line 461 of file tool_action.h.
Referenced by IsActivation(), and IsNotification().
|
protected |
User-friendly name.
Definition at line 451 of file tool_action.h.
Referenced by GetFriendlyName(), and PSEUDO_ACTION::PSEUDO_ACTION().
|
protected |
Optional group for the action to belong to.
Definition at line 441 of file tool_action.h.
Referenced by GetActionGroup(), MakeEvent(), and TOOL_ACTION().
|
protected |
The current hotkey (post-user-settings-application).
Definition at line 445 of file tool_action.h.
Referenced by GetHotKey(), GetMenuItem(), ACTION_MANAGER::processHotKey(), PSEUDO_ACTION::PSEUDO_ACTION(), and SetHotKey().
|
protected |
The alternate hotkey (post-user-settings-application).
Definition at line 448 of file tool_action.h.
Referenced by GetHotKeyAlt(), PSEUDO_ACTION::PSEUDO_ACTION(), and SetHotKey().
|
protected |
|
protected |
Unique ID for maps. Assigned by ACTION_MANAGER.
Definition at line 458 of file tool_action.h.
Referenced by GetId(), GetUIId(), operator!=(), and operator==().
|
protected |
Name for reading legacy hotkey settings.
Definition at line 449 of file tool_action.h.
Referenced by ACTION_MANAGER::processHotKey().
|
protected |
Menu label.
Definition at line 452 of file tool_action.h.
Referenced by GetMenuLabel(), and TOOL_ACTION().
|
protected |
Name of the action (convention is "app.tool.actionName")
Definition at line 438 of file tool_action.h.
Referenced by GetName(), GetToolName(), MakeEvent(), ACTION_MANAGER::processHotKey(), ACTION_MANAGER::RegisterAction(), and TOOL_ACTION().
|
protected |
Generic parameter.
Definition at line 462 of file tool_action.h.
Referenced by GetParam(), MakeEvent(), and TOOL_ACTION().
|
protected |
Definition at line 439 of file tool_action.h.
Referenced by GetScope(), and MakeEvent().
|
protected |
User facing tooltip help text.
Definition at line 453 of file tool_action.h.
Referenced by GetTooltip().
|
protected |
ID to use when interacting with the UI (if empty, generate one).
Definition at line 459 of file tool_action.h.
Referenced by GetUIId(), HasCustomUIId(), and TOOL_ACTION().