KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
TOOL_ACTION Class Reference

Represent a single user action. More...

#include <tool_action.h>

Inheritance diagram for TOOL_ACTION:
PSEUDO_ACTION

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_ACTIONoperator= (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 >
GetParam () const
 Return a non-standard parameter assigned to the action.
 
const std::optional< TOOL_ACTION_GROUPGetActionGroup () 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.
 
bool CheckToolbarState (TOOLBAR_STATE aState) const
 Check if a specific toolbar state is required for this 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_GROUPm_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.
 
std::optional< BITMAPSm_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).
 
TOOLBAR_STATE_FLAGS m_toolbarState
 Toolbar state behavior for the action.
 
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
 

Detailed Description

Represent a single user action.

For instance:

  • changing layer to top by pressing PgUp
  • running the DRC from the menu and so on, and so forth....

Action class groups all necessary properties of an action, including explanation, icons, hotkeys, menu items, etc.

Definition at line 303 of file tool_action.h.

Constructor & Destructor Documentation

◆ TOOL_ACTION() [1/4]

◆ TOOL_ACTION() [2/4]

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::~TOOL_ACTION ( )

Definition at line 118 of file tool_action.cpp.

References ACTION_MANAGER::GetActionList().

◆ TOOL_ACTION() [3/4]

TOOL_ACTION::TOOL_ACTION ( const TOOL_ACTION )
delete

◆ TOOL_ACTION() [4/4]

TOOL_ACTION::TOOL_ACTION ( )
protected

Definition at line 60 of file tool_action.cpp.

References SetHotKey().

Member Function Documentation

◆ CheckToolbarState()

bool TOOL_ACTION::CheckToolbarState ( TOOLBAR_STATE  aState) const
inline

Check if a specific toolbar state is required for this action.

Parameters
aStateThe state (from TOOLBAR_STATE enum) to check
Returns
true if the state should be used for this action

Definition at line 473 of file tool_action.h.

References m_toolbarState.

Referenced by ACTION_TOOLBAR::Add().

◆ GetActionGroup()

const std::optional< TOOL_ACTION_GROUP > TOOL_ACTION::GetActionGroup ( ) const
inline

Definition at line 429 of file tool_action.h.

References m_group.

◆ GetBaseUIId()

static int TOOL_ACTION::GetBaseUIId ( )
inlinestatic

Get the base value used to offset the user interface IDs for the actions.

Definition at line 379 of file tool_action.h.

References ACTION_BASE_UI_ID.

Referenced by ACTION_GROUP::GetUIId(), ACTION_MANAGER::IsActionUIId(), and ACTION_TOOLBAR::onToolEvent().

◆ GetButtonTooltip()

wxString TOOL_ACTION::GetButtonTooltip ( ) const

◆ GetDefaultHotKey()

int TOOL_ACTION::GetDefaultHotKey ( ) const
inline

Return the default hotkey (if any) for the action.

Definition at line 342 of file tool_action.h.

References m_defaultHotKey.

◆ GetDefaultHotKeyAlt()

int TOOL_ACTION::GetDefaultHotKeyAlt ( ) const
inline

Definition at line 343 of file tool_action.h.

References m_defaultHotKeyAlt.

◆ GetDescription()

◆ GetFriendlyName()

◆ GetHotKey()

◆ GetHotKeyAlt()

int TOOL_ACTION::GetHotKeyAlt ( ) const
inline

Definition at line 349 of file tool_action.h.

References m_hotKeyAlt.

Referenced by ACTION_MANAGER::UpdateHotKeys().

◆ GetIcon()

◆ GetId()

int TOOL_ACTION::GetId ( ) const
inline

Return the unique id of the TOOL_ACTION object.

It is valid only after registering the TOOL_ACTION by ACTION_MANAGER.

Returns
The unique identification number. If the number is negative, then it is not valid.

Definition at line 359 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().

◆ GetMenuItem()

wxString TOOL_ACTION::GetMenuItem ( ) const

