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
73 void onSelected(std::function<void()> callback, bool overwrite = true);
74
83 void onSelected(std::function<void(const std::optional<sf::Event>&)> callback, bool overwrite = true);
84
85 // ── onDeselected ──────────────────────────────────────────────────────
86
94 void onDeselected(std::function<void()> callback, bool overwrite = true);
95
104 void onDeselected(std::function<void(const std::optional<sf::Event>&)> callback, bool overwrite = true);
105
106 // ── Programmatic triggers ─────────────────────────────────────────────
107
116 void select();
117
124 void deselect();
125 };
126
127} // namespace ml
128
129#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 onSelected(std::function< void(const std::optional< sf::Event > &)> callback, bool overwrite=true)
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, bool overwrite=true)
Register a callback invoked when this component is deselected, receiving the raw SFML event (always s...
void onDeselected(std::function< void()> callback, bool overwrite=true)
Register a no-argument callback invoked when this component is deselected.
void select()
Fire the onSelected callbacks on this component.
void onSelected(std::function< void()> callback, bool overwrite=true)
Register a no-argument callback invoked when this component is selected.
#define MALENA_API
Definition Component.h:22