Loading...
Searching...
No Matches
ml::ComponentBase< ComponentManifest, Traits > Struct Template Referenceabstract

Intermediate drawable layer — with manifest. More...

#include <Component.h>

Inheritance diagram for ml::ComponentBase< ComponentManifest, Traits >:

Public Types

using Flag = DraggableManifest::Flag
using manifest_type
 The manifest type, used by GatherFlags and GatherStates to locate this class's flag and state declarations.
using Resources = ml::ManifestResources<ComponentManifest>
using State = DraggableManifest::State
using State
 The enum type this manager stores flags for.

Public Member Functions

template<class T>
void center (T &obj)
 Center this object within obj (both axes).
template<class T>
void centerHorizonally (T &obj)
 Center this object horizontally within obj.
void centerText (sf::Text &obj)
 Center an sf::Text object within this object's bounds.
template<class T>
void centerVertically (T &obj)
 Center this object vertically within obj.
bool checkFlag (State state) const
 Return the current value of a flag.
void clearDragBounds ()
 Remove any previously set drag bounds.
void disableFlag (State state)
 Set a flag to false.
void enableFlag (State state)
 Set a flag to true.
virtual sf::FloatRect getGlobalBounds () const =0
 Return the axis-aligned bounding box in world space.
virtual sf::Vector2f getPosition () const =0
 Return the current world-space position.
virtual sf::RenderStates getRenderStates () const
 Returns the SFML render states to use when drawing this object.
std::enable_if_t<!std::is_void_v< T >, T > getState () const
 Return the current state value.
bool isScrolling ()
 Return true while a moveTo or moveDistance animation is in progress.
std::enable_if_t<!std::is_void_v< T >, bool > isState (T state) const
 Return true if currently in state.
void moveDistance (sf::Vector2f distance, float seconds=1.f)
 Animate by a relative offset from the current position.
void moveTo (sf::FloatRect position, float seconds=1.f)
 Animate to a position defined by a FloatRect origin.
void moveTo (sf::Vector2f position, float seconds=1.f)
 Animate to an absolute world-space position.
void onBlur (std::function< void()> callback)
 Register a no-argument callback invoked when this component loses keyboard focus.
