Concrete adapter that gives Core a default virtual interface.
More...
#include <CoreAdapter.h>
Public Types | |
| 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 | disableFlag (State state) |
Set a flag to false. | |
| void | enableFlag (State state) |
Set a flag to true. | |
| virtual void | eventHandler (const std::optional< sf::Event > &event) |
| Handle an incoming SFML event. | |
| virtual sf::FloatRect | getGlobalBounds () const override |
| Return the axis-aligned bounding box of this object in world space. | |
| virtual sf::Vector2f | getPosition () const override |
| Return the current world-space position of this object. | |
| virtual sf::RenderStates | getRenderStates () const |
| Returns the SFML render states to use when drawing this object. | |
| bool | isScrolling () |
Return true while a moveTo or moveDistance animation is in progress. | |
| 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. | |
| 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 | 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 | 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) override |
| Set the world-space position of this object. | |
| template<class T> | |
| void | setRightOf (T &obj, float spacing=0) |
Position this object immediately to the right of obj. | |
| 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. | |
| virtual void | update () |
| Perform per-frame logic update. | |
Protected Member Functions | |
| virtual void | draw (sf::RenderTarget &target, sf::RenderStates states) const |
| Draw this object to an SFML render target. | |
Concrete adapter that gives Core a default virtual interface.
CoreAdapter extends Core with virtual implementations of the methods that SFML and the framework expect from a drawable, updatable object — without committing to a specific shape or rendering strategy.
Use CoreAdapter as a base when you need a framework object that:
Component<Manifest>)CoreManager collection without a manifestAll methods have empty default implementations, so subclasses override only what they need.
ml::Component or ml::ComponentWith, which layer manifest support, flag gathering, and SFML drawable registration automatically. CoreAdapter is primarily useful for framework-internal types and advanced custom objects.Definition at line 34 of file CoreAdapter.h.
|
inherited |
The enum type this manager stores flags for.
Definition at line 62 of file FlagManager.h.
|
inherited |
Center this object within obj (both axes).
| T | Any type with getGlobalBounds(). |
| obj | Container to center within. |
|
inherited |
Center this object horizontally within obj.
| T | Any type with getGlobalBounds(). |
| obj | Container to center within. |
|
inherited |
|
inherited |
Center this object vertically within obj.
| T | Any type with getGlobalBounds(). |
| obj | Container to center within. |
|
inherited |
Return the current value of a flag.
Returns false for any flag that has never been explicitly set.
| state | The flag to query. |
true if the flag is enabled; false otherwise.
|
inherited |
Set a flag to false.
| state | The flag to disable. |
|
protectedvirtual |
Draw this object to an SFML render target.
Default implementation does nothing. Override to render custom geometry or delegate to an internal SFML drawable.
| target | The SFML render target (window or texture). |
| states | The current render states (transform, shader, etc.). |
|
inherited |
Set a flag to true.
| state | The flag to enable. |
|
virtual |
Handle an incoming SFML event.
Called by the manager for each polled SFML event. Default implementation does nothing.
| event | The SFML event, wrapped in std::optional. |
|
overridevirtual |
Return the axis-aligned bounding box of this object in world space.
Used by the framework for hit-testing (click, hover). Default implementation returns an empty rect at the origin. Override to return meaningful bounds.
Implements ml::Positionable.
|
overridevirtual |
Return the current world-space position of this object.
Implements ml::Positionable.
|
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.
|
inherited |
Return true while a moveTo or moveDistance animation is in progress.
true if the waypoint queue is non-empty.
|
inherited |
Animate by a relative offset from the current position.
Equivalent to moveTo(getPosition() + distance, seconds).
| distance | Offset in world coordinates to move by. |
| seconds | Duration of the animation. Defaults to 1.0 s. |
|
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.
| position | Rect whose origin is the animation target. |
| seconds | Duration of the animation. Defaults to 1.0 s. |
|
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.
| position | Target position in world coordinates. |
| seconds | Duration of the animation. Defaults to 1.0 s. |
|
inherited |
Register a no-argument callback invoked when this component loses keyboard focus.
| callback | Function invoked with no arguments when focus is lost. |
|
inherited |
Register a callback invoked when this component loses keyboard focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event when focus is lost. |
|
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.
| callback | Function invoked with no arguments on click. |
|
inherited |
Register a callback invoked when this component is clicked, receiving the raw SFML event.
Replaces any previously registered onClick callback.
| callback | Function invoked with the SFML event on click. |
|
inherited |
Register a no-argument callback invoked when this component gains keyboard focus.
| callback | Function invoked with no arguments when focus is gained. |
|
inherited |
Register a callback invoked when this component gains keyboard focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event when focus is gained. |
|
inherited |
Register a no-argument callback invoked when the mouse enters this component's bounds.
| callback | Function invoked with no arguments on hover enter. |
|
inherited |
Register a callback invoked when the mouse enters this component's bounds, receiving the raw SFML event.
| callback | Function invoked with the SFML event on hover enter. |
|
inherited |
Register a no-argument callback invoked when a key is pressed while this component has focus.
| callback | Function invoked with no arguments on key press. |
|
inherited |
Register a callback invoked when a key is pressed while this component has focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event on key press. |
|
inherited |
Register a no-argument callback invoked when a key is released while this component has focus.
| callback | Function invoked with no arguments on key release. |
|
inherited |
Register a callback invoked when a key is released while this component has focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event on key release. |
|
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.
| callback | Function invoked with no arguments on mouse move. |
|
inherited |
Register a callback invoked whenever the mouse moves anywhere in the window, receiving the raw SFML event.
| callback | Function invoked with the SFML event on mouse move. |
|
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.
| callback | Function invoked with no arguments on mouse press. |
|
inherited |
Register a callback invoked when a mouse button is pressed, receiving the raw SFML event.
| callback | Function invoked with the SFML event on mouse press. |
|
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.
| callback | Function invoked with no arguments on mouse release. |
|
inherited |
Register a callback invoked when a mouse button is released, receiving the raw SFML event.
| callback | Function invoked with the SFML event on mouse release. |
|
inherited |
Register a no-argument callback invoked when the mouse wheel is scrolled while the cursor is over this component.
| callback | Function invoked with no arguments on scroll. |
|
inherited |
Register a callback invoked when the mouse wheel is scrolled while the cursor is over this component, receiving the SFML event.
| callback | Function invoked with the SFML event on scroll. |
|
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.
| callback | Function invoked with no arguments when text is entered. |
|
inherited |
Register a callback invoked when a unicode character is entered while this component has focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event when text is entered. |
|
inherited |
Register a no-argument callback invoked when the mouse leaves this component's bounds.
| callback | Function invoked with no arguments on hover leave. |
|
inherited |
Register a callback invoked when the mouse leaves this component's bounds, receiving the raw SFML event.
| callback | Function invoked with the SFML event on hover leave. |
|
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.
| callback | Function invoked with no arguments each frame. |
|
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.
| callback | Function invoked with the SFML event (always nullopt) each frame. |
|
inherited |
Register a no-argument callback invoked when the application window gains OS focus.
| callback | Function invoked with no arguments when focus is gained. |
|
inherited |
Register a callback invoked when the application window gains OS focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event when focus is gained. |
|
inherited |
Register a no-argument callback invoked when the application window loses OS focus.
| callback | Function invoked with no arguments when focus is lost. |
|
inherited |
Register a callback invoked when the application window loses OS focus, receiving the raw SFML event.
| callback | Function invoked with the SFML event when focus is lost. |
|
inherited |
Register a no-argument callback invoked when the application window is resized.
| callback | Function invoked with no arguments on window resize. |
|
inherited |
Register a callback invoked when the application window is resized, receiving the raw SFML event.
| callback | Function invoked with the SFML event on window resize. |
|
virtualinherited |
Invoke all callbacks registered for key.
Called by framework dispatchers. key is the string produced by EnumKey::get(eventEnum).
| key | String key identifying the event. |
| event | SFML event forwarded to each callback. |
|
inherited |
Invoke all callbacks registered for eventName.
Template overload that accepts any enum value directly, converting to a string key via EnumKey::get() internally.
| ENUM_TYPE | Any enum type. |
| eventName | The enum value identifying the event. |
| event | SFML event forwarded to each callback. |
|
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.
| ENUM_TYPE | Any enum type. |
| event | The enum value identifying the event to fire. |
| filter | Optional predicate; only subscribers for which this returns true receive the event. Defaults to accepting all subscribers. |
| resolve | Optional callback invoked for each subscriber that passes the filter. |
| reject | Optional callback invoked for each subscriber that fails the filter. |
|
inherited |
Position this object immediately above obj.
| T | Any type with getGlobalBounds(). |
| obj | Reference object. |
| spacing | Gap in pixels between the two objects. Defaults to 0. |
|
inherited |
Position this object immediately below obj.
| T | Any type with getGlobalBounds(). |
| obj | Reference object. |
| spacing | Gap in pixels between the two objects. Defaults to 0. |
|
inherited |
Set a flag to an explicit value.
| state | The flag to modify. |
| status | true to enable, false to disable. |
|
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.
| framerate | Target framerate in frames per second. |
|
inherited |
Position this object immediately to the left of obj.
| T | Any type with getGlobalBounds(). |
| obj | Reference object. |
| spacing | Gap in pixels between the two objects. Defaults to 0. |
|
overridevirtual |
Set the world-space position of this object.
| position | New position in world coordinates. |
Implements ml::Positionable.
|
inherited |
Position this object immediately to the right of obj.
| T | Any type with getGlobalBounds(). |
| obj | Reference object. |
| spacing | Gap in pixels between the two objects. Defaults to 0. |
|
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.
| ENUM_TYPE | Any enum type. |
| event | The enum value identifying the event to subscribe to. |
| callback | Function invoked with no arguments when the event fires. |
|
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.
| ENUM_TYPE | Any enum type — ml::Event for built-in events, or a manifest event enum for custom events. |
| event | The enum value identifying the event to subscribe to. |
| callback | Function invoked with the SFML event when the event fires. |
|
inherited |
Flip a flag between true and false.
| state | The flag to toggle. |
|
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.
| EnumType | Any enum type. Enforced at compile time. |
| event | The enum value identifying the event to remove. |
Definition at line 61 of file Unsubscribable.h.
|
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.
|
virtual |
Perform per-frame logic update.
Called by the manager each frame. Default implementation does nothing.