2021-08-06 14:22:56 +02:00
|
|
|
#ifndef BWIDGETS_MOUSE_HANDLER_HPP
|
|
|
|
#define BWIDGETS_MOUSE_HANDLER_HPP
|
2021-07-10 19:55:53 +02:00
|
|
|
|
2021-08-15 20:04:53 +02:00
|
|
|
#include <basic_widgets/w/feat/event_handler.hpp>
|
2021-07-18 18:26:12 +02:00
|
|
|
#include <basic_widgets/w/feat/focus_handler.hpp>
|
2021-07-10 19:55:53 +02:00
|
|
|
|
|
|
|
struct SDL_MouseButtonEvent;
|
|
|
|
struct SDL_MouseMotionEvent;
|
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
namespace bwidgets
|
2021-07-10 19:55:53 +02:00
|
|
|
{
|
2021-08-19 15:00:44 +02:00
|
|
|
class MouseHandler : public virtual FocusHandler,
|
|
|
|
public virtual EventHandler
|
2021-07-10 19:55:53 +02:00
|
|
|
{
|
2021-07-29 16:06:03 +02:00
|
|
|
protected:
|
2021-08-15 20:04:53 +02:00
|
|
|
using EventHandler::EventHandler;
|
2021-07-29 16:06:03 +02:00
|
|
|
|
|
|
|
public:
|
2021-08-23 23:50:14 +02:00
|
|
|
// Set click handler.
|
2021-08-15 20:04:53 +02:00
|
|
|
virtual void click_handler(std::function<void(const SDL_MouseButtonEvent&)>) = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Disable mouse event handling.
|
2021-08-15 20:04:53 +02:00
|
|
|
virtual void disable_mouse_handler() = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Enable mouse event handling.
|
2021-08-21 20:59:39 +02:00
|
|
|
virtual void enable_mouse_handler(const SDL_Rect&, const SDL_Rect&) = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Called on hover state changes.
|
2021-08-21 20:59:39 +02:00
|
|
|
virtual void hover_handler(std::function<void(bool)>) = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Get current hover state.
|
2021-08-15 20:04:53 +02:00
|
|
|
[[nodiscard]] virtual bool hovered() const = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Set mouse motion handler.
|
2021-08-15 20:04:53 +02:00
|
|
|
virtual void
|
2022-01-24 16:18:14 +01:00
|
|
|
mouse_motion_handler(std::function<void(const SDL_MouseMotionEvent&)>) = 0;
|
2022-01-26 18:38:47 +01:00
|
|
|
virtual void
|
|
|
|
mouse_wheel_handler(std::function<void(const SDL_MouseWheelEvent&)>) = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Get current push state (mouse button down)
|
2022-01-26 18:38:47 +01:00
|
|
|
[[nodiscard]] virtual bool pushed() const = 0;
|
2021-07-10 19:55:53 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|