bettola/client/src/ui/ui_window.h
Ritchie Cunningham ea25cb6cc7 [Add] Taskbar and window management work
- Adds a taskbar that displays and manages open application windows
- close, minimise and restore functionality
- resizeable windows
- Refactored desktop event handling to manage window focus and render
  order
2025-09-28 14:12:11 +01:00

53 lines
1.3 KiB
C++

#pragma once
#include <memory>
#include <string>
#include "gfx/shape_renderer.h"
#include "gfx/txt_renderer.h"
#include "terminal.h"
enum class WindowState {
NORMAL,
MINIMIZED,
MAXIMIZED
};
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);
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<Terminal> term);
Terminal* 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<Terminal> _content;
bool _is_focused; /* Managed by desktop. */
bool _is_hovered; /* Send scroll events even if not focused. */
bool _should_close;
WindowState _state;
bool _is_dragging;
int _drag_offset_x, _drag_offset_y;
bool _is_resizing;
int _resize_margin;
};