#pragma once #include #include #include #include #include #include #include namespace Tesses::BigScreen { constexpr int GRID_STRETCH_SZ(int ammount) { return -ammount; } constexpr int GRID_STRETCH = GRID_STRETCH_SZ(1); /* --bg-dark: hsl(136 100% 0%); --bg: hsl(133 100% 2%); --bg-light: hsl(134 100% 4%); --text: hsl(127 100% 90%); --text-muted: hsl(128 34% 64%); --highlight: hsl(144 100% 15%); --border: hsl(133 100% 9%); --border-muted: hsl(131 100% 4%); --primary: hsl(134 57% 56%); --secondary: hsl(301 74% 72%); --danger: hsl(7 94% 66%); --warning: hsl(53 100% 24%); --success: hsl(163 100% 26%); --info: hsl(217 100% 70%); */ constexpr SDL_Color COLOR_BGDARK = {.r = 0,.g=0,.b=0,.a=255}; constexpr SDL_Color COLOR_BG = {.r = 0,.g=10,.b=2,.a=255}; constexpr SDL_Color COLOR_BGLIGHT = {.r = 0,.g=20,.b=5,.a=255}; constexpr SDL_Color COLOR_TEXT = {.r = 204,.g=255,.b=210,.a=255}; constexpr SDL_Color COLOR_TEXTMUTED = {.r = 132,.g=194,.b=140,.a=255}; /* #004D1F*/ constexpr SDL_Color COLOR_HIGHLIGHT = {.r = 0,.g=77,.b=31,.a=255}; /* #002E0A */ constexpr SDL_Color COLOR_BORDER = {.r = 0,.g=46,.b=10,.a=255}; constexpr SDL_Color COLOR_BORDERMUTED = {.r = 0,.g=20,.b=4,.a=255}; constexpr SDL_Color COLOR_PRIMARY = {.r = 79,.g=207,.b=109,.a=255}; class BigScreenWindow; enum class EventResult { Ignored, Handled, ParentDo }; enum class LastDirection { North, South, East, West }; class Widget { public: std::weak_ptr parent; virtual EventResult Event(SDL_Event& event, SDL_Rect& rect) = 0; virtual void Draw(SDL_Rect& rect)=0; virtual std::shared_ptr GetRoot(); virtual ~Widget() = default; virtual bool CanFocus(); virtual int MinHeight(); virtual int MinWidth(); }; class VGrid : public Widget, public std::enable_shared_from_this { std::vector, int>> widgets; public: void AddChild(std::shared_ptr widget, int height); EventResult Event(SDL_Event& event,SDL_Rect& rect); void Draw(SDL_Rect& rect); ~VGrid() = default; int MinWidth(); int MinHeight(); }; class HGrid : public Widget, public std::enable_shared_from_this { std::vector, int>> widgets; public: void AddChild(std::shared_ptr widget, int width); EventResult Event(SDL_Event& event,SDL_Rect& rect); void Draw(SDL_Rect& rect); ~HGrid() = default; int MinWidth(); int MinHeight(); }; class Text : public Widget { private: std::string text; SDL_Color color; public: Text(std::string text); Text(std::string text, std::string color); Text(std::string text, SDL_Color color); bool CanFocus(); SDL_Color GetColor(); void SetColor(SDL_Color color); void SetColor(std::string color); std::string GetText(); void SetText(std::string text); EventResult Event(SDL_Event& event,SDL_Rect& rect); void Draw(SDL_Rect& rect); int MinWidth(); int MinHeight(); }; class Button : public Widget, public std::enable_shared_from_this