2021-07-10 19:55:53 +02:00
|
|
|
#ifndef MOUSE_HANDLER_HPP
|
|
|
|
#define MOUSE_HANDLER_HPP
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include <basic_widgets/abstract/focus_handler.hpp>
|
|
|
|
|
|
|
|
struct SDL_MouseButtonEvent;
|
|
|
|
struct SDL_MouseMotionEvent;
|
|
|
|
struct SDL_Rect;
|
|
|
|
|
|
|
|
namespace bwidgets::abstract
|
|
|
|
{
|
2021-07-11 22:03:30 +02:00
|
|
|
class MouseHandler : public virtual FocusHandler
|
2021-07-10 19:55:53 +02:00
|
|
|
{
|
|
|
|
protected:
|
2021-07-11 17:06:18 +02:00
|
|
|
const SDL_Rect* _click_area = nullptr;
|
|
|
|
bool _is_hovered = false;
|
|
|
|
bool _is_pushed = false;
|
2021-07-10 19:55:53 +02:00
|
|
|
|
|
|
|
virtual void _handle_mouse_button(const SDL_MouseButtonEvent&,
|
|
|
|
const SDL_Rect&);
|
|
|
|
virtual void _handle_mouse_motion(const SDL_MouseMotionEvent&,
|
|
|
|
const SDL_Rect&);
|
|
|
|
|
|
|
|
public:
|
2021-07-11 17:06:18 +02:00
|
|
|
std::function<void (const SDL_MouseButtonEvent&)> click_handler = nullptr;
|
2021-07-10 19:55:53 +02:00
|
|
|
|
2021-07-13 13:22:11 +02:00
|
|
|
void handle_mouse(const SDL_MouseButtonEvent&,
|
|
|
|
const SDL_Rect&);
|
|
|
|
void handle_mouse(const SDL_MouseMotionEvent&,
|
|
|
|
const SDL_Rect&);
|
2021-07-10 19:55:53 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|