/** * @file Window.h * @author apio (cloudapio.eu) * @brief UI windows. * * @copyright Copyright (c) 2023, the Luna authors. * */ #pragma once #include #include #include #include #include #include namespace ui { class Window { public: static Result create(Rect rect, bool decorated = true); void set_title(StringView title); void set_background(Color color) { m_background = color; } void set_main_widget(Widget& widget) { check(!m_main_widget); widget.set_window(this, m_canvas.rect(), {}); m_main_widget = &widget; } Canvas& canvas() { return m_canvas; } void update(); void close(); Result draw(); Result handle_mouse_leave(); Result handle_mouse_move(ui::Point position); Result handle_mouse_buttons(ui::Point position, int buttons); int id() const { return m_id; } ~Window(); private: int m_id; Canvas m_canvas; Widget* m_main_widget { nullptr }; Color m_background { ui::BLACK }; Option m_old_mouse_buttons; }; }