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

State model for a conventional menu bar. More...

#include <RADWidgets.h>

+ Inheritance diagram for RADUi::MenuBarModel:
+ Collaboration diagram for RADUi::MenuBarModel:

Public Member Functions

const std::vector< Menu > & menus () const
 Returns all top-level menus. More...
 
void setMenus (std::vector< Menu > menus)
 Replaces the complete menu structure. More...
 
std::optional< size_t > activeMenuIndex () const
 Returns the active/open top-level menu index, if any. More...
 
void openMenu (size_t index)
 Opens a top-level menu by index. More...
 
void toggleMenu (size_t index)
 Opens index or closes it if already active. More...
 
void close ()
 Closes the active menu. More...
 
bool triggerItem (size_t menuIndex, size_t itemIndex)
 Triggers an item by menu and item index. More...
 
bool setItemChecked (const std::string &id, bool checked)
 Updates a checkable item by stable id. 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 menu contents or active menu state changes. More...
 
RADCore::Event< void(std::string) > itemTriggered
 Raised with MenuItem::id when an item is triggered. More...
 

Detailed Description

State model for a conventional menu bar.

Member Function Documentation

◆ activeMenuIndex()

std::optional<size_t> RADUi::MenuBarModel::activeMenuIndex ( ) const

Returns the active/open top-level menu index, if any.

◆ close()

void RADUi::MenuBarModel::close ( )

Closes the active menu.

◆ menus()

const std::vector<Menu>& RADUi::MenuBarModel::menus ( ) const

Returns all top-level menus.

◆ openMenu()

void RADUi::MenuBarModel::openMenu ( size_t  index)

Opens a top-level menu by index.

◆ setItemChecked()

bool RADUi::MenuBarModel::setItemChecked ( const std::string &  id,
bool  checked 
)

Updates a checkable item by stable id.

◆ setMenus()

void RADUi::MenuBarModel::setMenus ( std::vector< Menu menus)

Replaces the complete menu structure.

◆ toggleMenu()

void RADUi::MenuBarModel::toggleMenu ( size_t  index)

Opens index or closes it if already active.

◆ triggerItem()

bool RADUi::MenuBarModel::triggerItem ( size_t  menuIndex,
size_t  itemIndex 
)

Triggers an item by menu and item index.

Member Data Documentation

◆ changed

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

Raised when menu contents or active menu state changes.

◆ itemTriggered

RADCore::Event<void (std::string) > RADUi::MenuBarModel::itemTriggered

Raised with MenuItem::id when an item is triggered.


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