gameui

view src/boolanm.h @ 3:f1014234dece

transitions in gui elements are awesome :)
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 21 Mar 2014 03:37:16 +0200
parents e5b1525084f7
children
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 set(bool st);
23 void change(bool st);
24 void change(bool st, long trans_start);
26 bool get_state() const;
27 bool get_state(long tm) const;
29 float get_value() const;
30 float get_value(long tm) const;
32 // transition direction (-1, 0, 1)
33 float get_dir() const;
34 float get_dir(long tm) const;
36 operator bool() const; // equivalent to get_state
37 operator float() const; // equivalent to get_value
38 };
40 #endif // BOOLANIM_H_