Loading...
Searching...
No Matches
Scrollable.h
Go to the documentation of this file.
1//
2// Scrollable.h
3//
4
5#pragma once
9
10namespace ml
11{
51 {
52 public:
53 // ── Mouse wheel ───────────────────────────────────────────────────────
54
61 void onScroll(std::function<void()> callback);
62
69 void onScroll(std::function<void(const std::optional<sf::Event>&)> callback);
70
71 // ── Mouse moved (fires for all components regardless of hover) ─────────
72
82 void onMouseMoved(std::function<void()> callback);
83
90 void onMouseMoved(std::function<void(const std::optional<sf::Event>&)> callback);
91
92 // ── Mouse button pressed (raw — before click logic) ───────────────────
93
103 void onMousePressed(std::function<void()> callback);
104
111 void onMousePressed(std::function<void(const std::optional<sf::Event>&)> callback);
112
113 // ── Mouse button released (raw — before click logic) ──────────────────
114
124 void onMouseReleased(std::function<void()> callback);
125
132 void onMouseReleased(std::function<void(const std::optional<sf::Event>&)> callback);
133 };
134
136
142 class ScrollableDispatcher : public EventDispatcher
143 {
144 public:
145 bool occurred(const std::optional<sf::Event>& event) override;
146 bool filter(const std::optional<sf::Event>& event, Core* component) override;
147 void fire(const std::optional<sf::Event>& event) override;
148 };
150
151} // namespace ml
152
153ML_EXPORT(ScrollableDispatcher)
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:38
Virtual base class for all Malena framework objects.
Definition Core.h:67
Base class for all per-event dispatchers in the Malena event system.
Base class for all event-receiving traits.
Trait that adds mouse-wheel and raw mouse-button callbacks to any Core object.
Definition Scrollable.h:51
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 e...
void onMouseMoved(std::function< void()> callback)
Register a no-argument callback invoked whenever the mouse moves 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 onMousePressed(std::function< void()> callback)
Register a no-argument callback invoked when a mouse button is pressed anywhere in the window.
void onScroll(std::function< void()> callback)
Register a no-argument callback invoked when the mouse wheel is scrolled while the cursor is over thi...
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,...
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.
Definition Component.h:18