Files
Seele/src/Engine/UI/Style/Class.h
T

45 lines
1.5 KiB
C++
Raw Normal View History

2025-01-08 19:15:12 +01:00
#pragma once
#include "MinimalEngine.h"
#include "Style.h"
2025-01-12 11:26:52 +01:00
#include "Asset/AssetRegistry.h"
2025-01-08 19:15:12 +01:00
namespace Seele {
template <typename C>
2025-01-12 11:26:52 +01:00
concept StyleClass = requires(C c, UI::Style& s) { c.apply(s); };
2025-01-08 19:15:12 +01:00
2025-01-12 11:26:52 +01:00
template <uint32 w, UI::DimensionType widthType> struct WidthClass {
static void apply(UI::Style& s) {
2025-01-08 19:15:12 +01:00
s.width = w;
s.widthType = widthType;
}
};
2025-01-12 11:26:52 +01:00
using W_Full = WidthClass<100, UI::DimensionType::Percent>;
using W_1 = WidthClass<2, UI::DimensionType::Pixel>;
2025-01-08 19:15:12 +01:00
2025-01-12 11:26:52 +01:00
template <UI::OuterDisplayType outer, UI::InnerDisplayType inner> struct DisplayClass {
static void apply(UI::Style& s) {
s.outerDisplay = outer;
s.innerDisplay = inner;
}
2025-01-08 19:15:12 +01:00
};
2025-01-12 11:26:52 +01:00
using Hidden = DisplayClass<UI::OuterDisplayType::Hidden, UI::InnerDisplayType::Flow>;
using Block = DisplayClass<UI::OuterDisplayType::Block, UI::InnerDisplayType::Flow>;
using Inline = DisplayClass<UI::OuterDisplayType::Inline, UI::InnerDisplayType::Flow>;
2025-01-08 19:15:12 +01:00
2025-01-12 11:26:52 +01:00
template <size_t N> struct StringLiteral {
constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
char value[N];
};
template <StringLiteral lit> struct FontClass {
static void apply(UI::Style& s) { s.fontFamily = AssetRegistry::findFont("", lit.value); }
};
using Font_Arial = FontClass<"arial">;
template <Vector backgroundColor> struct BackgroundColorClass {
static void apply(UI::Style& s) { s.backgroundColor = backgroundColor; }
};
using BG_Red = BackgroundColorClass<Vector(1, 0, 0)>;
2025-01-08 19:15:12 +01:00
} // namespace Seele