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.
This commit is contained in:
Thomas Kolb 2019-12-24 17:29:30 +01:00
parent 96e29061a2
commit ae2eb2a25f
2 changed files with 14 additions and 3 deletions

View file

@ -10,7 +10,7 @@
class ImageScrollerAnimation : public Animation class ImageScrollerAnimation : public Animation
{ {
public: 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; void loop(uint64_t frame) override;
@ -27,5 +27,7 @@ class ImageScrollerAnimation : public Animation
int32_t m_startIdx; int32_t m_startIdx;
uint32_t m_interval; uint32_t m_interval;
bool m_finishScrolling;
bool m_stopping; bool m_stopping;
}; };

View file

@ -2,10 +2,11 @@
#include <iostream> #include <iostream>
ImageScrollerAnimation::ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval) ImageScrollerAnimation::ImageScrollerAnimation(Fader *fader, Bitmap *image, uint32_t interval, bool finish_scrolling)
: Animation(fader), : Animation(fader),
m_image(*image), m_image(*image),
m_interval(interval) m_interval(interval),
m_finishScrolling(finish_scrolling)
{ {
reset(); reset();
} }
@ -19,6 +20,14 @@ void ImageScrollerAnimation::loop(uint64_t frame)
return; 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 // blit the image
m_fader->set_color(Fader::Color{0, 0, 0, 0}); m_fader->set_color(Fader::Color{0, 0, 0, 0});