Definition at line 165 of file tool_action.cpp.

References AddHotkeyName(), GetMenuLabel(), IS_HOTKEY, and m_hotKey.

Referenced by ACTION_MENU::Add().

◆ GetMenuLabel()

◆ GetName()

◆ GetParam()

template<typename T >
T TOOL_ACTION::GetParam ( ) const
inline

Return a non-standard parameter assigned to the action.

Definition at line 407 of file tool_action.h.

References ki::any::has_value(), m_param, name, and ki::any::type().

◆ GetScope()

TOOL_ACTION_SCOPE TOOL_ACTION::GetScope ( ) const
inline

Definition at line 401 of file tool_action.h.

References m_scope.

Referenced by HOTKEY_STORE::CheckKeyConflicts().

◆ GetToolName()

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 216 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().

◆ GetTooltip()

wxString TOOL_ACTION::GetTooltip ( bool  aIncludeHotkey = true) const

◆ GetUIId()

int TOOL_ACTION::GetUIId ( ) const
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.

Returns
The unique ID number for use in the user interface system.

Definition at line 374 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().

◆ HasCustomUIId()

bool TOOL_ACTION::HasCustomUIId ( ) const
inline

Return true if this action has a custom UI ID set.

Definition at line 364 of file tool_action.h.

References m_uiid.

Referenced by ACTION_MANAGER::RegisterAction().

◆ IsActivation()

bool TOOL_ACTION::IsActivation ( ) const
inline

Return true if the action is intended to activate a tool.

Definition at line 441 of file tool_action.h.

References AF_ACTIVATE, and m_flags.

Referenced by MakeEvent().

◆ IsNotification()

bool TOOL_ACTION::IsNotification ( ) const
inline

Return true if the action is a notification.

Definition at line 449 of file tool_action.h.

References AF_NOTIFY, and m_flags.

Referenced by MakeEvent().

◆ MakeEvent()

◆ operator!=()

bool TOOL_ACTION::operator!= ( const TOOL_ACTION aRhs) const
inline

Definition at line 324 of file tool_action.h.

References m_id.

◆ operator=()

TOOL_ACTION & TOOL_ACTION::operator= ( const TOOL_ACTION )
delete

◆ operator==()

bool TOOL_ACTION::operator== ( const TOOL_ACTION aRhs) const
inline

Definition at line 319 of file tool_action.h.

References m_id.

◆ SetHotKey()

void TOOL_ACTION::SetHotKey ( int  aKeycode,
int  aKeycodeAlt = 0 
)

Definition at line 209 of file tool_action.cpp.

References m_hotKey, and m_hotKeyAlt.

Referenced by ACTION_MANAGER::processHotKey(), HOTKEY_STORE::SaveAllHotkeys(), and TOOL_ACTION().

Friends And Related Function Documentation

◆ ACTION_MANAGER

friend class ACTION_MANAGER
friend

Definition at line 482 of file tool_action.h.

Member Data Documentation

◆ ACTION_BASE_UI_ID

constexpr int TOOL_ACTION::ACTION_BASE_UI_ID = 20000
staticconstexprprotected

Base ID to use inside the user interface system to offset the action IDs.

Definition at line 485 of file tool_action.h.

Referenced by GetBaseUIId(), and GetUIId().

◆ m_defaultHotKey

const int TOOL_ACTION::m_defaultHotKey
protected

Default hot key.

Definition at line 493 of file tool_action.h.

Referenced by GetDefaultHotKey(), and ACTION_MANAGER::processHotKey().

◆ m_defaultHotKeyAlt

const int TOOL_ACTION::m_defaultHotKeyAlt
protected

Default hot key alternate.

Definition at line 494 of file tool_action.h.

Referenced by GetDefaultHotKeyAlt().

◆ m_description

std::optional<wxString> TOOL_ACTION::m_description
protected

Description of the action.

Definition at line 504 of file tool_action.h.

