rename parent to m_parent and add floating panel class
This commit is contained in:
54
src/node.cpp
54
src/node.cpp
@@ -83,8 +83,8 @@ Node* Node::root()
|
||||
{
|
||||
|
||||
Node* ret = this;
|
||||
while (ret->parent)
|
||||
ret = ret->parent;
|
||||
while (ret->m_parent)
|
||||
ret = ret->m_parent;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ const Node* Node::init_template(const char* id)
|
||||
void Node::add_child(Node* n)
|
||||
{
|
||||
m_children.emplace_back(n);
|
||||
n->parent = this;
|
||||
n->m_parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
|
||||
n->added(this);
|
||||
@@ -313,7 +313,7 @@ void Node::add_child(Node* n)
|
||||
void Node::add_child(Node* n, int index)
|
||||
{
|
||||
m_children.emplace_back(n);
|
||||
n->parent = this;
|
||||
n->m_parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, index);
|
||||
n->added(this);
|
||||
@@ -323,7 +323,7 @@ void Node::add_child(Node* n, int index)
|
||||
void Node::add_child(std::shared_ptr<Node> n)
|
||||
{
|
||||
m_children.push_back(n);
|
||||
n->parent = this;
|
||||
n->m_parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
|
||||
n->added(this);
|
||||
@@ -333,7 +333,7 @@ void Node::add_child(std::shared_ptr<Node> n)
|
||||
void Node::add_child(std::shared_ptr<Node> n, int index)
|
||||
{
|
||||
m_children.insert(m_children.begin() + index, n);
|
||||
n->parent = this;
|
||||
n->m_parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, index);
|
||||
n->added(this);
|
||||
@@ -489,7 +489,7 @@ void Node::mouse_capture()
|
||||
|
||||
void Node::mouse_release()
|
||||
{
|
||||
if (!parent)
|
||||
if (!m_parent)
|
||||
return;
|
||||
|
||||
auto& c = root()->current_mouse_capture;
|
||||
@@ -514,7 +514,7 @@ void Node::mouse_release()
|
||||
|
||||
void Node::key_capture()
|
||||
{
|
||||
if (!parent)
|
||||
if (!m_parent)
|
||||
return;
|
||||
|
||||
root()->current_key_capture = this;
|
||||
@@ -545,10 +545,10 @@ Node::Node(Node&& o)
|
||||
m_nodeID_s = std::move(o.m_nodeID_s);
|
||||
m_children = std::move(o.m_children);
|
||||
for (auto& c : m_children)
|
||||
c->parent = this;
|
||||
c->m_parent = this;
|
||||
m_nodeID = o.m_nodeID;
|
||||
m_display = o.m_display;
|
||||
parent = o.parent;
|
||||
m_parent = o.m_parent;
|
||||
y_node = o.y_node;
|
||||
m_pos = o.m_pos;
|
||||
m_size = o.m_size;
|
||||
@@ -556,7 +556,7 @@ Node::Node(Node&& o)
|
||||
m_zoom = o.m_zoom;
|
||||
m_mouse_ignore = o.m_mouse_ignore;
|
||||
o.y_node = nullptr;
|
||||
o.parent = nullptr;
|
||||
o.m_parent = nullptr;
|
||||
|
||||
m_manager = o.m_manager;
|
||||
current_mouse_capture = o.current_mouse_capture;
|
||||
@@ -748,20 +748,20 @@ void Node::SetVisibility(bool visible)
|
||||
if (m_display && !visible)
|
||||
{
|
||||
// hide
|
||||
int idx = parent->get_child_index(this);
|
||||
YGNodeRemoveChild(parent->y_node, y_node);
|
||||
int idx = m_parent->get_child_index(this);
|
||||
YGNodeRemoveChild(m_parent->y_node, y_node);
|
||||
y_placeholder = YGNodeNew();
|
||||
YGNodeInsertChild(parent->y_node, y_placeholder, idx);
|
||||
YGNodeInsertChild(m_parent->y_node, y_placeholder, idx);
|
||||
}
|
||||
else if (!m_display && visible)
|
||||
{
|
||||
int count = YGNodeGetChildCount(parent->y_node);
|
||||
int count = YGNodeGetChildCount(m_parent->y_node);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (YGNodeGetChild(parent->y_node, i) == y_placeholder)
|
||||
if (YGNodeGetChild(m_parent->y_node, i) == y_placeholder)
|
||||
{
|
||||
YGNodeRemoveChild(parent->y_node, y_placeholder);
|
||||
YGNodeInsertChild(parent->y_node, y_node, i);
|
||||
YGNodeRemoveChild(m_parent->y_node, y_placeholder);
|
||||
YGNodeInsertChild(m_parent->y_node, y_node, i);
|
||||
YGNodeFree(y_placeholder);
|
||||
y_placeholder = nullptr;
|
||||
break;
|
||||
@@ -836,25 +836,25 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
|
||||
float w = YGNodeLayoutGetWidth(y_node);
|
||||
float h = YGNodeLayoutGetHeight(y_node);
|
||||
auto old_size = m_size;
|
||||
glm::vec2 parent_offset = parent ? parent->m_pos_offset_childred : glm::vec2(0.f);
|
||||
glm::vec2 parent_offset = m_parent ? m_parent->m_pos_offset_childred : glm::vec2(0.f);
|
||||
m_pos = glm::floor(origin + glm::vec2(x, y) + m_pos_offset + parent_offset);
|
||||
m_pos_origin = glm::floor(origin + glm::vec2(x, y));
|
||||
m_size = glm::floor(glm::vec2(w, h));
|
||||
|
||||
if (parent)
|
||||
if (m_parent)
|
||||
{
|
||||
// correct the padding clip
|
||||
// should not clip the padded area
|
||||
// useful to draw decorations
|
||||
float pt = YGNodeLayoutGetPadding(parent->y_node, YGEdgeTop);
|
||||
float pr = YGNodeLayoutGetPadding(parent->y_node, YGEdgeRight);
|
||||
float pb = YGNodeLayoutGetPadding(parent->y_node, YGEdgeBottom);
|
||||
float pl = YGNodeLayoutGetPadding(parent->y_node, YGEdgeLeft);
|
||||
float pt = YGNodeLayoutGetPadding(m_parent->y_node, YGEdgeTop);
|
||||
float pr = YGNodeLayoutGetPadding(m_parent->y_node, YGEdgeRight);
|
||||
float pb = YGNodeLayoutGetPadding(m_parent->y_node, YGEdgeBottom);
|
||||
float pl = YGNodeLayoutGetPadding(m_parent->y_node, YGEdgeLeft);
|
||||
glm::vec2 off_p(pl, pt);
|
||||
glm::vec2 off_s(pr, pb);
|
||||
glm::vec4 pclip = { xy(parent->m_clip) + off_p, zw(parent->m_clip) - (off_s + off_p)};
|
||||
glm::vec4 pclip = { xy(m_parent->m_clip) + off_p, zw(m_parent->m_clip) - (off_s + off_p)};
|
||||
m_clip_uncut = glm::vec4(m_pos - glm::vec2(1), m_size + glm::vec2(2));
|
||||
m_clip = rect_intersection(m_clip_uncut, parent->m_clip);
|
||||
m_clip = rect_intersection(m_clip_uncut, m_parent->m_clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1241,7 +1241,7 @@ void Node::clone_children(Node* dest) const
|
||||
{
|
||||
Node* cn = c->clone();
|
||||
dest->m_children.emplace_back(cn);
|
||||
cn->parent = dest;
|
||||
cn->m_parent = dest;
|
||||
cn->m_manager = dest->m_manager;
|
||||
cn->loaded();
|
||||
YGNodeInsertChild(dest->y_node, cn->y_node, YGNodeGetChildCount(dest->y_node));
|
||||
|
||||
Reference in New Issue
Block a user