basic flow layout
This commit is contained in:
1 parent
e487867f96
commit
2915db8898
18 files changed
+415
-172
No files matched your search
+30
-12
@@ -1,27 +1,45 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Style.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
|
||||
namespace Seele {
|
||||
namespace UI {
|
||||
template <typename C>
|
||||
concept StyleClass = requires(C c, Style& s) { c.apply(s); };
|
||||
concept StyleClass = requires(C c, UI::Style& s) { c.apply(s); };
|
||||
|
||||
template <uint32 w, DimensionType widthType> struct WidthClass {
|
||||
static void apply(Style& s) {
|
||||
template <uint32 w, UI::DimensionType widthType> struct WidthClass {
|
||||
static void apply(UI::Style& s) {
|
||||
s.width = w;
|
||||
s.widthType = widthType;
|
||||
}
|
||||
};
|
||||
using W_Full = WidthClass<100, DimensionType::Percent>;
|
||||
using W_1 = WidthClass<2, DimensionType::Pixel>;
|
||||
using W_Full = WidthClass<100, UI::DimensionType::Percent>;
|
||||
using W_1 = WidthClass<2, UI::DimensionType::Pixel>;
|
||||
|
||||
template <DisplayType displayType> struct DisplayClass {
|
||||
static void apply(Style& s) { s.displayType = displayType; }
|
||||
template <UI::OuterDisplayType outer, UI::InnerDisplayType inner> struct DisplayClass {
|
||||
static void apply(UI::Style& s) {
|
||||
s.outerDisplay = outer;
|
||||
s.innerDisplay = inner;
|
||||
}
|
||||
};
|
||||
using Hidden = DisplayClass<DisplayType::Hidden>;
|
||||
using Block = DisplayClass<DisplayType::Block>;
|
||||
using Flex = DisplayClass<DisplayType::Flex>;
|
||||
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>;
|
||||
|
||||
} // namespace UI
|
||||
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)>;
|
||||
} // namespace Seele
|
||||
Reference in new issue
Block a user