Add animation playback toggle boundary
This commit is contained in:
@@ -96,6 +96,36 @@ void NodePanelAnimation::execute_animation_plan(const pp::app::DocumentAnimation
|
||||
panel_.m_timeline->m_onion_size = onion_size;
|
||||
}
|
||||
|
||||
void capture_playback_restore_mode() override
|
||||
{
|
||||
playback_restore_mode() = Canvas::I->m_current_mode;
|
||||
}
|
||||
|
||||
void enter_playback_camera_mode() override
|
||||
{
|
||||
Canvas::set_mode(kCanvasMode::Camera);
|
||||
}
|
||||
|
||||
void restore_playback_canvas_mode() override
|
||||
{
|
||||
Canvas::set_mode(playback_restore_mode());
|
||||
}
|
||||
|
||||
void set_playback_active(bool active) override
|
||||
{
|
||||
panel_.btn_play->set_active(active);
|
||||
}
|
||||
|
||||
void reset_playback_timer() override
|
||||
{
|
||||
panel_.m_playback_timer = 0;
|
||||
}
|
||||
|
||||
void set_playback_idle_ms(int idle_ms) override
|
||||
{
|
||||
App::I->idle_ms = idle_ms;
|
||||
}
|
||||
|
||||
void update_canvas_animation() override
|
||||
{
|
||||
Canvas::I->anim_update();
|
||||
@@ -117,6 +147,12 @@ void NodePanelAnimation::execute_animation_plan(const pp::app::DocumentAnimation
|
||||
}
|
||||
|
||||
private:
|
||||
static kCanvasMode& playback_restore_mode()
|
||||
{
|
||||
static auto mode = Canvas::I->m_current_mode;
|
||||
return mode;
|
||||
}
|
||||
|
||||
NodePanelAnimation& panel_;
|
||||
Layer* layer_ = nullptr;
|
||||
};
|
||||
@@ -258,23 +294,10 @@ void NodePanelAnimation::init_controls()
|
||||
return;
|
||||
execute_animation_plan(plan.value());
|
||||
};
|
||||
btn_play->on_click = [this] (Node* target) {
|
||||
static auto mode = Canvas::I->m_current_mode;
|
||||
auto b = static_cast<NodeButtonCustom*>(target);
|
||||
if (b->is_active())
|
||||
{
|
||||
Canvas::set_mode(mode);
|
||||
b->set_active(false);
|
||||
App::I->idle_ms = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = Canvas::I->m_current_mode;
|
||||
Canvas::set_mode(kCanvasMode::Camera);
|
||||
m_playback_timer = 0;
|
||||
b->set_active(true);
|
||||
App::I->idle_ms = 10;
|
||||
}
|
||||
btn_play->on_click = [this] (Node*) {
|
||||
const auto plan = pp::app::plan_animation_playback_toggle(btn_play->is_active());
|
||||
if (plan)
|
||||
execute_animation_plan(plan.value());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user