Heaven v0.1.0-1
C++ global-menu library for Wayland sessions
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
HNToggle Class Reference

Clickable item with a checked/unchecked state created by a client. More...

#include "HNToggle.h"

Inheritance diagram for HNToggle:
Inheritance graph
[legend]
Collaboration diagram for HNToggle:
Collaboration graph
[legend]

Public Member Functions

void setChecked (bool checked) noexcept
 Updates the checked state and notifies the bar.
 
bool checked () const noexcept
 Returns the current checked state.
 
- Public Member Functions inherited from HNObject
UInt32 id () const noexcept
 Returns the unique identifier of this object within the client.
 
Type type () const noexcept
 Returns the immutable role/type of this object.
 
std::shared_ptr< HNClientclient () const noexcept
 Returns the client that owns this object.
 
 ~HNObject () noexcept
 Destructor. Notifies the bar that the object was destroyed.
 
- Public Member Functions inherited from HNWithTitle
const std::string & title () const noexcept
 Returns the current title.
 
void setTitle (const std::string &title) noexcept
 Updates the title and notifies the bar.
 
virtual ~HNWithTitle () noexcept=default
 Virtual destructor (makes the mixin polymorphic for safe cross-casts).
 
- Public Member Functions inherited from HNWithIcon
const std::string & icon () const noexcept
 Returns the current icon name.
 
void setIcon (const std::string &icon) noexcept
 Updates the icon name and notifies the bar.
 
virtual ~HNWithIcon () noexcept=default
 Virtual destructor (makes the mixin polymorphic for safe cross-casts).
 
- Public Member Functions inherited from HNWithShortcut
const std::string & shortcut () const noexcept
 Returns the current keyboard shortcut.
 
void setShortcut (const std::string &shortcut) noexcept
 Updates the shortcut and notifies the bar.
 
virtual ~HNWithShortcut () noexcept=default
 Virtual destructor (makes the mixin polymorphic for safe cross-casts).
 
- Public Member Functions inherited from HNWithEnabled
bool enabled () const noexcept
 Returns whether the object is currently enabled.
 
void setEnabled (bool enabled) noexcept
 Updates the enabled state and notifies the bar.
 
virtual ~HNWithEnabled () noexcept=default
 Virtual destructor (makes the mixin polymorphic for safe cross-casts).
 
- Public Member Functions inherited from HNWithParent
virtual ~HNWithParent () noexcept
 Destructor. Detaches this object from its parent.
 
HNObjectparent () const noexcept
 Returns the parent object.
 
bool setParent (HNObject *parent) noexcept
 Sets the parent.
 
bool insertBefore (HNObject *sibling) noexcept
 Inserts this object before the specified sibling.
 

Static Public Member Functions

static std::shared_ptr< HNToggleMake (const std::string &title="", const std::string &icon="", const std::string &shortcut="", bool checked=false, bool enabled=true, HNObject *parent=nullptr) noexcept
 Creates a new toggle and applies the given initial properties.
 

Additional Inherited Members

- Public Types inherited from HNObject
enum  Type {
  Topbar ,
  Menu ,
  Action ,
  Toggle ,
  Divider
}
 Enumeration of the possible object roles. More...
 
- Data Fields inherited from HNObject
CZSignal< HNObject * > onClicked
 Emitted when the bar notifies that this object was clicked.
 
- Protected Member Functions inherited from HNObject
 HNObject (std::shared_ptr< HNClient > client, UInt32 id, Type type) noexcept
 Constructs an object owned by the given client.
 

Detailed Description

Clickable item with a checked/unchecked state created by a client.

As with actions, clicks arrive through HNObject::onClicked. The client is responsible for updating the checked state (typically toggling it) in response and committing the change.

Member Function Documentation

◆ checked()

bool checked ( ) const
inlinenoexcept

Returns the current checked state.

Returns
true if checked, false otherwise.

◆ Make()

static std::shared_ptr< HNToggle > Make ( const std::string &  title = "",
const std::string &  icon = "",
const std::string &  shortcut = "",
bool  checked = false,
bool  enabled = true,
HNObject parent = nullptr 
)
staticnoexcept

Creates a new toggle and applies the given initial properties.

Parameters
titleInitial title.
iconInitial icon name.
shortcutInitial keyboard shortcut.
checkedInitial checked state.
enabledInitial enabled state.
parentObject to attach this toggle to, or nullptr.
Returns
Shared pointer to the new toggle, or nullptr on failure.

◆ setChecked()

void setChecked ( bool  checked)
noexcept

Updates the checked state and notifies the bar.

Parameters
checkedNew checked state.

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