#pragma once #include #include #include #include "gfx/shape_renderer.h" #include "gfx/txt_renderer.h" #include "i_window_content.h" enum class WindowState { NORMAL, MINIMIZED, MAXIMIZED }; enum class WindowButtonAction { CLOSE, MAXIMIZE, MINIMIZE }; struct TitleBarButton { WindowButtonAction action; Color color; }; class UIWindow { public: UIWindow(const char* title, int x, int y, int width, int height); ~UIWindow(void); void render(ShapeRenderer* shape_renderer, TextRenderer* txt_renderer, int screen_height, bool show_cursor); void handle_event(SDL_Event* event, int screen_width, int screen_height, int taskbar_height); void minimize(void); void restore(void); bool is_minimized(void) const; bool should_close(void) const; void set_focused(bool focused); bool is_point_inside(int x, int y); void set_content(std::unique_ptr content); IWindowContent* get_content(void); bool is_mouse_over_resize_handle(int mouse_x, int mouse_y) const; const std::string& get_title(void) const; private: friend class Taskbar; /* Allow taskbar to access private members. */ int _x, _y, _width, _height; Rect _pre_maximize_rect; std::string _title; std::unique_ptr _content; bool _is_focused; /* Managed by desktop. */ bool _is_hovered; /* Send scroll events even if not focused. */ bool _should_close; std::vector _title_bar_buttons; WindowState _state; bool _is_dragging; int _drag_offset_x, _drag_offset_y; bool _is_resizing; int _resize_margin; };