fix scroll
This commit is contained in:
@@ -28,14 +28,16 @@
|
|||||||
<layout id="tpl-panel-animation">
|
<layout id="tpl-panel-animation">
|
||||||
<node margin="0 0 10 0" rtl="ltr" grow="1" dir="col">
|
<node margin="0 0 10 0" rtl="ltr" grow="1" dir="col">
|
||||||
|
|
||||||
<scroll pad="0 5 0 5" dir="row" color=".4" grow="1" shrink="1">
|
<scroll pad="0 5 0 5" color=".4" grow="1" shrink="1">
|
||||||
<node color=".3" id="layers" width="100" dir="col-reverse" justify="flex-end" margin="20 5 0 0"></node>
|
<node grow="1" dir="row">
|
||||||
<scroll id="hscroll" scroll-dir="h" color=".6" grow="1" shrink="1" dir="col" margin="0 0 5 0">
|
<node color=".3" id="layers" width="100" dir="col-reverse" justify="flex-end" margin="20 5 0 0"></node>
|
||||||
<border color=".4">
|
<scroll id="hscroll" scroll-dir="h" color=".6" grow="1" shrink="1" dir="col" margin="0 0 5 0">
|
||||||
<timeline id="timeline" height="20"/>
|
<border color=".4">
|
||||||
</border>
|
<timeline id="timeline" height="20"/>
|
||||||
<node id="frames" dir="col-reverse" justify="flex-end" flood-events="1"></node>
|
</border>
|
||||||
</scroll>
|
<node id="frames" dir="col-reverse" justify="flex-end" flood-events="1"></node>
|
||||||
|
</scroll>
|
||||||
|
</node>
|
||||||
</scroll>
|
</scroll>
|
||||||
|
|
||||||
<border height="40" color=".5" dir="row" align="center" flood-events="1">
|
<border height="40" color=".5" dir="row" align="center" flood-events="1">
|
||||||
|
|||||||
@@ -538,15 +538,15 @@ bool App::update_ui_observer(Node *n)
|
|||||||
float pl = YGNodeLayoutGetPadding(p->y_node, YGEdgeLeft);
|
float pl = YGNodeLayoutGetPadding(p->y_node, YGEdgeLeft);
|
||||||
glm::vec2 off_p(pl, pt);
|
glm::vec2 off_p(pl, pt);
|
||||||
glm::vec2 off_s(pr, pb);
|
glm::vec2 off_s(pr, pb);
|
||||||
glm::vec2 parent_offset = p->m_parent ? -p->m_parent->m_pos_offset_childred : glm::vec2(0.f);
|
//glm::vec2 parent_offset = p->m_parent ? -p->m_parent->m_pos_offset_childred : glm::vec2(0.f);
|
||||||
glm::vec4 pclip = { xy(p->m_clip_uncut) + off_p, zw(p->m_clip_uncut) - off_s - off_p + parent_offset };
|
glm::vec4 pclip = { xy(p->m_clip_uncut) + off_p, zw(p->m_clip_uncut) - off_s - off_p/* + parent_offset*/ };
|
||||||
box = rect_intersection(box, pclip);
|
box = rect_intersection(box, pclip);
|
||||||
p = p->m_parent;
|
p = p->m_parent;
|
||||||
}
|
}
|
||||||
//auto box = n->m_clip;
|
//auto box = n->m_clip;
|
||||||
//glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
|
//glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
|
||||||
glm::vec2 parent_offset = n->m_parent ? n->m_parent->m_pos_offset_childred : glm::vec2(0.f);
|
glm::vec2 parent_offset = n->m_parent ? n->m_parent->m_pos_offset_childred : glm::vec2(0.f);
|
||||||
if (box.z <= parent_offset.x || box.w <= parent_offset.y)
|
if (box.z <= 0 || box.w <= 0)
|
||||||
{
|
{
|
||||||
if (n->m_on_screen)
|
if (n->m_on_screen)
|
||||||
{
|
{
|
||||||
|
|||||||
16
src/node.cpp
16
src/node.cpp
@@ -1077,8 +1077,13 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
|
|||||||
float w = YGNodeLayoutGetWidth(y_node);
|
float w = YGNodeLayoutGetWidth(y_node);
|
||||||
float h = YGNodeLayoutGetHeight(y_node);
|
float h = YGNodeLayoutGetHeight(y_node);
|
||||||
auto old_size = m_size;
|
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_pos_origin = /*glm::floor*/(origin + glm::vec2(x, y));
|
||||||
m_size = /*glm::floor*/(glm::vec2(w, h));
|
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::vec2 off_s(pr, pb);
|
||||||
glm::vec4 pclip = { xy(m_parent->m_clip) + off_p, zw(m_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_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
|
else
|
||||||
{
|
{
|
||||||
@@ -1118,7 +1123,10 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : m_children)
|
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(),
|
m_children.erase(std::remove_if(m_children.begin(), m_children.end(),
|
||||||
[](const auto& n) { return n->m_destroyed; }), m_children.end());
|
[](const auto& n) { return n->m_destroyed; }), m_children.end());
|
||||||
|
|||||||
@@ -109,10 +109,6 @@ void NodePanelAnimation::load_layers()
|
|||||||
auto& layers = Canvas::I->m_layers;
|
auto& layers = Canvas::I->m_layers;
|
||||||
m_selected_frame = nullptr;
|
m_selected_frame = nullptr;
|
||||||
|
|
||||||
float max_width = find("hscroll")->GetWidth() - 2;
|
|
||||||
for (int i = 0; i < layers.size(); i++)
|
|
||||||
max_width = glm::max(max_width, layers[i]->total_duration() * 35.f);
|
|
||||||
|
|
||||||
for (int i = 0; i < layers.size(); i++)
|
for (int i = 0; i < layers.size(); i++)
|
||||||
{
|
{
|
||||||
auto l = m_layers_container->add_child<NodeAnimationLayer>();
|
auto l = m_layers_container->add_child<NodeAnimationLayer>();
|
||||||
@@ -120,8 +116,6 @@ void NodePanelAnimation::load_layers()
|
|||||||
l->set_selected(Canvas::I->m_current_layer_idx == i);
|
l->set_selected(Canvas::I->m_current_layer_idx == i);
|
||||||
l->set_chekcbox(layers[i]->m_visible);
|
l->set_chekcbox(layers[i]->m_visible);
|
||||||
auto film = m_frames_container->add_child_ref<NodeAnimationFilm>();
|
auto film = m_frames_container->add_child_ref<NodeAnimationFilm>();
|
||||||
//film->m_color = glm::vec4(glm::vec3(i % 2 ? .8 : .7), 1);
|
|
||||||
film->SetWidth(max_width - 5);
|
|
||||||
for (int fi = 0; fi < layers[i]->m_frames.size(); fi++)
|
for (int fi = 0; fi < layers[i]->m_frames.size(); fi++)
|
||||||
{
|
{
|
||||||
auto b = film->add_frame(layers[i]->m_frames[fi].m_duration);
|
auto b = film->add_frame(layers[i]->m_frames[fi].m_duration);
|
||||||
@@ -146,7 +140,6 @@ void NodePanelAnimation::load_layers()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_timeline->SetWidth(max_width - 4);
|
|
||||||
m_timeline->m_frame = Canvas::I->m_anim_frame;
|
m_timeline->m_frame = Canvas::I->m_anim_frame;
|
||||||
m_timeline->m_onion_size = m_onion->get_int();
|
m_timeline->m_onion_size = m_onion->get_int();
|
||||||
update_frames();
|
update_frames();
|
||||||
@@ -159,18 +152,6 @@ void NodePanelAnimation::update_frames()
|
|||||||
m_frame_label->set_text_format("%0*d/%d", digits, m_timeline->m_frame + 1, total_frames);
|
m_frame_label->set_text_format("%0*d/%d", digits, m_timeline->m_frame + 1, total_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodePanelAnimation::handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom)
|
|
||||||
{
|
|
||||||
parent::handle_resize(old_size, new_size, zoom);
|
|
||||||
auto& layers = Canvas::I->m_layers;
|
|
||||||
float max_width = find("hscroll")->GetWidth() - 2;
|
|
||||||
for (int i = 0; i < layers.size(); i++)
|
|
||||||
max_width = glm::max(max_width, layers[i]->total_duration() * 35.f);
|
|
||||||
for (auto& film : m_frames_container->m_children)
|
|
||||||
film->SetWidth(max_width - 5);
|
|
||||||
m_timeline->SetWidth(max_width - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodePanelAnimation::on_tick(float dt)
|
void NodePanelAnimation::on_tick(float dt)
|
||||||
{
|
{
|
||||||
parent::on_tick(dt);
|
parent::on_tick(dt);
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public:
|
|||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual void added(Node* parent) override;
|
virtual void added(Node* parent) override;
|
||||||
virtual void on_tick(float dt) override;
|
virtual void on_tick(float dt) override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
|
||||||
|
|
||||||
void init_controls();
|
void init_controls();
|
||||||
void load_layers();
|
void load_layers();
|
||||||
|
|||||||
@@ -286,6 +286,9 @@ bool NodePanelBrush::restore()
|
|||||||
{
|
{
|
||||||
f.read_all();
|
f.read_all();
|
||||||
|
|
||||||
|
if (f.m_len == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
BinaryStreamReader sr;
|
BinaryStreamReader sr;
|
||||||
sr.init(f.m_data, f.m_len);
|
sr.init(f.m_data, f.m_len);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Node* NodeScroll::clone_instantiate() const
|
|||||||
void NodeScroll::fix_scroll()
|
void NodeScroll::fix_scroll()
|
||||||
{
|
{
|
||||||
auto pad = GetPadding();
|
auto pad = GetPadding();
|
||||||
glm::vec2 padoff = { pad.y + pad.w, pad.x + pad.z };
|
glm::vec2 padoff = { pad[1] + pad[3], pad[0] + pad[2] };
|
||||||
auto rect = get_children_rect();
|
auto rect = get_children_rect();
|
||||||
if (rect.w > 0 && rect.z > 0)
|
if (rect.w > 0 && rect.z > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user