Referenced by GetDescription(), and TOOL_ACTION().

◆ m_flags

TOOL_ACTION_FLAGS TOOL_ACTION::m_flags
protected

Definition at line 513 of file tool_action.h.

Referenced by IsActivation(), and IsNotification().

◆ m_friendlyName

wxString TOOL_ACTION::m_friendlyName
protected

User-friendly name.

Definition at line 501 of file tool_action.h.

Referenced by GetFriendlyName(), and PSEUDO_ACTION::PSEUDO_ACTION().

◆ m_group

std::optional<TOOL_ACTION_GROUP> TOOL_ACTION::m_group
protected

Optional group for the action to belong to.

Definition at line 491 of file tool_action.h.

Referenced by GetActionGroup(), MakeEvent(), and TOOL_ACTION().

◆ m_hotKey

int TOOL_ACTION::m_hotKey
protected

The current hotkey (post-user-settings-application).

Definition at line 495 of file tool_action.h.

Referenced by GetHotKey(), GetMenuItem(), ACTION_MANAGER::processHotKey(), PSEUDO_ACTION::PSEUDO_ACTION(), and SetHotKey().

◆ m_hotKeyAlt

int TOOL_ACTION::m_hotKeyAlt
protected

The alternate hotkey (post-user-settings-application).

Definition at line 498 of file tool_action.h.

Referenced by GetHotKeyAlt(), PSEUDO_ACTION::PSEUDO_ACTION(), and SetHotKey().

◆ m_icon

std::optional<BITMAPS> TOOL_ACTION::m_icon
protected

Icon for the menu entry.

Definition at line 506 of file tool_action.h.

Referenced by GetIcon(), and TOOL_ACTION().

◆ m_id

int TOOL_ACTION::m_id
protected

Unique ID for maps. Assigned by ACTION_MANAGER.

Definition at line 508 of file tool_action.h.

Referenced by GetId(), GetUIId(), operator!=(), and operator==().

◆ m_legacyName

const std::string TOOL_ACTION::m_legacyName
protected

Name for reading legacy hotkey settings.

Definition at line 499 of file tool_action.h.

Referenced by ACTION_MANAGER::processHotKey().

◆ m_menuLabel

std::optional<wxString> TOOL_ACTION::m_menuLabel
protected

Menu label.

Definition at line 502 of file tool_action.h.

Referenced by GetMenuLabel(), and TOOL_ACTION().

◆ m_name

std::string TOOL_ACTION::m_name
protected

Name of the action (convention is "app.tool.actionName")

Definition at line 488 of file tool_action.h.

Referenced by GetName(), GetToolName(), MakeEvent(), ACTION_MANAGER::processHotKey(), ACTION_MANAGER::RegisterAction(), and TOOL_ACTION().

◆ m_param

ki::any TOOL_ACTION::m_param
protected

Generic parameter.

Definition at line 514 of file tool_action.h.

Referenced by GetParam(), MakeEvent(), and TOOL_ACTION().

◆ m_scope

TOOL_ACTION_SCOPE TOOL_ACTION::m_scope
protected

Definition at line 489 of file tool_action.h.

Referenced by GetScope(), and MakeEvent().

◆ m_toolbarState

TOOLBAR_STATE_FLAGS TOOL_ACTION::m_toolbarState
protected

Toolbar state behavior for the action.

Definition at line 511 of file tool_action.h.

Referenced by CheckToolbarState(), and TOOL_ACTION().

◆ m_tooltip

wxString TOOL_ACTION::m_tooltip
protected

User facing tooltip help text.

Definition at line 503 of file tool_action.h.

Referenced by GetTooltip().

◆ m_uiid

std::optional<int> TOOL_ACTION::m_uiid
protected

ID to use when interacting with the UI (if empty, generate one).

Definition at line 509 of file tool_action.h.

Referenced by GetUIId(), HasCustomUIId(), and TOOL_ACTION().


The documentation for this class was generated from the following files: