RADLib
RADical C++ application framework
RADUi::Action Class Reference

Backend-neutral command/action model for buttons, menus, and toolbars. More...

#include <RADWidgets.h>

+ Inheritance diagram for RADUi::Action:
+ Collaboration diagram for RADUi::Action:

Public Member Functions

 Action ()=default
 Creates an empty enabled action. More...
 
 Action (std::string text)
 Creates an enabled action with display text. More...
 
const std::string & text () const
 Returns the action display text. More...
 
void setText (std::string text)
 Updates the action display text. More...
 
bool isEnabled () const
 Returns true when the action can be triggered. More...
 
void setEnabled (bool enabled)
 Enables or disables the action. More...
 
bool isCheckable () const
 Returns true when the action has a checked state. More...
 
void setCheckable (bool checkable)
 Enables or disables checkable behavior. More...
 
bool isChecked () const
 Returns true when a checkable action is checked. More...
 
void setChecked (bool checked)
 Sets the checked state for checkable actions. More...
 
void trigger ()
 Emits triggered when enabled. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Public Attributes

RADCore::Event< void() > changed
 Raised when text, enabled state, checkable state, or checked state changes. More...
 
RADCore::Event< void() > triggered
 Raised when trigger() is called on an enabled action. More...
 

Detailed Description

Backend-neutral command/action model for buttons, menus, and toolbars.

Constructor & Destructor Documentation

◆ Action() [1/2]

RADUi::Action::Action ( )
default

Creates an empty enabled action.

◆ Action() [2/2]

RADUi::Action::Action ( std::string  text)
explicit

Creates an enabled action with display text.

Member Function Documentation

◆ isCheckable()

bool RADUi::Action::isCheckable ( ) const

Returns true when the action has a checked state.

◆ isChecked()

bool RADUi::Action::isChecked ( ) const

Returns true when a checkable action is checked.

◆ isEnabled()

bool RADUi::Action::isEnabled ( ) const

Returns true when the action can be triggered.

◆ setCheckable()

void RADUi::Action::setCheckable ( bool  checkable)

Enables or disables checkable behavior.

◆ setChecked()

void RADUi::Action::setChecked ( bool  checked)

Sets the checked state for checkable actions.

◆ setEnabled()

void RADUi::Action::setEnabled ( bool  enabled)

Enables or disables the action.

◆ setText()

void RADUi::Action::setText ( std::string  text)

Updates the action display text.

◆ text()

const std::string& RADUi::Action::text ( ) const

Returns the action display text.

◆ trigger()

void RADUi::Action::trigger ( )

Emits triggered when enabled.

Member Data Documentation

◆ changed

RADCore::Event<void () > RADUi::Action::changed

Raised when text, enabled state, checkable state, or checked state changes.

◆ triggered

RADCore::Event<void () > RADUi::Action::triggered

Raised when trigger() is called on an enabled action.


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