diff --git a/Editor/resources/Interface/Testing.css b/Editor/resources/Interface/Testing.css index 7a24cc90..bca5b904 100644 --- a/Editor/resources/Interface/Testing.css +++ b/Editor/resources/Interface/Testing.css @@ -1,7 +1,11 @@ - - .button { - width: 10px; - height: 100px; - color: rgba(1, 1, 2, 1); -} \ No newline at end of file + width: 25%; + height: 100%; +} + +.left { + width: 100px; + height: 150px; + margin: 50px 100px; +} + diff --git a/Editor/resources/Interface/Testing.interface b/Editor/resources/Interface/Testing.interface new file mode 100644 index 00000000..14be270f --- /dev/null +++ b/Editor/resources/Interface/Testing.interface @@ -0,0 +1,31 @@ + + + + + + + + + + diff --git a/Nuake/src/UI/Canvas.cpp b/Nuake/src/UI/Canvas.cpp new file mode 100644 index 00000000..189bf5dc --- /dev/null +++ b/Nuake/src/UI/Canvas.cpp @@ -0,0 +1,5 @@ +#include "Canvas.h" +Canvas::Canvas() +{ + +} diff --git a/Nuake/src/UI/InterfaceParser.cpp b/Nuake/src/UI/InterfaceParser.cpp new file mode 100644 index 00000000..1144bd12 --- /dev/null +++ b/Nuake/src/UI/InterfaceParser.cpp @@ -0,0 +1,3 @@ +#include "InterfaceParser.h" + +Ref InterfaceParser::Root = CreateRef(); \ No newline at end of file diff --git a/Nuake/src/UI/InterfaceParser.h b/Nuake/src/UI/InterfaceParser.h index 54b45792..1ed417f1 100644 --- a/Nuake/src/UI/InterfaceParser.h +++ b/Nuake/src/UI/InterfaceParser.h @@ -32,6 +32,8 @@ public: return Root; } + + static void Iterate(const pugi::xml_node& xml_node, Ref node) { for (auto& e : xml_node.children()) @@ -58,6 +60,13 @@ public: for (auto& a : xml_node.attributes()) { std::string name = a.name(); + if (name == "groups") + { + for (auto& g : split(a.value(), ' ')) + { + node->AddGroup(g); + } + } if (name == "height") node->Height = GetUnit(a.value()); if (name == "width") @@ -72,7 +81,6 @@ public: node->Position = GetVec4Unit(a.value()); if (name == "color") node->BackgroundColor = GetColor(a.value()); - } return node; @@ -200,6 +208,13 @@ public: for (auto& a : xml_node.attributes()) { std::string name = a.name(); + if (name == "groups") + { + for (auto& g : split(a.value(), ' ')) + { + node->AddGroup(g); + } + } if (name == "height") node->Height = GetUnit(a.value()); if (name == "width") diff --git a/Nuake/src/UI/Node.cpp b/Nuake/src/UI/Node.cpp index e0d1567c..cbc2fff6 100644 --- a/Nuake/src/UI/Node.cpp +++ b/Nuake/src/UI/Node.cpp @@ -1,8 +1,62 @@ #include "Node.h" +void Node::ApplyStyle(Ref stylegroup) +{ + for (auto& s : stylegroup->GetProps()) + { + switch (s.first) + { + case PropType::HEIGHT: + { + Height.Unit = (Layout::Unit)(s.second.type); + float value = s.second.value.Number; + Height.Value = value; + } + break; + case PropType::MIN_HEIGHT: + MinHeight.Unit = (Layout::Unit)s.second.type; + MinHeight.Value = s.second.value.Number; + break; + case PropType::MAX_HEIGHT: + MaxHeight.Unit = (Layout::Unit)s.second.type; + MaxHeight.Value = s.second.value.Number; + break; + case PropType::WIDTH: + Width.Unit = (Layout::Unit)s.second.type; + Width.Value = s.second.value.Number; + break; + case PropType::MIN_WIDTH: + MinWidth.Unit = (Layout::Unit)s.second.type; + MinWidth.Value = s.second.value.Number; + break; + case PropType::MAX_WIDTH: + MaxWidth.Unit = (Layout::Unit)s.second.type; + MaxWidth.Value = s.second.value.Number; + break; + case PropType::MARGIN_RIGHT: + Margin.Right.Unit = (Layout::Unit)s.second.type; + Margin.Right.Value = s.second.value.Number; + break; + case PropType::MARGIN_LEFT: + Margin.Left.Unit = (Layout::Unit)s.second.type; + Margin.Left.Value = s.second.value.Number; + break; + case PropType::MARGIN_TOP: + Margin.Top.Unit = (Layout::Unit)s.second.type; + Margin.Top.Value = s.second.value.Number; + break; + case PropType::MARGIN_BOTTOM: + Margin.Bottom.Unit = (Layout::Unit)s.second.type; + Margin.Bottom.Value = s.second.value.Number; + break; + } + } +} + Node::Node() { Childrens = std::vector>(); + Groups = std::vector(); PositionType = Layout::PositionType::RELATIVE; Position = Layout::LayoutVec4(); diff --git a/Nuake/src/UI/Node.h b/Nuake/src/UI/Node.h index 5a2ef59c..5d66f5b4 100644 --- a/Nuake/src/UI/Node.h +++ b/Nuake/src/UI/Node.h @@ -4,6 +4,8 @@ #include "yoga/Yoga.h" #include "../Rendering/Renderer2D.h" #include "../Core/Logger.h" +#include "Style.h" + namespace Layout { enum class LayoutDirection @@ -70,6 +72,10 @@ public: YGNodeRef YogaNode; std::vector> Childrens = std::vector>(); + void ApplyStyle(Ref stylegroup); + Ref