bwidgets/inc/basic_widgets/abstract/mouse_handler.hpp

37 lines
1.1 KiB
C++
Raw Normal View History

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
{
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
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