fix zoom change propagation
This commit is contained in:
15
src/node.cpp
15
src/node.cpp
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user