2013-09-19 15:02:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-11-08 21:34:14 +00:00
|
|
|
* Copyright (C) 2013-2023 CERN
|
2020-12-27 00:41:04 +00:00
|
|
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
2013-09-19 15:02:57 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-27 16:51:21 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
2013-09-19 15:02:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-09-18 17:56:37 +00:00
|
|
|
#ifndef __TOOL_ACTION_H
|
|
|
|
#define __TOOL_ACTION_H
|
|
|
|
|
2022-09-28 01:15:19 +00:00
|
|
|
#include <any>
|
2013-09-26 12:09:18 +00:00
|
|
|
#include <cassert>
|
2022-09-26 22:44:34 +00:00
|
|
|
#include <optional>
|
2023-07-12 23:53:06 +00:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
2013-09-18 17:56:37 +00:00
|
|
|
|
2021-06-06 17:26:26 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
|
|
|
|
class TOOL_EVENT;
|
2013-09-18 17:56:37 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
enum class BITMAPS : unsigned int;
|
2015-04-02 14:09:48 +00:00
|
|
|
|
2021-06-06 17:26:26 +00:00
|
|
|
/// Scope of tool actions
|
|
|
|
enum TOOL_ACTION_SCOPE
|
|
|
|
{
|
|
|
|
AS_CONTEXT = 1, ///< Action belongs to a particular tool (i.e. a part of a pop-up menu)
|
|
|
|
AS_ACTIVE, ///< All active tools
|
|
|
|
AS_GLOBAL ///< Global action (toolbar/main menu event, global shortcut)
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Flags for tool actions
|
|
|
|
enum TOOL_ACTION_FLAGS
|
|
|
|
{
|
|
|
|
AF_NONE = 0,
|
|
|
|
AF_ACTIVATE = 1, ///< Action activates a tool
|
|
|
|
AF_NOTIFY = 2 ///< Action is a notification (it is by default passed to all tools)
|
|
|
|
};
|
|
|
|
|
2023-10-05 12:34:25 +00:00
|
|
|
/**
|
|
|
|
* Define a group that can be used to group actions (and their events) of similar operations.
|
|
|
|
*/
|
|
|
|
class TOOL_ACTION_GROUP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TOOL_ACTION_GROUP( std::string aName ) :
|
|
|
|
m_name( aName )
|
|
|
|
{
|
|
|
|
// Assign a unique group ID to each group
|
|
|
|
static int groupIDs = 0;
|
|
|
|
m_groupID = ++groupIDs;
|
|
|
|
};
|
|
|
|
|
|
|
|
TOOL_ACTION_GROUP( const TOOL_ACTION_GROUP& aOther )
|
|
|
|
{
|
|
|
|
// Ensure a copy of a group is exactly the same as this one to get
|
|
|
|
// proper comparisons
|
|
|
|
m_name = aOther.GetName();
|
|
|
|
m_groupID = aOther.GetGroupID();
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetGroupID() const { return m_groupID; }
|
|
|
|
const std::string& GetName() const { return m_name; }
|
|
|
|
|
|
|
|
bool operator==( const TOOL_ACTION_GROUP& aOther ) const
|
|
|
|
{
|
|
|
|
return m_groupID == aOther.m_groupID;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_groupID;
|
|
|
|
std::string m_name;
|
|
|
|
};
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* Build up the properties of a TOOL_ACTION in an incremental manner that is static-construction
|
|
|
|
* safe.
|
2023-07-12 23:53:06 +00:00
|
|
|
*
|
|
|
|
* Note: This is meant to be constructed and immediately passed into the TOOL_ACTION constructor.
|
|
|
|
* Construction should not be delayed, since this only retains pointers to the strings used.
|
2022-09-26 22:44:34 +00:00
|
|
|
*/
|
|
|
|
class TOOL_ACTION_ARGS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TOOL_ACTION_ARGS() = default;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the action, the convention is "app.tool.actionName".
|
|
|
|
*
|
|
|
|
* This is a required property.
|
|
|
|
*/
|
2023-07-12 23:53:06 +00:00
|
|
|
TOOL_ACTION_ARGS& Name( const std::string_view& aName )
|
2022-09-26 22:44:34 +00:00
|
|
|
{
|
|
|
|
m_name = aName;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2023-10-27 22:40:35 +00:00
|
|
|
TOOL_ACTION_ARGS& FriendlyName( const std::string_view& aName )
|
|
|
|
{
|
|
|
|
m_friendlyName = aName;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* The scope of the action.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& Scope( TOOL_ACTION_SCOPE aScope )
|
|
|
|
{
|
|
|
|
m_scope = aScope;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The default hotkey to assign to the action.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& DefaultHotkey( int aDefaultHotkey )
|
|
|
|
{
|
|
|
|
m_defaultHotKey = aDefaultHotkey;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
/**
|
|
|
|
* The default alternate hotkey to assign to the action.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& DefaultHotkeyAlt( int aDefaultHotkeyAlt )
|
|
|
|
{
|
|
|
|
m_defaultHotKeyAlt = aDefaultHotkeyAlt;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* The legacy hotkey name from the old system.
|
|
|
|
*
|
|
|
|
* This property is only needed for existing actions and shouldn't be used in new actions.
|
|
|
|
*/
|
2023-07-12 23:53:06 +00:00
|
|
|
TOOL_ACTION_ARGS& LegacyHotkeyName( const std::string_view& aLegacyName )
|
2022-09-26 22:44:34 +00:00
|
|
|
{
|
|
|
|
m_legacyName = aLegacyName;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*The string to use when displaying the action in a menu.
|
|
|
|
*/
|
2023-07-12 23:53:06 +00:00
|
|
|
TOOL_ACTION_ARGS& MenuText( const std::string_view& aMenuText )
|
2022-09-26 22:44:34 +00:00
|
|
|
{
|
|
|
|
m_menuText = aMenuText;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The string to use as a tooltip for the action in menus and toolbars.
|
|
|
|
*/
|
2023-07-12 23:53:06 +00:00
|
|
|
TOOL_ACTION_ARGS& Tooltip( const std::string_view& aTooltip )
|
2022-09-26 22:44:34 +00:00
|
|
|
{
|
|
|
|
m_tooltip = aTooltip;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2023-06-29 23:06:03 +00:00
|
|
|
/**
|
|
|
|
* The description of the action.
|
|
|
|
*/
|
2023-07-12 23:53:06 +00:00
|
|
|
TOOL_ACTION_ARGS& Description( const std::string_view& aDescription )
|
2023-06-29 23:06:03 +00:00
|
|
|
{
|
|
|
|
m_description = aDescription;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* The bitmap to use as the icon for the action in toolbars and menus.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& Icon( BITMAPS aIcon )
|
|
|
|
{
|
|
|
|
m_icon = aIcon;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flags describing the type of the action.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& Flags( TOOL_ACTION_FLAGS aFlags )
|
|
|
|
{
|
|
|
|
m_flags = aFlags;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom parameter to pass information to the tool.
|
|
|
|
*/
|
2022-09-29 02:15:22 +00:00
|
|
|
template<typename T>
|
|
|
|
TOOL_ACTION_ARGS& Parameter( T aParam )
|
2022-09-26 22:44:34 +00:00
|
|
|
{
|
|
|
|
m_param = aParam;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-09-27 21:03:58 +00:00
|
|
|
/**
|
|
|
|
* The ID number to use for the action when interacting with any UI elements.
|
|
|
|
*/
|
|
|
|
TOOL_ACTION_ARGS& UIId( int aUIId )
|
|
|
|
{
|
|
|
|
m_uiid = aUIId;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2023-10-05 12:34:25 +00:00
|
|
|
TOOL_ACTION_ARGS& Group( const TOOL_ACTION_GROUP& aGroup )
|
|
|
|
{
|
|
|
|
m_group = aGroup;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
protected:
|
|
|
|
// Let the TOOL_ACTION constructor have direct access to the members here
|
|
|
|
friend class TOOL_ACTION;
|
|
|
|
|
2023-07-12 23:53:06 +00:00
|
|
|
std::optional<std::string_view> m_name;
|
2023-10-27 22:40:35 +00:00
|
|
|
std::optional<std::string_view> m_friendlyName;
|
2022-09-26 22:44:34 +00:00
|
|
|
std::optional<TOOL_ACTION_SCOPE> m_scope;
|
|
|
|
std::optional<TOOL_ACTION_FLAGS> m_flags;
|
|
|
|
|
2022-09-27 21:03:58 +00:00
|
|
|
std::optional<int> m_uiid;
|
|
|
|
|
2022-09-26 22:44:34 +00:00
|
|
|
std::optional<int> m_defaultHotKey;
|
2023-07-13 14:08:00 +00:00
|
|
|
std::optional<int> m_defaultHotKeyAlt;
|
2023-07-12 23:53:06 +00:00
|
|
|
std::optional<std::string_view> m_legacyName;
|
2022-09-26 22:44:34 +00:00
|
|
|
|
2023-07-12 23:53:06 +00:00
|
|
|
std::optional<std::string_view> m_menuText;
|
|
|
|
std::optional<std::string_view> m_tooltip;
|
|
|
|
std::optional<std::string_view> m_description;
|
2022-09-26 22:44:34 +00:00
|
|
|
|
|
|
|
std::optional<BITMAPS> m_icon;
|
|
|
|
|
2023-10-05 12:34:25 +00:00
|
|
|
std::optional<TOOL_ACTION_GROUP> m_group;
|
|
|
|
|
2022-09-28 01:15:19 +00:00
|
|
|
std::any m_param;
|
2022-09-26 22:44:34 +00:00
|
|
|
};
|
|
|
|
|
2013-09-27 16:51:21 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Represent a single user action.
|
|
|
|
*
|
|
|
|
* For instance:
|
2013-09-27 16:51:21 +00:00
|
|
|
* - changing layer to top by pressing PgUp
|
|
|
|
* - running the DRC from the menu
|
|
|
|
* and so on, and so forth....
|
2020-12-27 00:41:04 +00:00
|
|
|
*
|
2013-09-27 16:51:21 +00:00
|
|
|
* Action class groups all necessary properties of an action, including explanation,
|
2015-04-30 08:46:01 +00:00
|
|
|
* icons, hotkeys, menu items, etc.
|
2013-09-27 16:51:21 +00:00
|
|
|
*/
|
2013-09-19 15:02:57 +00:00
|
|
|
class TOOL_ACTION
|
2013-09-18 17:56:37 +00:00
|
|
|
{
|
2013-09-19 15:02:57 +00:00
|
|
|
public:
|
2022-09-26 22:44:34 +00:00
|
|
|
TOOL_ACTION( const TOOL_ACTION_ARGS& aArgs );
|
2013-10-14 18:40:36 +00:00
|
|
|
TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT,
|
2020-07-23 23:47:19 +00:00
|
|
|
int aDefaultHotKey = 0, const std::string& aLegacyHotKeyName = "",
|
2020-12-27 00:41:04 +00:00
|
|
|
const wxString& aMenuText = wxEmptyString,
|
|
|
|
const wxString& aTooltip = wxEmptyString,
|
2022-09-28 01:15:19 +00:00
|
|
|
BITMAPS aIcon = static_cast<BITMAPS>( 0 ), TOOL_ACTION_FLAGS aFlags = AF_NONE);
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2015-05-05 18:39:41 +00:00
|
|
|
~TOOL_ACTION();
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2019-06-17 22:02:30 +00:00
|
|
|
// TOOL_ACTIONS are singletons; don't be copying them around....
|
|
|
|
TOOL_ACTION( const TOOL_ACTION& ) = delete;
|
|
|
|
TOOL_ACTION& operator= ( const TOOL_ACTION& ) = delete;
|
|
|
|
|
2013-09-19 15:02:57 +00:00
|
|
|
bool operator==( const TOOL_ACTION& aRhs ) const
|
|
|
|
{
|
|
|
|
return m_id == aRhs.m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( const TOOL_ACTION& aRhs ) const
|
|
|
|
{
|
|
|
|
return m_id != aRhs.m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* 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".
|
2013-09-19 15:02:57 +00:00
|
|
|
*
|
|
|
|
* @return Name of the action.
|
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
const std::string& GetName() const { return m_name; }
|
2020-07-23 23:47:19 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return the default hotkey (if any) for the action.
|
2019-06-09 21:57:23 +00:00
|
|
|
*/
|
|
|
|
int GetDefaultHotKey() const { return m_defaultHotKey; }
|
2023-07-13 14:08:00 +00:00
|
|
|
int GetDefaultHotKeyAlt() const { return m_defaultHotKeyAlt; }
|
2020-07-23 23:47:19 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return the hotkey keycode which initiates the action.
|
2019-06-09 21:57:23 +00:00
|
|
|
*/
|
|
|
|
int GetHotKey() const { return m_hotKey; }
|
2023-07-13 14:08:00 +00:00
|
|
|
int GetHotKeyAlt() const { return m_hotKeyAlt; }
|
|
|
|
void SetHotKey( int aKeycode, int aKeycodeAlt = 0 );
|
2020-07-23 23:47:19 +00:00
|
|
|
|
2013-09-19 15:02:57 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return the unique id of the TOOL_ACTION object.
|
|
|
|
*
|
|
|
|
* It is valid only after registering the TOOL_ACTION by #ACTION_MANAGER.
|
2013-09-19 15:02:57 +00:00
|
|
|
*
|
|
|
|
* @return The unique identification number. If the number is negative, then it is not valid.
|
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
int GetId() const { return m_id; }
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2022-09-27 21:03:58 +00:00
|
|
|
/**
|
|
|
|
* Return true if this action has a custom UI ID set.
|
|
|
|
*/
|
|
|
|
bool HasCustomUIId() const { return m_uiid.has_value(); }
|
|
|
|
|
2020-07-23 23:47:19 +00:00
|
|
|
/*
|
2020-12-27 00:41:04 +00:00
|
|
|
* Get the unique ID for this action in the user interface system.
|
|
|
|
*
|
2022-09-27 21:03:58 +00:00
|
|
|
* This can be either set to a specific ID during creation or computed
|
|
|
|
* by offsetting the action ID by @c ACTION_BASE_UI_ID.
|
2020-07-23 23:47:19 +00:00
|
|
|
*
|
|
|
|
* @return The unique ID number for use in the user interface system.
|
|
|
|
*/
|
2022-09-27 21:03:58 +00:00
|
|
|
int GetUIId() const { return m_uiid.value_or( m_id + ACTION_BASE_UI_ID ); }
|
2020-07-23 23:47:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the base value used to offset the user interface IDs for the actions.
|
|
|
|
*/
|
|
|
|
static int GetBaseUIId() { return ACTION_BASE_UI_ID; }
|
|
|
|
|
2013-09-19 15:02:57 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return the event associated with the action (i.e. the event that will be sent after
|
2013-09-19 15:02:57 +00:00
|
|
|
* activating the action).
|
|
|
|
*/
|
2021-06-06 17:26:26 +00:00
|
|
|
TOOL_EVENT MakeEvent() const;
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2023-08-04 17:07:31 +00:00
|
|
|
/**
|
|
|
|
* Return the translated label for the action.
|
|
|
|
*/
|
2023-10-27 22:40:35 +00:00
|
|
|
wxString GetMenuLabel() const;
|
2019-06-17 00:34:21 +00:00
|
|
|
wxString GetMenuItem() const;
|
2023-06-29 23:06:03 +00:00
|
|
|
wxString GetTooltip( bool aIncludeHotkey = true ) const;
|
2024-02-17 15:15:42 +00:00
|
|
|
wxString GetButtonTooltip() const;
|
2023-06-29 23:06:03 +00:00
|
|
|
wxString GetDescription() const;
|
2013-09-26 12:09:18 +00:00
|
|
|
|
2023-10-27 22:40:35 +00:00
|
|
|
/**
|
|
|
|
* Return the translated user-friendly name of the action.
|
|
|
|
*/
|
|
|
|
wxString GetFriendlyName() const;
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
TOOL_ACTION_SCOPE GetScope() const { return m_scope; }
|
2014-04-09 15:05:05 +00:00
|
|
|
|
2022-09-28 01:15:19 +00:00
|
|
|
/**
|
|
|
|
* Return a non-standard parameter assigned to the action.
|
|
|
|
*/
|
|
|
|
template<typename T>
|
|
|
|
T GetParam() const
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_param.has_value(), "Attempted to get a parameter from an action with no parameter." );
|
|
|
|
|
|
|
|
T param;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
param = std::any_cast<T>( m_param );
|
|
|
|
}
|
|
|
|
catch( const std::bad_any_cast& e )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( false,
|
|
|
|
wxString::Format( "Requested parameter type %s from action with parameter type %s.",
|
|
|
|
typeid(T).name(), m_param.type().name() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return param;
|
|
|
|
}
|
|
|
|
|
2023-10-05 12:34:25 +00:00
|
|
|
const std::optional<TOOL_ACTION_GROUP> GetActionGroup() const { return m_group; }
|
2021-02-24 18:43:12 +00:00
|
|
|
|
2014-04-09 15:05:05 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return name of the tool associated with the action. It is basically the action name
|
2014-04-09 15:05:05 +00:00
|
|
|
* stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is
|
|
|
|
* "pcbnew.InteractiveDrawing").
|
|
|
|
*/
|
2014-07-09 11:50:27 +00:00
|
|
|
std::string GetToolName() const;
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return true if the action is intended to activate a tool.
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
|
|
|
bool IsActivation() const
|
2014-04-09 15:05:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
return m_flags & AF_ACTIVATE;
|
2014-04-09 15:05:05 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return true if the action is a notification.
|
2014-07-09 13:10:32 +00:00
|
|
|
*/
|
|
|
|
bool IsNotification() const
|
|
|
|
{
|
|
|
|
return m_flags & AF_NOTIFY;
|
|
|
|
}
|
|
|
|
|
2015-04-02 14:09:48 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Return an icon associated with the action.
|
|
|
|
*
|
|
|
|
* It is used in context menu.
|
2015-04-02 14:09:48 +00:00
|
|
|
*/
|
2023-05-19 01:34:30 +00:00
|
|
|
BITMAPS GetIcon() const
|
2015-04-02 14:09:48 +00:00
|
|
|
{
|
|
|
|
return m_icon;
|
|
|
|
}
|
|
|
|
|
2019-06-12 14:39:47 +00:00
|
|
|
protected:
|
|
|
|
TOOL_ACTION();
|
|
|
|
|
2013-09-19 15:02:57 +00:00
|
|
|
friend class ACTION_MANAGER;
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Base ID to use inside the user interface system to offset the action IDs.
|
2020-07-23 23:47:19 +00:00
|
|
|
static constexpr int ACTION_BASE_UI_ID = 20000;
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Name of the action (convention is "app.tool.actionName")
|
2019-06-09 21:57:23 +00:00
|
|
|
std::string m_name;
|
|
|
|
TOOL_ACTION_SCOPE m_scope;
|
2023-10-05 12:34:25 +00:00
|
|
|
|
|
|
|
std::optional<TOOL_ACTION_GROUP> m_group; // Optional group for the action to belong to
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
const int m_defaultHotKey; // Default hot key
|
|
|
|
const int m_defaultHotKeyAlt; // Default hot key alternate
|
2020-12-27 00:41:04 +00:00
|
|
|
int m_hotKey; // The current hotkey (post-user-settings-application)
|
2023-07-13 14:08:00 +00:00
|
|
|
int m_hotKeyAlt; // The alternate hotkey (post-user-settings-application)
|
2019-06-09 21:57:23 +00:00
|
|
|
const std::string m_legacyName; // Name for reading legacy hotkey settings
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2023-10-27 22:40:35 +00:00
|
|
|
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
|
2023-06-29 23:06:03 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS m_icon; // Icon for the menu entry
|
2013-09-19 15:02:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
int m_id; // Unique ID for maps. Assigned by ACTION_MANAGER.
|
2022-09-27 21:03:58 +00:00
|
|
|
std::optional<int> m_uiid; // ID to use when interacting with the UI (if empty, generate one)
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
TOOL_ACTION_FLAGS m_flags;
|
2022-09-28 01:15:19 +00:00
|
|
|
std::any m_param; // Generic parameter
|
2013-09-18 17:56:37 +00:00
|
|
|
};
|
2013-09-26 12:09:18 +00:00
|
|
|
|
2013-09-18 17:56:37 +00:00
|
|
|
#endif
|