Loading...
Searching...
No Matches
Selectable.h
Go to the documentation of this file.
1//
2// Selectable.h
3//
4
5#ifndef MALENA_SELECTABLE_H
6#define MALENA_SELECTABLE_H
7
8#pragma once
9
15#include <functional>
16#include <optional>
17#include <SFML/Window/Event.hpp>
18
19namespace ml
20{
62 {
63 public:
64 // ── onSelected ────────────────────────────────────────────────────────
65
72 void onSelected(std::function<void()> callback);
73
81 void onSelected(std::function<void(const std::optional<sf::Event>&)> callback);
82
83 // ── onDeselected ──────────────────────────────────────────────────────
84
91 void onDeselected(std::function<void()> callback);
92
100 void onDeselected(std::function<void(const std::optional<sf::Event>&)> callback);
101
102 // ── Programmatic triggers ─────────────────────────────────────────────
103
112 void select();
113
120 void deselect();
121 };
122
123} // namespace ml
124
125#endif // MALENA_SELECTABLE_H
Base class for all event-receiving traits.
Trait that adds selection and deselection callbacks to any Core object.
Definition Selectable.h:62
void deselect()
Fire the onDeselected callbacks on this component.
void onDeselected(std::function< void()> callback)
Register a no-argument callback invoked when this component is deselected.
void onSelected(std::function< void()> callback)
Register a no-argument callback invoked when this component is selected.
void select()
Fire the onSelected callbacks on this component.
void onSelected(std::function< void(const std::optional< sf::Event > &)> callback)
Register a callback invoked when this component is selected, receiving the raw SFML event (always std...
void onDeselected(std::function< void(const std::optional< sf::Event > &)> callback)
Register a callback invoked when this component is deselected, receiving the raw SFML event (always s...
#define MALENA_API
Definition Component.h:22