diff --git a/inc/basic_widgets/impl/mouse_handler_impl.hpp b/inc/basic_widgets/impl/mouse_handler_impl.hpp new file mode 100644 index 0000000..f746b9e --- /dev/null +++ b/inc/basic_widgets/impl/mouse_handler_impl.hpp @@ -0,0 +1,45 @@ +#ifndef BWIDGETS_MOUSE_HANDLER_IMPL_HPP +#define BWIDGETS_MOUSE_HANDLER_IMPL_HPP + +#include + +namespace bwidgets +{ + class MouseHandlerImpl : public MouseHandler + { + private: + const SDL_Rect* _area {nullptr}; + bool _hovered {false}; + bool _pushed {false}; + + std::function _click_handler; + std::function _motion_handler; + + protected: + MouseHandlerImpl() = default; + + public: + void + click_handler(std::function handler) override + { + _click_handler = std::move(handler); + } + void disable_mouse_handler() override; + void enable_mouse_handler(const SDL_Rect*) override; + [[nodiscard]] bool hovered() const override + { + return _hovered; + } + void mouse_motion_handler( + std::function handler) override + { + _motion_handler = std::move(handler); + } + [[nodiscard]] bool pushed() const override + { + return _pushed; + } + }; +} + +#endif