/** * @file Button.h * @author apio (cloudapio.eu) * @brief A clickable component that triggers an action when pressed. * * @copyright Copyright (c) 2023, the Luna authors. * */ #pragma once #include #include namespace ui { class Button : public Widget { public: Button(Rect rect); void set_widget(Widget& widget); void set_action(os::Action&& action); Result handle_mouse_move(Point position) override; Result handle_mouse_leave() override; Result handle_mouse_down(Point position, int buttons) override; Result handle_mouse_up(Point position, int buttons) override; Result handle_key_event(const ui::KeyEventRequest& request) override; Result draw(Canvas& canvas) override; private: bool m_hovered { false }; bool m_clicked { false }; Widget* m_child; os::Action m_action; }; }