summaryrefslogtreecommitdiff
path: root/src/animator.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-09-26 23:44:35 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-09-26 23:44:35 +0200
commiteff2e4cc49bfadd9716f3ad65854b3b0ca309b74 (patch)
treebafa49f7efcf39e9057b8f006c14d7f3a2a53e2d /src/animator.hh
parent811e04305457108bc32d8895fd9bd274715d02fc (diff)
Animate job count changes
Diffstat (limited to 'src/animator.hh')
-rw-r--r--src/animator.hh60
1 files changed, 60 insertions, 0 deletions
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 <memory>
+
+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<Looper> const& looper);
+
+ virtual void start(std::shared_ptr<Animation> 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