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

Base class for all menu objects created by a client. 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 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.
 

Data Fields

CZSignal< HNObject * > onClicked
 Emitted when the bar notifies that this object was clicked.
 

Protected Member Functions

 HNObject (std::shared_ptr< HNClient > client, UInt32 id, Type type) noexcept
 Constructs an object owned by the given client.
 

Detailed Description

Base class for all menu objects created by a client.

A client builds its menu tree out of HNObject subclasses (HNTopbar, HNMenu, HNAction, HNToggle, HNDivider). Objects are reference-counted through std::shared_ptr; destroying the last reference removes the object and, once connected, notifies the bar.

The role/type of an object is fixed at construction time.

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 ( std::shared_ptr< HNClient client,
UInt32  id,
Type  type 
)
protectednoexcept

Constructs an object owned by the given client.

Parameters
clientOwning client.
idUnique object identifier within the client.
typeImmutable object role.

Member Function Documentation

◆ client()

std::shared_ptr< HNClient > client ( ) const
inlinenoexcept

Returns the client that owns this object.

Returns
Shared pointer to the owning client.

◆ id()

UInt32 id ( ) const
inlinenoexcept

Returns the unique identifier of this object within the client.

Returns
The object identifier (always greater than 0).

◆ type()

Type type ( ) const
inlinenoexcept

Returns the immutable role/type of this object.

Returns
The object type.

Field Documentation

◆ onClicked

CZSignal<HNObject*> onClicked

Emitted when the bar notifies that this object was clicked.

Parameters
objectPointer to the clicked object (this).

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