void onBlur (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when this component loses keyboard focus, receiving the raw SFML event.
void onClick (std::function< void()> callback)
 Register a no-argument callback invoked when this component is clicked.
void onClick (std::function< void(const std::optional< sf::Event > &event)> callback)
 Register a callback invoked when this component is clicked, receiving the raw SFML event.
void onFocus (std::function< void()> callback)
 Register a no-argument callback invoked when this component gains keyboard focus.
void onFocus (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when this component gains keyboard focus, receiving the raw SFML event.
void onHover (std::function< void()> callback)
 Register a no-argument callback invoked when the mouse enters this component's bounds.
void onHover (std::function< void(const std::optional< sf::Event > &event)> callback)
 Register a callback invoked when the mouse enters this component's bounds, receiving the raw SFML event.
void onKeypress (std::function< void()> callback)
 Register a no-argument callback invoked when a key is pressed while this component has focus.
void onKeypress (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when a key is pressed while this component has focus, receiving the raw SFML event.
void onKeyRelease (std::function< void()> callback)
 Register a no-argument callback invoked when a key is released while this component has focus.
void onKeyRelease (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when a key is released while this component has focus, receiving the raw SFML event.
void onMouseMoved (std::function< void()> callback)
 Register a no-argument callback invoked whenever the mouse moves anywhere in the window.
void onMouseMoved (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked whenever the mouse moves anywhere in the window, receiving the raw SFML event.
void onMousePressed (std::function< void()> callback)
 Register a no-argument callback invoked when a mouse button is pressed anywhere in the window.
void onMousePressed (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when a mouse button is pressed, receiving the raw SFML event.
void onMouseReleased (std::function< void()> callback)
 Register a no-argument callback invoked when a mouse button is released anywhere in the window.
void onMouseReleased (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when a mouse button is released, receiving the raw SFML event.
void onScroll (std::function< void()> callback)
 Register a no-argument callback invoked when the mouse wheel is scrolled while the cursor is over this component.
void onScroll (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when the mouse wheel is scrolled while the cursor is over this component, receiving the SFML event.
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.
void onTextEntered (std::function< void()> callback)
 Register a no-argument callback invoked when a unicode character is entered while this component has focus.
void onTextEntered (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when a unicode character is entered while this component has focus, receiving the raw SFML event.
void onUnhover (std::function< void()> callback)
 Register a no-argument callback invoked when the mouse leaves this component's bounds.
void onUnhover (std::function< void(const std::optional< sf::Event > &event)> callback)
 Register a callback invoked when the mouse leaves this component's bounds, receiving the raw SFML event.
void onUpdate (std::function< void()> callback)
 Register a no-argument callback invoked every frame.
void onUpdate (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked every frame, receiving the SFML event.
void onWindowFocusGained (std::function< void()> callback)
 Register a no-argument callback invoked when the application window gains OS focus.
void onWindowFocusGained (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when the application window gains OS focus, receiving the raw SFML event.
void onWindowFocusLost (std::function< void()> callback)
 Register a no-argument callback invoked when the application window loses OS focus.
void onWindowFocusLost (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when the application window loses OS focus, receiving the raw SFML event.
void onWindowResized (std::function< void()> callback)
 Register a no-argument callback invoked when the application window is resized.
void onWindowResized (std::function< void(const std::optional< sf::Event > &)> callback)
 Register a callback invoked when the application window is resized, receiving the raw SFML event.
virtual void process (const std::string &key, const std::optional< sf::Event > &event)
 Invoke all callbacks registered for key.
template<typename ENUM_TYPE>
void process (ENUM_TYPE eventName, const std::optional< sf::Event > &event)
 Invoke all callbacks registered for eventName.
template<typename ENUM_TYPE>
void process (ENUM_TYPE eventName, const std::optional< sf::Event > &event)
 Invoke all callbacks registered for eventName.
template<typename ENUM_TYPE>
void publish (ENUM_TYPE event, FilterCallback filter=[](EventReceiver &){ return true;}, SystemCallback resolve=nullptr, SystemCallback reject=nullptr)
 Fire an enum-keyed event to all matching subscribers.
template<class T>
void setAbove (T &obj, float spacing=0)
 Position this object immediately above obj.
template<class T>
void setBelow (T &obj, float spacing=0)
 Position this object immediately below obj.
void setDragBounds (const sf::FloatRect &bounds)
 Constrain drag movement to an axis-aligned bounding rectangle.
void setFlag (State state, bool status)
 Set a flag to an explicit value.
void setFramerate (float framerate)
 Set the assumed framerate for movement interpolation.
template<class T>
void setLeftOf (T &obj, float spacing=0)
 Position this object immediately to the left of obj.
virtual void setPosition (const sf::Vector2f &position)=0
 Set the world-space position immediately (no animation).
template<class T>
void setRightOf (T &obj, float spacing=0)
 Position this object immediately to the right of obj.
std::enable_if_t<!std::is_void_v< T > > setState (T newState)
 Transition to a new state.
template<typename ENUM_TYPE>
void subscribe (ENUM_TYPE event, Callback callback)
 Subscribe to an enum-keyed event with a no-argument callback.
template<typename ENUM_TYPE>
void subscribe (ENUM_TYPE event, EventCallback callback)
 Subscribe to an enum-keyed event with a full SFML event callback.
void toggleFlag (State state)
 Flip a flag between true and false.
template<typename EnumType>
void unsubscribe (EnumType event)
 Unsubscribe from a single event by enum value.
void unsubscribeAll ()
 Remove all event subscriptions for this component.

Static Public Member Functions

static auto get (EnumType key) -> std::enable_if_t< !is_asset_enum< ComponentManifest, EnumType >::value, decltype(ConfigManager< ComponentManifest >::get(key))>
 Retrieve a config value by enum key → ConfigManager.
static auto get (EnumType key) -> std::enable_if_t< is_asset_enum< ComponentManifest, EnumType >::value, const_ref_t< decltype(AssetsManager< ComponentManifest >::get(key))> >
 Retrieve an asset by enum key → AssetsManager.
static std::enable_if_t< is_sounds_enum< ComponentManifest, EnumType >::value > unload (EnumType key)
static std::enable_if_t< is_fonts_enum< ComponentManifest, EnumType >::value > unload (EnumType key)
static std::enable_if_t< is_images_enum< ComponentManifest, EnumType >::value > unload (EnumType key)

Protected Member Functions

virtual void draw (RenderTarget &target, RenderStates states) const=0

Detailed Description

template<typename ComponentManifest, typename... Traits>
struct ml::ComponentBase< ComponentManifest, Traits >

Intermediate drawable layer — with manifest.

When a manifest is provided, injects:

  • ManifestAliases — enum types unqualified in scope via Resources
  • Resources — unified accessor: Resources::get(Images::Background), Resources::get(Text::Title) etc.
Template Parameters
ComponentManifestManifest struct forwarded to ComponentCore.
TraitsExtra traits forwarded to ComponentCore.
See also
ComponentCore, Component, ManifestResources

Definition at line 88 of file Component.h.

Member Typedef Documentation

◆ Flag

Definition at line 69 of file Draggable.h.

◆ manifest_type

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.

◆ Resources

template<typename ComponentManifest, typename... Traits>
using ml::ComponentBase< ComponentManifest, Traits >::Resources = ml::ManifestResources<ComponentManifest>

Definition at line 92 of file Component.h.

◆ State [1/2]

Definition at line 70 of file Draggable.h.

◆ State [2/2]

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

◆ center()

template<class T>
void ml::Positionable::center ( T & obj)
inherited

Center this object within obj (both axes).

Template Parameters
TAny type with getGlobalBounds().
Parameters
objContainer to center within.

◆ centerHorizonally()

template<class T>
void ml::Positionable::centerHorizonally ( T & obj)
inherited

Center this object horizontally within obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objContainer to center within.

◆ centerText()

void ml::Positionable::centerText ( sf::Text & obj)
inherited

Center an sf::Text object within this object's bounds.

Convenience overload for the common pattern of centering a text label inside a button or panel.

Parameters
objThe sf::Text to reposition.

◆ centerVertically()

template<class T>
void ml::Positionable::centerVertically ( T & obj)
inherited

Center this object vertically within obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objContainer to center within.

◆ 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.

◆ clearDragBounds()

void ml::Draggable::clearDragBounds ( )
inherited

Remove any previously set drag bounds.

After this call the component can be dragged freely across the window with no position clamping. Has no effect if no bounds were set.

◆ 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.

◆ get() [1/2]

auto ml::ManifestResources< ComponentManifest >::get ( EnumType key) -> std::enable_if_t< !is_asset_enum< ComponentManifest, EnumType >::value, decltype(ConfigManager< ComponentManifest >::get(key))>
inlinestaticinherited

Retrieve a config value by enum key → ConfigManager.

Return type is inferred from ConfigManager::get()Text gives const std::string&, Ints gives int, etc.

Definition at line 122 of file ManifestResources.h.

◆ get() [2/2]

auto ml::ManifestResources< ComponentManifest >::get ( EnumType key) -> std::enable_if_t< is_asset_enum< ComponentManifest, EnumType >::value, const_ref_t< decltype(AssetsManager< ComponentManifest >::get(key))> >
inlinestaticinherited

Retrieve an asset by enum key → AssetsManager.

Return type is explicitly const T& — taking & gives const T* with no ambiguity, suitable for SFML functions that take const sf::Texture* etc.

Definition at line 107 of file ManifestResources.h.

◆ getGlobalBounds()

virtual sf::FloatRect ml::Positionable::getGlobalBounds ( ) const
pure virtualinherited

Return the axis-aligned bounding box in world space.

Used by UIManager for hit-testing (click, hover) and by layout helpers for relative placement. Pure virtual — implemented by the concrete shape or adapter class.

Returns
Bounding rectangle in world coordinates.

Implemented in ml::CoreAdapter, ml::DrawableWrapper< ENTITY >, ml::Graphic< T >, ml::Graphic< ml::RoundedRectangle >, ml::Graphic< sf::CircleShape >, ml::Graphic< sf::ConvexShape >, ml::Graphic< sf::Sprite >, ml::Graphic< sf::Text >, ml::Grid, and ml::TextInput.

◆ getPosition()

virtual sf::Vector2f ml::Positionable::getPosition ( ) const
pure virtualinherited

Return the current world-space position.

Pure virtual — implemented by the concrete shape or adapter class.

Returns
Current position in world coordinates.

Implemented in ml::CoreAdapter, ml::DrawableWrapper< ENTITY >, ml::Graphic< T >, ml::Graphic< ml::RoundedRectangle >, ml::Graphic< sf::CircleShape >, ml::Graphic< sf::ConvexShape >, ml::Graphic< sf::Sprite >, ml::Graphic< sf::Text >, ml::Grid, and ml::TextInput.

◆ getRenderStates()

virtual sf::RenderStates ml::Core::getRenderStates ( ) const
inlinevirtualinherited

Returns the SFML render states to use when drawing this object.

The default implementation returns a default-constructed sf::RenderStates (no transform, no texture, no blend mode override). Override to apply a custom shader, blend mode, or transform.

Returns
sf::RenderStates to pass to the SFML draw call.

Definition at line 80 of file Core.h.

◆ getState()

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

Return the current state value.

Returns
The active StateEnum value.

◆ isScrolling()

bool ml::Positionable::isScrolling ( )
inherited

Return true while a moveTo or moveDistance animation is in progress.

Returns
true if the waypoint queue is non-empty.

◆ isState()

std::enable_if_t<!std::is_void_v< T >, bool > ml::StateManager< extract_State< DraggableManifest >::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.

◆ moveDistance()

void ml::Positionable::moveDistance ( sf::Vector2f distance,
float seconds = 1.f )
inherited

Animate by a relative offset from the current position.

Equivalent to moveTo(getPosition() + distance, seconds).

Parameters
distanceOffset in world coordinates to move by.
secondsDuration of the animation. Defaults to 1.0 s.

◆ moveTo() [1/2]

void ml::Positionable::moveTo ( sf::FloatRect position,
float seconds = 1.f )
inherited

Animate to a position defined by a FloatRect origin.

Convenience overload that uses the top-left of position as the target. Useful when positioning relative to layout rects.

Parameters
positionRect whose origin is the animation target.
secondsDuration of the animation. Defaults to 1.0 s.

◆ moveTo() [2/2]

void ml::Positionable::moveTo ( sf::Vector2f position,
float seconds = 1.f )
inherited

Animate to an absolute world-space position.

Populates an internal waypoint queue and advances through it on successive onUpdate ticks. The object's position at the start of the call is the implicit start point.

Parameters
positionTarget position in world coordinates.
secondsDuration of the animation. Defaults to 1.0 s.

◆ onBlur() [1/2]

void ml::Focusable::onBlur ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when this component loses keyboard focus.

Parameters
callbackFunction invoked with no arguments when focus is lost.

◆ onBlur() [2/2]

void ml::Focusable::onBlur ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when this component loses keyboard focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event when focus is lost.

◆ onClick() [1/2]

void ml::Clickable::onClick ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when this component is clicked.

Replaces any previously registered onClick callback. The callback fires after the mouse button is released over this component.

Parameters
callbackFunction invoked with no arguments on click.

◆ onClick() [2/2]

void ml::Clickable::onClick ( std::function< void(const std::optional< sf::Event > &event)> callback)
inherited

Register a callback invoked when this component is clicked, receiving the raw SFML event.

Replaces any previously registered onClick callback.

Parameters
callbackFunction invoked with the SFML event on click.

◆ onFocus() [1/2]

void ml::Focusable::onFocus ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when this component gains keyboard focus.

Parameters
callbackFunction invoked with no arguments when focus is gained.

◆ onFocus() [2/2]

void ml::Focusable::onFocus ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when this component gains keyboard focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event when focus is gained.

◆ onHover() [1/2]

void ml::Hoverable::onHover ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the mouse enters this component's bounds.

Parameters
callbackFunction invoked with no arguments on hover enter.

◆ onHover() [2/2]

void ml::Hoverable::onHover ( std::function< void(const std::optional< sf::Event > &event)> callback)
inherited

Register a callback invoked when the mouse enters this component's bounds, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on hover enter.

◆ onKeypress() [1/2]

void ml::Keyable::onKeypress ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when a key is pressed while this component has focus.

Parameters
callbackFunction invoked with no arguments on key press.

◆ onKeypress() [2/2]

void ml::Keyable::onKeypress ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when a key is pressed while this component has focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on key press.

◆ onKeyRelease() [1/2]

void ml::Keyable::onKeyRelease ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when a key is released while this component has focus.

Parameters
callbackFunction invoked with no arguments on key release.

◆ onKeyRelease() [2/2]

void ml::Keyable::onKeyRelease ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when a key is released while this component has focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on key release.

◆ onMouseMoved() [1/2]

void ml::Scrollable::onMouseMoved ( std::function< void()> callback)
inherited

Register a no-argument callback invoked whenever the mouse moves anywhere in the window.

Unlike onHover, this fires for every component regardless of whether the cursor is over it.

Parameters
callbackFunction invoked with no arguments on mouse move.

◆ onMouseMoved() [2/2]

void ml::Scrollable::onMouseMoved ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked whenever the mouse moves anywhere in the window, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on mouse move.

◆ onMousePressed() [1/2]

void ml::Scrollable::onMousePressed ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when a mouse button is pressed anywhere in the window.

This fires before click logic is evaluated. Prefer onClick for standard click handling.

Parameters
callbackFunction invoked with no arguments on mouse press.

◆ onMousePressed() [2/2]

void ml::Scrollable::onMousePressed ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when a mouse button is pressed, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on mouse press.

◆ onMouseReleased() [1/2]

void ml::Scrollable::onMouseReleased ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when a mouse button is released anywhere in the window.

This fires before click logic is evaluated. Prefer onClick for standard click handling.

Parameters
callbackFunction invoked with no arguments on mouse release.

◆ onMouseReleased() [2/2]

void ml::Scrollable::onMouseReleased ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when a mouse button is released, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on mouse release.

◆ onScroll() [1/2]

void ml::Scrollable::onScroll ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the mouse wheel is scrolled while the cursor is over this component.

Parameters
callbackFunction invoked with no arguments on scroll.

◆ onScroll() [2/2]

void ml::Scrollable::onScroll ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when the mouse wheel is scrolled while the cursor is over this component, receiving the SFML event.

Parameters
callbackFunction invoked with the SFML event on scroll.

◆ onStateEnter()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< DraggableManifest >::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< DraggableManifest >::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.

◆ onTextEntered() [1/2]

void ml::Keyable::onTextEntered ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when a unicode character is entered while this component has focus.

Prefer onTextEntered over onKeypress for text input — it handles modifier keys, input method editors (IME), and non-ASCII characters correctly.

Parameters
callbackFunction invoked with no arguments when text is entered.

◆ onTextEntered() [2/2]

void ml::Keyable::onTextEntered ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when a unicode character is entered while this component has focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event when text is entered.

◆ onUnhover() [1/2]

void ml::Hoverable::onUnhover ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the mouse leaves this component's bounds.

Parameters
callbackFunction invoked with no arguments on hover leave.

◆ onUnhover() [2/2]

void ml::Hoverable::onUnhover ( std::function< void(const std::optional< sf::Event > &event)> callback)
inherited

Register a callback invoked when the mouse leaves this component's bounds, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on hover leave.

◆ onUpdate() [1/2]

void ml::Updatable::onUpdate ( std::function< void()> callback)
inherited

Register a no-argument callback invoked every frame.

The callback fires once per frame before the draw pass. All active components receive this regardless of hover or focus state.

Parameters
callbackFunction invoked with no arguments each frame.

◆ onUpdate() [2/2]

void ml::Updatable::onUpdate ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked every frame, receiving the SFML event.

For frame events the std::optional<sf::Event> is always std::nullopt — use the no-argument overload unless you specifically need the optional parameter in your callback signature.

Parameters
callbackFunction invoked with the SFML event (always nullopt) each frame.

◆ onWindowFocusGained() [1/2]

void ml::Updatable::onWindowFocusGained ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the application window gains OS focus.

Parameters
callbackFunction invoked with no arguments when focus is gained.

◆ onWindowFocusGained() [2/2]

void ml::Updatable::onWindowFocusGained ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when the application window gains OS focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event when focus is gained.

◆ onWindowFocusLost() [1/2]

void ml::Updatable::onWindowFocusLost ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the application window loses OS focus.

Parameters
callbackFunction invoked with no arguments when focus is lost.

◆ onWindowFocusLost() [2/2]

void ml::Updatable::onWindowFocusLost ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when the application window loses OS focus, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event when focus is lost.

◆ onWindowResized() [1/2]

void ml::Updatable::onWindowResized ( std::function< void()> callback)
inherited

Register a no-argument callback invoked when the application window is resized.

Parameters
callbackFunction invoked with no arguments on window resize.

◆ onWindowResized() [2/2]

void ml::Updatable::onWindowResized ( std::function< void(const std::optional< sf::Event > &)> callback)
inherited

Register a callback invoked when the application window is resized, receiving the raw SFML event.

Parameters
callbackFunction invoked with the SFML event on window resize.

◆ process() [1/3]

virtual void ml::EventReceiver::process ( const std::string & key,
const std::optional< sf::Event > & event )
virtualinherited

Invoke all callbacks registered for key.

Called by framework dispatchers. key is the string produced by EnumKey::get(eventEnum).

Parameters
keyString key identifying the event.
eventSFML event forwarded to each callback.

◆ process() [2/3]

template<typename ENUM_TYPE>
void ml::EventReceiver::process ( ENUM_TYPE eventName,
const std::optional< sf::Event > & event )
inherited

Invoke all callbacks registered for eventName.

Template overload that accepts any enum value directly, converting to a string key via EnumKey::get() internally.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventNameThe enum value identifying the event.
eventSFML event forwarded to each callback.

◆ process() [3/3]

template<typename ENUM_TYPE>
void ml::EventReceiver::process ( ENUM_TYPE eventName,
const std::optional< sf::Event > & event )
inherited

Invoke all callbacks registered for eventName.

Template overload that accepts any enum value directly, converting to a string key via EnumKey::get() internally.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventNameThe enum value identifying the event.
eventSFML event forwarded to each callback.

◆ publish()

template<typename ENUM_TYPE>
void ml::Subscribable::publish ( ENUM_TYPE event,
FilterCallback filter = [](EventReceiver &){ return true;},
SystemCallback resolve = nullptr,
SystemCallback reject = nullptr )
inherited

Fire an enum-keyed event to all matching subscribers.

Iterates all subscribers registered for event and invokes their callbacks for each subscriber that passes the optional filter. Optional resolve and reject system callbacks are called after each component passes or fails the filter respectively.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventThe enum value identifying the event to fire.
filterOptional predicate; only subscribers for which this returns true receive the event. Defaults to accepting all subscribers.
resolveOptional callback invoked for each subscriber that passes the filter.
rejectOptional callback invoked for each subscriber that fails the filter.

◆ setAbove()

template<class T>
void ml::Positionable::setAbove ( T & obj,
float spacing = 0 )
inherited

Position this object immediately above obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objReference object.
spacingGap in pixels between the two objects. Defaults to 0.

◆ setBelow()

template<class T>
void ml::Positionable::setBelow ( T & obj,
float spacing = 0 )
inherited

Position this object immediately below obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objReference object.
spacingGap in pixels between the two objects. Defaults to 0.

◆ setDragBounds()

void ml::Draggable::setDragBounds ( const sf::FloatRect & bounds)
inherited

Constrain drag movement to an axis-aligned bounding rectangle.

While bounds are set, the component's position is clamped so that its top-left corner never moves outside bounds during a drag gesture. Bounds are applied in world coordinates.

Call clearDragBounds() to remove the constraint and allow free movement again.

Parameters
boundsThe world-space rectangle within which the component may be dragged.

◆ 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.

◆ setFramerate()

void ml::Positionable::setFramerate ( float framerate)
inherited

Set the assumed framerate for movement interpolation.

moveTo generates a queue of intermediate positions based on this value. Defaults to 60 fps. Call this if your application runs at a different target rate to keep animation timing accurate.

Parameters
framerateTarget framerate in frames per second.

◆ setLeftOf()

template<class T>
void ml::Positionable::setLeftOf ( T & obj,
float spacing = 0 )
inherited

Position this object immediately to the left of obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objReference object.
spacingGap in pixels between the two objects. Defaults to 0.

◆ setPosition()

virtual void ml::Positionable::setPosition ( const sf::Vector2f & position)
pure virtualinherited

Set the world-space position immediately (no animation).

Pure virtual — implemented by the concrete shape or adapter class.

Parameters
positionNew position in world coordinates.

Implemented in ml::Button< Circle, float >, ml::Button< Convex, std::size_t >, ml::Button< Rectangle, sf::Vector2f >, ml::CoreAdapter, ml::DrawableWrapper< ENTITY >, ml::Graphic< T >, ml::Graphic< ml::RoundedRectangle >, ml::Graphic< sf::CircleShape >, ml::Graphic< sf::ConvexShape >, ml::Graphic< sf::Sprite >, ml::Graphic< sf::Text >, ml::Grid, and ml::TextInput.

◆ setRightOf()

template<class T>
void ml::Positionable::setRightOf ( T & obj,
float spacing = 0 )
inherited

Position this object immediately to the right of obj.

Template Parameters
TAny type with getGlobalBounds().
Parameters
objReference object.
spacingGap in pixels between the two objects. Defaults to 0.

◆ setState()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< DraggableManifest >::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.

◆ subscribe() [1/2]

template<typename ENUM_TYPE>
void ml::Subscribable::subscribe ( ENUM_TYPE event,
Callback callback )
inherited

Subscribe to an enum-keyed event with a no-argument callback.

Convenience overload for callbacks that do not need access to the raw SFML event.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventThe enum value identifying the event to subscribe to.
callbackFunction invoked with no arguments when the event fires.

◆ subscribe() [2/2]

template<typename ENUM_TYPE>
void ml::Subscribable::subscribe ( ENUM_TYPE event,
EventCallback callback )
inherited

Subscribe to an enum-keyed event with a full SFML event callback.

The callback is invoked each time the event fires and the framework's filter (defined by the associated EventDispatcher) passes this component. The std::optional<sf::Event> parameter carries the raw SFML event when one is available, or std::nullopt for frame events.

Template Parameters
ENUM_TYPEAny enum type — ml::Event for built-in events, or a manifest event enum for custom events.
Parameters
eventThe enum value identifying the event to subscribe to.
callbackFunction invoked with the SFML event when the event fires.

◆ toggleFlag()

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

Flip a flag between true and false.

Parameters
stateThe flag to toggle.

◆ unload() [1/3]

std::enable_if_t< is_sounds_enum< ComponentManifest, EnumType >::value > ml::ManifestResources< ComponentManifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 148 of file ManifestResources.h.

◆ unload() [2/3]

std::enable_if_t< is_fonts_enum< ComponentManifest, EnumType >::value > ml::ManifestResources< ComponentManifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 141 of file ManifestResources.h.

◆ unload() [3/3]

std::enable_if_t< is_images_enum< ComponentManifest, EnumType >::value > ml::ManifestResources< ComponentManifest >::unload ( EnumType key)
inlinestaticinherited

Definition at line 134 of file ManifestResources.h.

◆ unsubscribe()

template<typename EnumType>
void ml::Unsubscribable::unsubscribe ( EnumType event)
inlineinherited

Unsubscribe from a single event by enum value.

Works with any enum type — ml::Event for built-in events, or a manifest Event enum for custom events.

If called during a _EventsManager::fire() iteration the removal is deferred until the iteration completes.

Template Parameters
EnumTypeAny enum type. Enforced at compile time.
Parameters
eventThe enum value identifying the event to remove.

Definition at line 61 of file Unsubscribable.h.

◆ unsubscribeAll()

void ml::Unsubscribable::unsubscribeAll ( )
inherited

Remove all event subscriptions for this component.

Removes every subscription registered across all event names. Called automatically by Core's destructor.

If called during a _EventsManager::fire() iteration the removal is deferred until the iteration completes.


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