Loading...
Searching...
No Matches
Hoverable.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// Created by Dave Smith on 3/20/26.
6//
7
8#ifndef MALENA_HOVERABLE_H
9#define MALENA_HOVERABLE_H
10
15#include <optional>
16namespace ml
17{
47 {
48 public:
55 void onHover(std::function<void()> callback);
56
63 void onHover(std::function<void(const std::optional<sf::Event>& event)> callback);
64
71 void onUnhover(std::function<void()> callback);
72
79 void onUnhover(std::function<void(const std::optional<sf::Event>& event)> callback);
80 };
81
83 class MALENA_API HoverableDispatcher : public EventDispatcher
84 {
85 public:
86 bool occurred(const std::optional<sf::Event>& event) override;
87 bool filter(const std::optional<sf::Event>& event, Core* component) override;
88 void fire(const std::optional<sf::Event>& event) override;
89 };
91
92} // namespace ml
93
94ML_EXPORT(HoverableDispatcher)
95#endif // MALENA_HOVERABLE_H
#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-hover and mouse-leave callbacks to any Core object.
Definition Hoverable.h:47
void onHover(std::function< void()> callback)
Register a no-argument callback invoked when the mouse enters 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 eve...
void onUnhover(std::function< void()> callback)
Register a no-argument callback invoked when the mouse leaves 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 eve...
#define MALENA_API
Definition Component.h:22