fix scroll node, improve animation panel
This commit is contained in:
@@ -26,7 +26,8 @@ void NodePanelAnimation::init()
|
||||
|
||||
void NodePanelAnimation::init_controls()
|
||||
{
|
||||
m_container = find<NodeScroll>("container");
|
||||
m_layers_container = find<NodeScroll>("layers");
|
||||
m_frames_container = find<NodeScroll>("frames");
|
||||
m_timeline = find<NodeAnimationTimeline>("timeline");
|
||||
btn_add = find<NodeButtonCustom>("btn-add");
|
||||
btn_remove = find<NodeButtonCustom>("btn-remove");
|
||||
@@ -62,23 +63,30 @@ void NodePanelAnimation::load_layers()
|
||||
{
|
||||
if (!added_to_root())
|
||||
return;
|
||||
m_container->remove_all_children();
|
||||
m_layers_container->remove_all_children();
|
||||
m_frames_container->remove_all_children();
|
||||
auto& layers = Canvas::I->m_layers;
|
||||
m_selected_frame = nullptr;
|
||||
float max_width = 0;
|
||||
for (int i = 0; i < layers.size(); i++)
|
||||
{
|
||||
auto l = m_container->add_child<NodeAnimationLayer>();
|
||||
auto l = m_layers_container->add_child<NodeAnimationLayer>();
|
||||
l->set_text(layers[i]->m_name);
|
||||
l->set_selected(Canvas::I->m_current_layer_idx == i);
|
||||
l->set_chekcbox(layers[i]->m_visible);
|
||||
auto film = m_frames_container->add_child_ref<NodeAnimationFilm>();
|
||||
film->SetWidth(layers[i]->total_duration() * 35.f);
|
||||
max_width = glm::max(max_width, layers[i]->total_duration() * 35.f);
|
||||
for (int fi = 0; fi < layers[i]->m_frames.size(); fi++)
|
||||
{
|
||||
auto b = l->add_frame(layers[i]->m_frames[fi].m_duration);
|
||||
auto b = film->add_frame(layers[i]->m_frames[fi].m_duration);
|
||||
|
||||
if (m_selected_frame_layer_id == layers[i]->id && m_selected_frame_index == fi)
|
||||
{
|
||||
b->set_active(true);
|
||||
m_selected_frame = b.get();
|
||||
}
|
||||
|
||||
b->on_click = [this, fi, lid=layers[i]->id, i] (Node* target) {
|
||||
auto frame = static_cast<NodeAnimationFrame*>(target);
|
||||
if (m_selected_frame)
|
||||
@@ -91,6 +99,7 @@ void NodePanelAnimation::load_layers()
|
||||
};
|
||||
}
|
||||
}
|
||||
m_timeline->SetWidth(max_width);
|
||||
}
|
||||
|
||||
void NodePanelAnimation::added(Node* parent)
|
||||
@@ -124,7 +133,6 @@ void NodeAnimationLayer::init_controls()
|
||||
{
|
||||
m_label = find<NodeText>("label");
|
||||
m_visibility = find<NodeCheckBox>("cb");
|
||||
m_container = find<NodeScroll>("container");
|
||||
}
|
||||
|
||||
void NodeAnimationLayer::draw()
|
||||
@@ -135,15 +143,9 @@ void NodeAnimationLayer::draw()
|
||||
parent::draw();
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeAnimationFrame> NodeAnimationLayer::add_frame(int duration)
|
||||
{
|
||||
auto b = m_container->add_child_ref<NodeAnimationFrame>();
|
||||
b->SetWidth(30 * duration + 5 * (duration - 1));
|
||||
//b->SetFlexGrow(duration);
|
||||
b->SetHeightP(100);
|
||||
b->SetMargin(0, 5, 0, 0);
|
||||
return b;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user