From eff2e4cc49bfadd9716f3ad65854b3b0ca309b74 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 26 Sep 2017 23:44:35 +0200 Subject: Animate job count changes --- src/animator.hh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/animator.hh (limited to 'src/animator.hh') diff --git a/src/animator.hh b/src/animator.hh new file mode 100644 index 0000000..c8072ac --- /dev/null +++ b/src/animator.hh @@ -0,0 +1,60 @@ +#ifndef ANIMATOR_HH +#define ANIMATOR_HH + +#include + +class Animation; +class Looper; + +class Animator { +public: + class Observer { + public: + virtual ~Observer() {} + + // Called after all active animations callbacks has been called. + // Not called if there are no active animations. + virtual void tick(Animator* animator) = 0; + + protected: + Observer() {} + }; + + class AnimationObserver { + public: + virtual ~AnimationObserver() {} + + // Called after the animation has been updated with the new value + virtual void ticked(Animator* animator, Animation* animation, + double value) = 0; + // Called after the animation stopped, either because stop() was called + // or because animation->tick() return false. + // If animation->tick() returned false ticked method above is always called + // first + virtual void stopped(Animator* animator, Animation* animation) = 0; + + protected: + AnimationObserver() {} + }; + + virtual ~Animator() {} + + static Animator* create(std::shared_ptr const& looper); + + virtual void start(std::shared_ptr const& animation, + AnimationObserver* observer) = 0; + virtual bool observe(Animation* animation, AnimationObserver* observer) = 0; + virtual bool stop(Animation* animation) = 0; + virtual bool active(Animation* animation) const = 0; + virtual bool active() const = 0; + + virtual void add_observer(Observer* observer) = 0; + virtual void remove_observer(Observer* observer) = 0; + +protected: + Animator() {} + Animator(Animator const&) = delete; + Animator& operator=(Animator const&) = delete; +}; + +#endif // ANIMATOR_HH -- cgit v1.3