Route animation timeline scrubbing through app core

This commit is contained in:
2026-06-05 00:28:06 +02:00
parent 59210c28ea
commit a9e12f2219
8 changed files with 194 additions and 5 deletions

View File

@@ -347,10 +347,13 @@ kEventResult NodeAnimationTimeline::handle_event(Event* e)
parent::handle_event(e);
static int signaled_frame = -1;
auto me = static_cast<MouseEvent*>(e);
auto ge = static_cast<GestureEvent*>(e);
auto update = [&](){
auto loc = me->m_pos - m_pos;
m_frame = glm::clamp((int)glm::floor(loc.x / 35.f), 0, Canvas::I->anim_duration() - 1);
const int total_duration = Canvas::I ? Canvas::I->anim_duration() : 0;
const auto scrub = pp::app::plan_animation_timeline_scrub(total_duration, loc.x);
if (!scrub)
return;
m_frame = scrub.value().target_frame;
if (on_frame_changed && signaled_frame != m_frame)
on_frame_changed(this, m_frame);
signaled_frame = m_frame;