From ae2eb2a25f8f9a6f277597a8391274b8e7c4f1a7 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Tue, 24 Dec 2019 17:29:30 +0100 Subject: [PATCH] ImageScrollerAnimation: faster stop by default Waiting until the text has scrolled by completely is still possible, but must be activated on object construction by a special argument. --- include/Animation/ImageScrollerAnimation.h | 4 +++- src/Animation/ImageScrollerAnimation.cpp | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/Animation/ImageScrollerAnimation.h b/include/Animation/ImageScrollerAnimation.h index fde7c79..c2d73bc 100644 --- a/include/Animation/ImageScrollerAnimation.h +++ b/include/Animation/ImageScrollerAnimation.h @@ -10,7 +10,7 @@ class ImageScrollerAnimation : public Animation { public: - ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval = 3); + ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval = 3, bool finish_scrolling = false); void loop(uint64_t frame) override; @@ -27,5 +27,7 @@ class ImageScrollerAnimation : public Animation int32_t m_startIdx; uint32_t m_interval; + bool m_finishScrolling; + bool m_stopping; }; diff --git a/src/Animation/ImageScrollerAnimation.cpp b/src/Animation/ImageScrollerAnimation.cpp index 72009c4..1ca374e 100644 --- a/src/Animation/ImageScrollerAnimation.cpp +++ b/src/Animation/ImageScrollerAnimation.cpp @@ -2,10 +2,11 @@ #include -ImageScrollerAnimation::ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval) +ImageScrollerAnimation::ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval, bool finish_scrolling) : Animation(fader), m_image(*image), - m_interval(interval) + m_interval(interval), + m_finishScrolling(finish_scrolling) { reset(); } @@ -19,6 +20,14 @@ void ImageScrollerAnimation::loop(uint64_t frame) return; } + if(m_stopping && !m_finishScrolling) { + m_fader->set_fadestep(3); + m_fader->fade_color(Fader::Color{0, 0, 0, 0}); + + m_running = false; + return; + } + // blit the image m_fader->set_color(Fader::Color{0, 0, 0, 0});