fix zoom change propagation

This commit is contained in:
2019-08-08 10:11:30 +02:00
parent 079f66edf9
commit 34464c167e
9 changed files with 48 additions and 50 deletions

View File

@@ -251,7 +251,7 @@ kEventResult Node::handle_event(Event* e)
return kEventResult::Available;
}
void Node::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
void Node::handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom)
{
}
@@ -959,16 +959,16 @@ void Node::update(float width, float height, float zoom)
YGNodeStyleSetHeight(y_node, height / zoom);
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
m_proj = glm::ortho(0.f, width / zoom, height / zoom, 0.f, -1.f, 1.f);
update_internal({ 0, 0 }, m_proj);
update_internal({ 0, 0 }, m_proj, zoom);
}
void Node::update()
{
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
update_internal({ 0, 0 }, m_proj);
update_internal({ 0, 0 }, m_proj, m_zoom);
}
void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float zoom)
{
float x = YGNodeLayoutGetLeft(y_node);
float y = YGNodeLayoutGetTop(y_node);
@@ -1017,15 +1017,16 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
}
}
if (m_size != old_size)
if (m_size != old_size || m_zoom != zoom)
{
handle_resize(old_size, m_size);
m_zoom = zoom;
handle_resize(old_size, m_size, zoom);
for (auto& c : m_children)
c->handle_parent_resize(old_size, m_size);
}
for (auto& c : m_children)
c->update_internal(m_pos, proj);
c->update_internal(m_pos, proj, zoom);
}
void Node::tick(float dt)