Loading...
Searching...
No Matches
ml::Flaggable Class Reference

Trait that provides system-level boolean flag management. More...

#include <Flaggable.h>

Inheritance diagram for ml::Flaggable:

Public Types

using State
 The enum type this manager stores flags for.

Public Member Functions

bool checkFlag (State state) const
 Return the current value of a flag.
void disableFlag (State state)
 Set a flag to false.
void enableFlag (State state)
 Set a flag to true.
void setFlag (State state, bool status)
 Set a flag to an explicit value.
void toggleFlag (State state)
 Flip a flag between true and false.

Detailed Description

Trait that provides system-level boolean flag management.

Flaggable layers FlagManager<ml::Flag> onto the Trait base, giving any inheriting class the ability to read and write the framework's built-in ml::Flag values.

It is one of the three core traits automatically included in every ml::Core object (Subscribable, Flaggable, Positionable). Framework dispatchers check ml::Flag values to gate built-in behavior:

Flag Effect
ml::Flag::DRAGGABLE Enables drag handling in DraggableDispatcher
ml::Flag::HOVERED Set by HoverableDispatcher while the mouse is over the component
ml::Flag::FOCUSED Set by ClickableDispatcher when the component has keyboard focus

Usage

// Enable dragging on a component
myComponent.setFlag(ml::Flag::DRAGGABLE);
// Check hover state
if (myComponent.checkFlag(ml::Flag::HOVERED)) { ... }
// Toggle focus
myComponent.toggleFlag(ml::Flag::FOCUSED);
@ FOCUSED
Component has keyboard focus (set by ClickableDispatcher).
Definition Flag.h:65
@ HOVERED
Mouse is currently over this component (set by HoverableDispatcher).
Definition Flag.h:61
@ DRAGGABLE
Enables drag handling in ComponentCore.
Definition Flag.h:67

For custom (manifest-declared) flags, see CustomFlaggable and MultiCustomFlaggable, which are composed into components separately.

See also
FlagManager, ml::Flag, Core, CustomFlaggable

Definition at line 49 of file Flaggable.h.

Member Typedef Documentation

◆ State

using ml::FlagManager< Flag >::State
inherited

The enum type this manager stores flags for.

Definition at line 62 of file FlagManager.h.

Member Function Documentation

◆ checkFlag()

bool ml::FlagManager< Flag >::checkFlag ( State state) const
inherited

Return the current value of a flag.

Returns false for any flag that has never been explicitly set.

Parameters
stateThe flag to query.
Returns
true if the flag is enabled; false otherwise.

◆ disableFlag()

void ml::FlagManager< Flag >::disableFlag ( State state)
inherited

Set a flag to false.

Parameters
stateThe flag to disable.

◆ enableFlag()

void ml::FlagManager< Flag >::enableFlag ( State state)
inherited

Set a flag to true.

Parameters
stateThe flag to enable.

◆ setFlag()

void ml::FlagManager< Flag >::setFlag ( State state,
bool status )
inherited

Set a flag to an explicit value.

Parameters
stateThe flag to modify.
statustrue to enable, false to disable.

◆ toggleFlag()

void ml::FlagManager< Flag >::toggleFlag ( State state)
inherited

Flip a flag between true and false.

Parameters
stateThe flag to toggle.

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