Defer animation start so arrows don't start halfway materialized

Took 13 minutes
This commit is contained in:
Lukas Brübach 2026-08-12 00:25:03 +02:00
parent ccbdcc5f74
commit 52b769a98e
2 changed files with 12 additions and 1 deletions

View file

@ -178,7 +178,12 @@ void ArrowItem::startDrawAnimation()
strokeDurationMs = qBound(kMinStrokeDurationMs, centerLine.length() * kMsPerPixel, kMaxStrokeDurationMs);
glowFadeDurationMs = kGlowFadeDurationMs;
animationClock.start();
// The clock is started on the first animationEvent() tick so that t=0
// corresponds to the first rendered frame. Starting it here would count
// the time spent before the item's first paint (event-loop delays, bursts
// of arrows created together), making the arrow appear already partway
// drawn when it first shows up.
animationStarted = false;
drawProgress = 0.0;
glowAlpha = 1.0;
update();
@ -189,6 +194,11 @@ void ArrowItem::startDrawAnimation()
bool ArrowItem::animationEvent()
{
if (!animationStarted) {
animationClock.start();
animationStarted = true;
}
const qint64 elapsed = animationClock.elapsed();
if (elapsed >= strokeDurationMs + glowFadeDurationMs) {
drawProgress = 1.0;

View file

@ -33,6 +33,7 @@ private:
qreal glowFadeDurationMs = 0;
qreal drawProgress = 1.0;
qreal glowAlpha = 0.0;
bool animationStarted = false;
static constexpr qreal glowExtent = 12.0;