fix zoom change propagation
This commit is contained in:
@@ -1746,43 +1746,40 @@ Here's a list of what's available in this release.
|
|||||||
</border>
|
</border>
|
||||||
<!-- central row -->
|
<!-- central row -->
|
||||||
<node grow="1" dir="row" wrap="1" height="0" id="central-row">
|
<node grow="1" dir="row" wrap="1" height="0" id="central-row">
|
||||||
<border color="0 0 0 0.6" pad="0 5 0 0" justify="center" dir="col" flood-events="1" mouse-capture="true">
|
<border color="0 0 0 0.6" pad="0 5 55 0" justify="center" dir="col" wrap="1" flood-events="1" mouse-capture="true">
|
||||||
<node margin="0 0 55 0" wrap="1" >
|
<button-custom id="btn-pen" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<button-custom id="btn-pen" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<image path="data/ui/pen.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
<image path="data/ui/pen.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
</button-custom>
|
||||||
</button-custom>
|
<button-custom id="btn-pick" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<button-custom id="btn-pick" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<image path="data/ui/picker.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
<image path="data/ui/picker.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
</button-custom>
|
||||||
</button-custom>
|
|
||||||
|
|
||||||
<button-custom id="btn-erase" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-erase" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/eraser.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/eraser.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
|
||||||
<button-custom id="btn-bucket" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-bucket" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/bucket.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/bucket.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
|
||||||
<button-custom id="btn-line" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-line" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/line.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/line.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="btn-mask-free" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-mask-free" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/sel-free.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/sel-free.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="btn-mask-line" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-mask-line" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/sel-poly.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/sel-poly.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button id="btn-copy" width="40" height="40" margin="2 0 2 5" text="Copy"/>
|
<button id="btn-copy" width="40" height="40" margin="2 0 2 5" text="Copy"/>
|
||||||
<button id="btn-cut" width="40" height="40" margin="2 0 2 5" text="Cut"/>
|
<button id="btn-cut" width="40" height="40" margin="2 0 2 5" text="Cut"/>
|
||||||
<!-- <button id="btn-fill" width="40" height="40" margin="0" text="Fill"/> -->
|
<!-- <button id="btn-fill" width="40" height="40" margin="0" text="Fill"/> -->
|
||||||
|
|
||||||
<button id="btn-cam" width="40" height="40" margin="2 0 2 5" text="Cam"/>
|
<button id="btn-cam" width="40" height="40" margin="2 0 2 5" text="Cam"/>
|
||||||
<button id="btn-grid" width="40" height="40" margin="2 0 2 5" text="Guide"/>
|
<button id="btn-grid" width="40" height="40" margin="2 0 2 5" text="Guide"/>
|
||||||
<button-custom id="btn-touchlock" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
<button-custom id="btn-touchlock" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
<image path="data/ui/notouch.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/notouch.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
|
||||||
</node>
|
|
||||||
</border>
|
</border>
|
||||||
|
|
||||||
<scroll id="drop-left" color="0 0 0 .6" min-width="10" mouse-capture="true" rtl="ltr"/>
|
<scroll id="drop-left" color="0 0 0 .6" min-width="10" mouse-capture="true" rtl="ltr"/>
|
||||||
|
|||||||
15
src/node.cpp
15
src/node.cpp
@@ -251,7 +251,7 @@ kEventResult Node::handle_event(Event* e)
|
|||||||
return kEventResult::Available;
|
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);
|
YGNodeStyleSetHeight(y_node, height / zoom);
|
||||||
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
|
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
m_proj = glm::ortho(0.f, width / zoom, height / zoom, 0.f, -1.f, 1.f);
|
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()
|
void Node::update()
|
||||||
{
|
{
|
||||||
YGNodeCalculateLayout(y_node, YGUndefined, YGUndefined, YGDirectionLTR);
|
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 x = YGNodeLayoutGetLeft(y_node);
|
||||||
float y = YGNodeLayoutGetTop(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)
|
for (auto& c : m_children)
|
||||||
c->handle_parent_resize(old_size, m_size);
|
c->handle_parent_resize(old_size, m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : m_children)
|
for (auto& c : m_children)
|
||||||
c->update_internal(m_pos, proj);
|
c->update_internal(m_pos, proj, zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::tick(float dt)
|
void Node::tick(float dt)
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public:
|
|||||||
virtual void clear_context();
|
virtual void clear_context();
|
||||||
void update(float width, float height, float zoom);
|
void update(float width, float height, float zoom);
|
||||||
void update();
|
void update();
|
||||||
void update_internal(const glm::vec2& origin, const glm::mat4& proj);
|
void update_internal(const glm::vec2& origin, const glm::mat4& proj, float zoom);
|
||||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr);
|
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr);
|
||||||
void load_internal(const tinyxml2::XMLElement* x_node);
|
void load_internal(const tinyxml2::XMLElement* x_node);
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
@@ -253,7 +253,7 @@ public:
|
|||||||
virtual void on_tick(float dt) { };
|
virtual void on_tick(float dt) { };
|
||||||
virtual kEventResult on_event(Event* e);
|
virtual kEventResult on_event(Event* e);
|
||||||
virtual kEventResult handle_event(Event* e);
|
virtual kEventResult handle_event(Event* e);
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size);
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom);
|
||||||
virtual void handle_on_screen(bool old_visibility, bool new_visibility);
|
virtual void handle_on_screen(bool old_visibility, bool new_visibility);
|
||||||
virtual void handle_parent_resize(glm::vec2 old_size, glm::vec2 new_size);
|
virtual void handle_parent_resize(glm::vec2 old_size, glm::vec2 new_size);
|
||||||
virtual void create();
|
virtual void create();
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void NodeCanvas::draw()
|
|||||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeCanvas::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
void NodeCanvas::handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom)
|
||||||
{
|
{
|
||||||
if (new_size.x != m_canvas->m_width || new_size.y != m_canvas->m_height)
|
if (new_size.x != m_canvas->m_width || new_size.y != m_canvas->m_height)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
virtual void restore_context() override;
|
virtual void restore_context() override;
|
||||||
virtual void clear_context() override;
|
virtual void clear_context() override;
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size) override;
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
||||||
virtual kEventResult handle_event(Event* e) override;
|
virtual kEventResult handle_event(Event* e) override;
|
||||||
virtual void destroy_immediate() override;
|
virtual void destroy_immediate() override;
|
||||||
virtual void on_tick(float dt) override;
|
virtual void on_tick(float dt) override;
|
||||||
|
|||||||
@@ -568,8 +568,8 @@ void NodeHeightmapOverlay::draw()
|
|||||||
m_picker->SetPosition(pos - m_picker->GetSize() * .5f);
|
m_picker->SetPosition(pos - m_picker->GetSize() * .5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeHeightmapOverlay::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
void NodeHeightmapOverlay::handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom)
|
||||||
{
|
{
|
||||||
NodeBorder::handle_resize(old_size, new_size);
|
NodeBorder::handle_resize(old_size, new_size, zoom);
|
||||||
set_value(m_value.x, m_value.y);
|
set_value(m_value.x, m_value.y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
void set_value(float x, float y);
|
void set_value(float x, float y);
|
||||||
virtual kEventResult handle_event(Event* e) override;
|
virtual kEventResult handle_event(Event* e) override;
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size) override;
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NodePanelGrid : public Node
|
class NodePanelGrid : public Node
|
||||||
|
|||||||
@@ -578,9 +578,9 @@ void NodeStrokePreview::draw()
|
|||||||
m_tex_preview.unbind();
|
m_tex_preview.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom)
|
||||||
{
|
{
|
||||||
if (m_tex_preview.size() == new_size || !m_brush)
|
if (m_tex_preview.size() == new_size || m_preview_size == (new_size * root()->m_zoom) || !m_brush)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_preview_size = new_size * root()->m_zoom;
|
m_preview_size = new_size * root()->m_zoom;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
void draw_stroke();
|
void draw_stroke();
|
||||||
void draw_stroke_immediate();
|
void draw_stroke_immediate();
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size) override;
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
||||||
virtual void destroy_immediate() override;
|
virtual void destroy_immediate() override;
|
||||||
virtual void handle_on_screen(bool old_visibility, bool new_visibility) override;
|
virtual void handle_on_screen(bool old_visibility, bool new_visibility) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user