Loading...
Searching...
No Matches
ml::Customizable< Manifest > Class Template Reference

Tags a class with a manifest type and wires in its State manager. More...

#include <Customizable.h>

Inheritance diagram for ml::Customizable< Manifest >:

Public Types

using manifest_type = Manifest
 The manifest type, used by GatherFlags and GatherStates to locate this class's flag and state declarations.

Public Member Functions

 Customizable ()=default
virtual ~Customizable ()=default
std::enable_if_t<!std::is_void_v< T >, T > getState () const
 Return the current state value.
std::enable_if_t<!std::is_void_v< T >, bool > isState (T state) const
 Return true if currently in state.
std::enable_if_t<!std::is_void_v< T > > onStateEnter (std::function< void(T)> callback)
 Register a callback invoked after each state transition.
std::enable_if_t<!std::is_void_v< T > > onStateExit (std::function< void(T)> callback)
 Register a callback invoked before each state transition.
std::enable_if_t<!std::is_void_v< T > > setState (T newState)
 Transition to a new state.

Detailed Description

template<typename Manifest>
class ml::Customizable< Manifest >

Tags a class with a manifest type and wires in its State manager.

Customizable<Manifest> is the base class for any framework type that needs to declare a manifest — traits, graphics components, and plugins all inherit from it directly or indirectly through the With<Manifest> pattern.

What Customizable does

  • Exposes manifest_type so that GatherFlags and GatherStates can find this class's manifest when building the multi-flag and multi-state inheritance chains in ComponentCore.
  • Inherits StateManager<State> where State is extracted from the manifest via extract_State<Manifest>::type. If the manifest has no State enum, extract_State yields void and StateManager becomes a no-op.

What Customizable does NOT do

Customizable does not own CustomFlaggable. Flag storage is managed by MultiCustomFlaggable inside ComponentBase, which gathers flags from the component manifest and from every trait that also declares a Flags enum. This prevents duplicate base classes and ensures a single flag map per enum type.

Traits that need to read or write their own flags do so by casting to the appropriate SingleFlaggable base:

auto* f = dynamic_cast<SingleFlaggable<DraggableManifest::Flags>*>(this);
if (f) f->enableFlag(DraggableManifest::Flags::DRAGGING);
Flag store for a single enum type.
void enableFlag(Enum flag)
Set flag to true.

Usage

// A trait with its own manifest
class Draggable : public ml::Customizable<DraggableManifest> {};
// A component with a manifest and an extra trait
class Carousel : public ml::ComponentWith<CarouselManifest, Draggable> {};
Tags a class with a manifest type and wires in its State manager.
Receiver trait that adds mouse-drag behavior to any Component.
Definition Draggable.h:67
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Definition Component.h:150
Template Parameters
ManifestA struct with optional Flags and State enums and optional resource list inner types.
See also
ComponentCore, GatherFlags, GatherStates, StateManager, MultiCustomFlaggable

Customizable.

Definition at line 59 of file Customizable.h.

Member Typedef Documentation

◆ manifest_type

template<typename Manifest>
using ml::Customizable< Manifest >::manifest_type = Manifest

The manifest type, used by GatherFlags and GatherStates to locate this class's flag and state declarations.

Definition at line 64 of file Customizable.h.

Constructor & Destructor Documentation

◆ Customizable()

template<typename Manifest>
ml::Customizable< Manifest >::Customizable ( )
default

◆ ~Customizable()

template<typename Manifest>
virtual ml::Customizable< Manifest >::~Customizable ( )
virtualdefault

Member Function Documentation

◆ getState()

std::enable_if_t<!std::is_void_v< T >, T > ml::StateManager< extract_State< Manifest >::type >::getState ( ) const
inherited

Return the current state value.

Returns
The active StateEnum value.

◆ isState()

std::enable_if_t<!std::is_void_v< T >, bool > ml::StateManager< extract_State< Manifest >::type >::isState ( T state) const
inherited

Return true if currently in state.

Parameters
stateThe state value to compare against.
Returns
true if the current state equals state.

◆ onStateEnter()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< Manifest >::type >::onStateEnter ( std::function< void(T)> callback)
inherited

Register a callback invoked after each state transition.

The callback receives the newly entered state. Only one enter callback is active at a time; calling this again replaces it.

Parameters
callbackFunction called with the new state after each transition.

◆ onStateExit()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< Manifest >::type >::onStateExit ( std::function< void(T)> callback)
inherited

Register a callback invoked before each state transition.

The callback receives the state being left. Only one exit callback is active at a time; calling this again replaces it.

Parameters
callbackFunction called with the old state before each transition.

◆ setState()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< Manifest >::type >::setState ( T newState)
inherited

Transition to a new state.

Fires the exit callback with the current state, updates the stored state to newState, then fires the enter callback with the new state. Either callback may be unset (nullptr), in which case it is skipped.

Parameters
newStateThe state to transition into.

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