ref nodes work fine now but need to complete Widget::clone implementations and add clone() to Shape classes to actually clone the OpenGL data
This commit is contained in:
@@ -31,6 +31,7 @@ enum class kWidget : uint16_t
|
||||
{
|
||||
Border = const_hash("border"),
|
||||
Shape = const_hash("shape"),
|
||||
Ref = const_hash("ref"),
|
||||
};
|
||||
|
||||
enum class kShapeType : uint16_t
|
||||
@@ -46,6 +47,16 @@ class Widget
|
||||
public:
|
||||
glm::mat4 mvp;
|
||||
glm::vec4 clip;
|
||||
virtual std::unique_ptr<Widget> clone() = 0;
|
||||
virtual void create() { }
|
||||
virtual void draw() { }
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) { }
|
||||
};
|
||||
|
||||
class WidgetRef : public Widget
|
||||
{
|
||||
public:
|
||||
uint16_t id;
|
||||
virtual void create() { }
|
||||
virtual void draw() { }
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) { }
|
||||
@@ -58,6 +69,12 @@ public:
|
||||
glm::vec4 m_color;
|
||||
glm::vec4 m_border_color;
|
||||
float m_thinkness{ 1 };
|
||||
virtual std::unique_ptr<Widget> clone() override
|
||||
{
|
||||
auto ret = std::make_unique<WidgetBorder>();
|
||||
*ret = *this;
|
||||
return std::move(ret);
|
||||
}
|
||||
virtual void draw() override
|
||||
{
|
||||
ShaderManager::use(kShader::Color);
|
||||
@@ -110,6 +127,12 @@ public:
|
||||
glm::vec4 m_border_color;
|
||||
float m_thinkness{ 1 };
|
||||
float m_radius{ .5f };
|
||||
virtual std::unique_ptr<Widget> clone() override
|
||||
{
|
||||
auto ret = std::make_unique<WidgetShape>();
|
||||
//*ret = *this;
|
||||
return std::move(ret);
|
||||
}
|
||||
virtual void create() override
|
||||
{
|
||||
switch (m_type)
|
||||
@@ -186,6 +209,7 @@ class Node
|
||||
|
||||
const Node* parent{ nullptr };
|
||||
YGNodeRef y_node{ nullptr };
|
||||
class LayoutManager* m_manager;
|
||||
|
||||
public:
|
||||
std::vector<Node> m_children;
|
||||
@@ -253,6 +277,7 @@ public:
|
||||
void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr);
|
||||
void load_internal(const tinyxml2::XMLElement* x_node);
|
||||
void draw();
|
||||
Node clone();
|
||||
|
||||
class iterator
|
||||
{
|
||||
@@ -297,5 +322,5 @@ public:
|
||||
bool load(const char* path);
|
||||
bool reload();
|
||||
Node& operator[](uint16_t id) { return m_layouts[id]; }
|
||||
Node& operator[](const char* ids) { return m_layouts[const_hash(ids)]; }
|
||||
//Node& operator[](const char* ids) { return m_layouts[const_hash(ids)]; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user