#pragma once #include "UI/Style/Style.h" #include "UI/Style/Theme.h" #include "Asset/AssetRegistry.h" #include "Asset/FontAsset.h" #include "MinimalEngine.h" #include namespace Seele { namespace UI { // a style class is anything with a static apply(Style&, const Theme&) template concept StyleClass = requires(Style& s, const Theme& t) { C::apply(s, t); }; // --- size --- template struct WidthClass { static void apply(Style& s, const Theme&) { s.width = w; s.widthType = widthType; } }; using W_Full = WidthClass<100, DimensionType::Percent>; template struct HeightClass { static void apply(Style& s, const Theme&) { s.height = h; s.heightType = DimensionType::Pixel; } }; using H_Full = HeightClass<100>; // --- display --- template struct DisplayClass { static void apply(Style& s, const Theme&) { s.outerDisplay = outer; s.innerDisplay = inner; } }; using Hidden = DisplayClass; using Block = DisplayClass; using Inline = DisplayClass; // --- fonts (looked up at style() time; fonts must be loaded before the first // System::style() call, see the invariant in System.h) --- // a string literal can't be a C++ template argument, so font *names* are carried // as runtime data on Style::fontName by a font class tag (e.g. UI::Font_Arial in // Fonts.h); Text::applyStyle resolves the name to a PFontAsset (Theme::defaultFont // as fallback). the font scale below is what remains a pure static class. // tailwind text scale: (fontSize, lineHeight) in px, scaled by Theme at style() time template struct FontSizeClass { static void apply(Style& s, const Theme& t) { s.fontSize = t.font(fontSize); s.lineHeight = t.font(lineHeight); } }; template struct BackgroundColorClass { static void apply(Style& s, const Theme& t) { s.backgroundColor = t.color(token); } }; template struct TextColorClass { static void apply(Style& s, const Theme& t) { s.textColor = t.color(token); } }; using BG_White = BackgroundColorClass; using BG_Gray950 = BackgroundColorClass; using BG_Gray900 = BackgroundColorClass; using BG_Gray800 = BackgroundColorClass; using BG_Gray700 = BackgroundColorClass; using BG_Gray600 = BackgroundColorClass; using BG_Red = BackgroundColorClass; using BG_Green = BackgroundColorClass; using BG_Blue = BackgroundColorClass; using BG_Amber = BackgroundColorClass; using C_White = TextColorClass; using C_Gray400 = TextColorClass; using C_Gray500 = TextColorClass; using C_Red = TextColorClass; using C_Green = TextColorClass; using C_Blue = TextColorClass; // --- spacing (themed: scaled by Theme::spacingScale for DPI/accessibility) --- // a side left as ~0U (4294967295) is left untouched template struct MarginClass { static void apply(Style& s, const Theme& t) { if constexpr (ml != ~0U) s.marginLeft = t.spacing(ml); if constexpr (mr != ~0U) s.marginRight = t.spacing(mr); if constexpr (mt != ~0U) s.marginTop = t.spacing(mt); if constexpr (mb != ~0U) s.marginBottom = t.spacing(mb); } }; template struct PaddingClass { static void apply(Style& s, const Theme& t) { if constexpr (ml != ~0U) s.paddingLeft = t.spacing(ml); if constexpr (mr != ~0U) s.paddingRight = t.spacing(mr); if constexpr (mt != ~0U) s.paddingTop = t.spacing(mt); if constexpr (mb != ~0U) s.paddingBottom = t.spacing(mb); } }; template struct GapClass { static void apply(Style& s, const Theme& t) { s.gap = t.spacing(g); } }; // curated tailwind spacing scale (px @ scale 1.0). // intermediate steps: declare a local MarginClass/PaddingClass alias // in your own namespace — StyleClass is a concept, not a closed set. #define SPACE(n) \ using M_##n = MarginClass; \ using P_##n = PaddingClass; \ using M_X##n = MarginClass; \ using M_Y##n = MarginClass<~0U, ~0U, n, n>; \ using P_X##n = PaddingClass; \ using P_Y##n = PaddingClass<~0U, ~0U, n, n>; \ using G_##n = GapClass; SPACE(0) SPACE(1) SPACE(2) SPACE(4) SPACE(6) SPACE(8) SPACE(10) SPACE(12) SPACE(16) SPACE(20) SPACE(24) SPACE(32) SPACE(40) SPACE(48) SPACE(64) SPACE(80) // tailwind text scale: (fontSize, lineHeight) @ scale 1.0. // names must be valid identifiers (no leading digit), and the macro body ends in ';' // or the next token gets glued to the using-declaration. #define TEXT_STEP(name, size, line) using Text_##name = FontSizeClass; TEXT_STEP(XS, 12, 16) TEXT_STEP(SM, 14, 20) TEXT_STEP(BASE, 16, 24) TEXT_STEP(LG, 18, 28) TEXT_STEP(XL, 20, 28) TEXT_STEP(XXL, 24, 32) TEXT_STEP(3XL, 30, 36) TEXT_STEP(4XL, 36, 40) TEXT_STEP(5XL, 48, 48) TEXT_STEP(6XL, 60, 60) TEXT_STEP(7XL, 72, 72) TEXT_STEP(8XL, 96, 96) } // namespace UI } // namespace Seele