Files
Seele/src/Engine/UI/Element/Div.h
T

44 lines
2.0 KiB
C++

#pragma once
#include "UI/Element.h"
#include "UI/Style/Class.h"
namespace Seele {
namespace UI {
template<StyleClass... classes>
class Div : public Element {
public:
// forward every Element construction form (no children / variadic / initializer list)
using Element::Element;
Div() = delete; // force an explicit style/attrs choice, no accidental empty divs
virtual ~Div() {}
virtual void applyStyle(Style parentStyle, const Theme& theme) override {
style = parentStyle;
// CSS non-inherited properties: reset to defaults before applying template
// classes. width/height, min/max, margin/padding, gap, position offsets, and
// per-item flex properties (grow/shrink/order/basis/alignSelf) are all
// non-inherited in CSS — a child's Div classes opt in explicitly.
// Inherited (keep from parent): display, direction, wrap, justify, items,
// content, z, colors, font, lineHeight, fontSize, fontWeight.
style.widthType = DimensionType::Auto; style.width = 0;
style.minWidthType = DimensionType::Auto; style.minWidth = 0;
style.maxWidthType = DimensionType::Auto; style.maxWidth = 0;
style.heightType = DimensionType::Auto; style.height = 0;
style.minHeightType = DimensionType::Auto; style.minHeight = 0;
style.maxHeightType = DimensionType::Auto; style.maxHeight = 0;
style.paddingTop = 0; style.paddingBottom = 0;
style.paddingLeft = 0; style.paddingRight = 0;
style.marginTop = 0; style.marginBottom = 0;
style.marginLeft = 0; style.marginRight = 0;
style.gap = 0;
style.top = 0; style.bottom = 0; style.left = 0; style.right = 0;
style.position = Position::Static;
style.grow = 0.f; style.shrink = 1.f;
style.order = 0; style.alignSelfOverride = -1.f;
style.basisType = DimensionType::Auto; style.basis = 0.f;
(classes::apply(style, theme), ...);
}
private:
};
} // namespace UI
} // namespace Seele