KiCad PCB EDA Suite
ACTION_GROUP Class Reference

A group of actions that will be displayed together on a toolbar palette. More...

#include <action_toolbar.h>

Public Member Functions

 ACTION_GROUP (std::string aName, const std::vector< const TOOL_ACTION * > &aActions)
 
void SetDefaultAction (const TOOL_ACTION &aDefault)
 Set the default action to use when first creating the toolbar palette icon. More...
 
const TOOL_ACTIONGetDefaultAction () const
 Get the default action to use when first creating this group's toolbar palette icon. More...
 
std::string GetName () const
 Get the name of the group. More...
 
int GetUIId () const
 Get the ID used in the UI to reference this group. More...
 
const std::vector< const TOOL_ACTION * > & GetActions () const
 Get a vector of all the actions contained inside this group. More...
 

Protected Attributes

int m_id
 < The action ID for this action group More...
 
std::string m_name
 The default action to display on the toolbar item. More...
 
const TOOL_ACTIONm_defaultAction
 The actions that compose the group. More...
 
std::vector< const TOOL_ACTION * > m_actions
 

Friends

class ACTION_TOOLBAR
 

Detailed Description

A group of actions that will be displayed together on a toolbar palette.

Definition at line 47 of file action_toolbar.h.

Constructor & Destructor Documentation

◆ ACTION_GROUP()

ACTION_GROUP::ACTION_GROUP ( std::string  aName,
const std::vector< const TOOL_ACTION * > &  aActions 
)

Definition at line 46 of file action_toolbar.cpp.

47 {
48  wxASSERT_MSG( aActions.size() > 0, "Action groups must have at least one action" );
49 
50  // The default action is just the first action in the vector
51  m_actions = aActions;
53 
54  m_name = aName;
56 }
const TOOL_ACTION * m_defaultAction
The actions that compose the group.
static int MakeActionId(const std::string &aActionName)
Generate an unique ID from for an action with given name.
std::vector< const TOOL_ACTION * > m_actions
int m_id
< The action ID for this action group
std::string m_name
The default action to display on the toolbar item.

References m_actions, m_defaultAction, m_id, m_name, and ACTION_MANAGER::MakeActionId().

Member Function Documentation

◆ GetActions()

const std::vector< const TOOL_ACTION*>& ACTION_GROUP::GetActions ( ) const
inline

Get a vector of all the actions contained inside this group.

Definition at line 83 of file action_toolbar.h.

83 { return m_actions; }
std::vector< const TOOL_ACTION * > m_actions

References m_actions.

◆ GetDefaultAction()

const TOOL_ACTION* ACTION_GROUP::GetDefaultAction ( ) const
inline

Get the default action to use when first creating this group's toolbar palette icon.

Definition at line 68 of file action_toolbar.h.

68 { return m_defaultAction; }
const TOOL_ACTION * m_defaultAction
The actions that compose the group.

References m_defaultAction.

Referenced by ACTION_TOOLBAR::AddGroup().

◆ GetName()

std::string ACTION_GROUP::GetName ( void  ) const
inline

Get the name of the group.

Definition at line 73 of file action_toolbar.h.

73 { return m_name; }
std::string m_name
The default action to display on the toolbar item.

References m_name.

◆ GetUIId()

int ACTION_GROUP::GetUIId ( ) const
inline

Get the ID used in the UI to reference this group.

Definition at line 78 of file action_toolbar.h.

78 { return m_id + TOOL_ACTION::GetBaseUIId(); }
static int GetBaseUIId()
Definition: tool_action.h:117
int m_id
< The action ID for this action group

References TOOL_ACTION::GetBaseUIId(), and m_id.

Referenced by ACTION_TOOLBAR::AddGroup(), and ACTION_TOOLBAR::doSelectAction().

◆ SetDefaultAction()

void ACTION_GROUP::SetDefaultAction ( const TOOL_ACTION aDefault)

Set the default action to use when first creating the toolbar palette icon.

If no default action is provided, the default will be the first action in the vector.

Parameters
aDefaultis the default action.

Definition at line 59 of file action_toolbar.cpp.

60 {
61  bool valid = std::any_of( m_actions.begin(), m_actions.end(),
62  [&]( const TOOL_ACTION* aAction ) -> bool
63  {
64  // For some reason, we can't compare the actions directly
65  return aAction->GetId() == aDefault.GetId();
66  } );
67 
68  wxASSERT_MSG( valid, "Action must be present in a group to be the default" );
69 
70  m_defaultAction = &aDefault;
71 }
const TOOL_ACTION * m_defaultAction
The actions that compose the group.
std::vector< const TOOL_ACTION * > m_actions
int GetId() const
Return the unique id of the TOOL_ACTION object.
Definition: tool_action.h:103
Represent a single user action.
Definition: tool_action.h:49

References TOOL_ACTION::GetId(), m_actions, and m_defaultAction.

Friends And Related Function Documentation

◆ ACTION_TOOLBAR

friend class ACTION_TOOLBAR
friend

Definition at line 51 of file action_toolbar.h.

Member Data Documentation

◆ m_actions

std::vector<const TOOL_ACTION*> ACTION_GROUP::m_actions
protected

◆ m_defaultAction

const TOOL_ACTION* ACTION_GROUP::m_defaultAction
protected

The actions that compose the group.

Definition at line 93 of file action_toolbar.h.

Referenced by ACTION_GROUP(), GetDefaultAction(), and SetDefaultAction().

◆ m_id

int ACTION_GROUP::m_id
protected

< The action ID for this action group

The name of this action group

Definition at line 87 of file action_toolbar.h.

Referenced by ACTION_GROUP(), and GetUIId().

◆ m_name

std::string ACTION_GROUP::m_name
protected

The default action to display on the toolbar item.

Definition at line 90 of file action_toolbar.h.

Referenced by ACTION_GROUP(), and GetName().


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