gameui

view src/boolanm.h @ 2:e5b1525084f7

boolanim
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 20 Mar 2014 07:03:58 +0200
parents
children f1014234dece
line source
1 #ifndef BOOLANIM_H_
2 #define BOOLANIM_H_
4 class BoolAnim {
5 private:
6 mutable float value;
7 mutable float trans_dir; // transition direction (sign)
8 long trans_start; // transition start time
9 long trans_dur;
11 long (*get_msec)();
13 void update(long tm) const;
15 public:
16 BoolAnim(bool st = false);
18 void set_transition_duration(long dur);
19 void set_time_callback(long (*time_func)());
21 void change(bool st);
22 void change(bool st, long trans_start);
24 bool get_state() const;
25 bool get_state(long tm) const;
27 float get_value() const;
28 float get_value(long tm) const;
30 // transition direction (-1, 0, 1)
31 float get_dir() const;
32 float get_dir(long tm) const;
34 operator bool() const; // equivalent to get_state
35 operator float() const; // equivalent to get_value
36 };
38 #endif // BOOLANIM_H_