fix scroll

This commit is contained in:
2019-10-20 16:13:24 +02:00
parent e30ac277c1
commit 0d575be198
7 changed files with 29 additions and 36 deletions

View File

@@ -1077,8 +1077,13 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
float w = YGNodeLayoutGetWidth(y_node);
float h = YGNodeLayoutGetHeight(y_node);
auto old_size = m_size;
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);
if (YGNodeStyleGetWidth(y_node).unit == YGUnit::YGUnitAuto)
w -= m_pos_offset.x;
//if (YGNodeStyleGetHeight(y_node).unit == YGUnit::YGUnitAuto)
// h -= m_pos_offset.y;
m_pos = /*glm::floor*/(origin + glm::vec2(x, y) + m_pos_offset);
m_pos_origin = /*glm::floor*/(origin + glm::vec2(x, y));
m_size = /*glm::floor*/(glm::vec2(w, h));
@@ -1095,7 +1100,7 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
glm::vec2 off_s(pr, pb);
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, m_parent->m_clip) + glm::vec4(0, 0, -parent_offset);
m_clip = rect_intersection(m_clip_uncut, m_parent->m_clip);
}
else
{
@@ -1118,7 +1123,10 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
}
for (auto& c : m_children)
c->update_internal(m_pos, proj, zoom);
{
c->m_pos_offset = m_pos_offset + m_pos_offset_childred;
c->update_internal(m_pos_origin, proj, zoom);
}
m_children.erase(std::remove_if(m_children.begin(), m_children.end(),
[](const auto& n) { return n->m_destroyed; }), m_children.end());