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

Base class for all objects shared by a client and displayed in the bar. More...

#include "HNObject.h"

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

Public Types

enum  Type {
  Topbar ,
  Menu ,
  Action ,
  Toggle ,
  Divider
}
 Enumeration of the possible object roles. More...
 

Public Member Functions

UInt32 id () const noexcept
 Returns the client-assigned unique identifier of this object.
 
Type type () const noexcept
 Returns the immutable role/type of this object.
 
HNClientclient () const noexcept
 Returns the client that owns this object.
 
void click () noexcept
 Notifies the owning client that this object was clicked.
 

Static Public Member Functions

static bool IsValidType (UInt32 type) noexcept
 Checks whether a numeric value is a valid object type.
 

Protected Member Functions

 HNObject (UInt32 id, Type type) noexcept
 Constructs an object with the given id and role.
 

Detailed Description

Base class for all objects shared by a client and displayed in the bar.

Every menu item exposed by a client is represented, on the bar side, by a subclass of HNObject (HNTopbar, HNMenu, HNAction, HNToggle, HNDivider).

The concrete role of an object is fixed at creation time and never changes during its lifetime. Depending on its role, an object may additionally implement the HNWith* mixin interfaces (title, icon, parent, children, etc.).

Instances are owned and managed by the bar library; they are created and destroyed as the owning client requests it.

Member Enumeration Documentation

◆ Type

enum Type

Enumeration of the possible object roles.

Enumerator
Topbar 

Top bar container that can host menus.

Menu 

Menu that can host other objects and be nested.

Action 

Clickable action item.

Toggle 

Clickable item with a checked/unchecked state.

Divider 

Non-interactive separator.

Constructor & Destructor Documentation

◆ HNObject()

HNObject ( UInt32  id,
Type  type 
)
inlineprotectednoexcept

Constructs an object with the given id and role.

Parameters
idClient-assigned object identifier.
typeImmutable object role.

Member Function Documentation

◆ click()

void click ( )
noexcept

Notifies the owning client that this object was clicked.

The bar application calls this method when the user activates the item. The click is forwarded over D-Bus to the owning client, which will emit its own click notification.

◆ client()

HNClient * client ( ) const
inlinenoexcept

Returns the client that owns this object.

Returns
Pointer to the owning client.

◆ id()

UInt32 id ( ) const
inlinenoexcept

Returns the client-assigned unique identifier of this object.

The identifier is unique within the scope of the owning client.

Returns
The object identifier (always greater than 0).

◆ IsValidType()

static bool IsValidType ( UInt32  type)
inlinestaticnoexcept

Checks whether a numeric value is a valid object type.

Parameters
typeRaw value received over D-Bus.
Returns
true if type maps to a valid Type, false otherwise.

◆ type()

Type type ( ) const
inlinenoexcept

Returns the immutable role/type of this object.

Returns
The object type.

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