refactor layout loading to add multiple layout, templates and references

This commit is contained in:
2017-02-01 20:35:57 +00:00
parent ed02e38805
commit 70792669e7
5 changed files with 97 additions and 51 deletions

View File

@@ -39,7 +39,6 @@ enum class kShapeType : uint16_t
Poly = const_hash("poly"),
RoundRect = const_hash("round-rect"),
Slice9 = const_hash("slice9"),
};
class Widget
@@ -185,8 +184,6 @@ class Node
{
const Node* parent{ nullptr };
YGNodeRef y_node{ nullptr };
struct stat m_file_info { 0 };
std::string m_path;
public:
std::vector<Node> m_children;
@@ -201,7 +198,6 @@ public:
Node(Node&& o)
{
m_name = std::move(o.m_name);
m_path = std::move(o.m_path);
m_widget = std::move(o.m_widget);
m_children = std::move(o.m_children);
for (auto& c : m_children)
@@ -211,7 +207,6 @@ public:
m_pos = o.m_pos;
m_size = o.m_size;
m_clip = o.m_clip;
m_file_info = o.m_file_info;
o.y_node = nullptr;
o.parent = nullptr;
}
@@ -254,9 +249,7 @@ public:
void update(float width, float height);
void update_internal(const glm::vec2& origin, const glm::mat4& proj);
void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr);
void load(const char* path);
void load_internal(const tinyxml2::XMLElement* x_node);
void reload();
void draw();
class iterator
@@ -292,3 +285,13 @@ public:
return nullptr;
}
};
class LayoutManager
{
std::map<uint16_t, Node> m_layouts;
std::string m_path;
struct stat m_file_info { 0 };
public:
bool load(const char* path);
void reload();
};