bwidgets/inc/basic_widgets/w/feat/mouse_handler.hpp

38 lines
1.3 KiB
C++
Raw Permalink Normal View History

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>
#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
{
class MouseHandler : public virtual FocusHandler,
public virtual EventHandler
2021-07-10 19:55:53 +02:00
{
protected:
2021-08-15 20:04:53 +02:00
using EventHandler::EventHandler;
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.
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.
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
mouse_motion_handler(std::function<void(const SDL_MouseMotionEvent&)>) = 0;
2021-08-23 23:50:14 +02:00
// Get current push state (mouse button down)
2021-08-15 20:04:53 +02:00
[[nodiscard]] virtual bool pushed() const = 0;
2021-07-10 19:55:53 +02:00
};
}
#endif