Loading...
Searching...
No Matches
Scrollable.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// Scrollable.h
6//
7
8#pragma once
13
14namespace ml
15{
55 {
56 public:
57 // ── Mouse wheel ───────────────────────────────────────────────────────
58
65 void onScroll(std::function<void()> callback);
66
73 void onScroll(std::function<void(const std::optional<sf::Event>&)> callback);
74
75 // ── Mouse moved (fires for all components regardless of hover) ─────────
76
86 void onMouseMoved(std::function<void()> callback);
87
94 void onMouseMoved(std::function<void(const std::optional<sf::Event>&)> callback);
95
96 // ── Mouse button pressed (raw — before click logic) ───────────────────
97
107 void onMousePressed(std::function<void()> callback);
108
115 void onMousePressed(std::function<void(const std::optional<sf::Event>&)> callback);
116
117 // ── Mouse button released (raw — before click logic) ──────────────────
118
128 void onMouseReleased(std::function<void()> callback);
129
136 void onMouseReleased(std::function<void(const std::optional<sf::Event>&)> callback);
137 };
138
140
146 class MALENA_API ScrollableDispatcher : public EventDispatcher
147 {
148 public:
149 bool occurred(const std::optional<sf::Event>& event) override;
150 bool filter(const std::optional<sf::Event>& event, Core* component) override;
151 void fire(const std::optional<sf::Event>& event) override;
152 };
154
155} // namespace ml
156
157ML_EXPORT(ScrollableDispatcher)
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:43
Virtual base class for all Malena framework objects.
Definition Core.h:69
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:55
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.
#define MALENA_API
Definition Component.h:22