Mercurial > MadButterfly
annotate src/animate.h @ 127:d2cc7400c971
Bug of subject_notify() when free subjects.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 16 Sep 2008 16:06:04 +0800 |
parents | 9e2316dc6ecb |
children | 3a4d6179e6a9 |
rev | line source |
---|---|
41 | 1 #ifndef __ANIMATE_H_ |
2 #define __ANIMATE_H_ | |
3 | |
42 | 4 #include "mb_types.h" |
5 #include "mb_timer.h" | |
52
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
47
diff
changeset
|
6 #include "paint.h" |
42 | 7 |
117 | 8 /*! \page def_action How to Define An Action? |
116
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
9 * |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
10 * A action must implement following 4 functions. |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
11 * \li start, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
12 * \li step, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
13 * \li stop, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
14 * \li free, and |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
15 * \li *_new(). |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
16 * |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
17 * *_new() must invokes mb_word_add_action() to add new object |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
18 * as one of actions in the word specified as an argument of it. |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
19 * It also means *_new() must have an argument with type of |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
20 * (mb_word_t *). |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
21 */ |
117 | 22 |
23 /*! \defgroup anim Animation | |
24 * \brief Animation is a set of functions to make graph moving. | |
25 * @{ | |
26 */ | |
27 typedef struct _mb_progm mb_progm_t; | |
28 typedef struct _mb_word mb_word_t; | |
29 typedef struct _mb_action mb_action_t; | |
30 | |
123
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
31 struct _mb_progm_complete { |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
32 event_t event; |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
33 mb_progm_t *progm; |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
34 }; |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
35 typedef struct _mb_progm_complete mb_progm_complete_t; |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
36 |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
37 extern mb_progm_t *mb_progm_new(int max_words, redraw_man_t *rdman); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
38 extern void mb_progm_free(mb_progm_t *progm); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
39 extern mb_word_t *mb_progm_next_word(mb_progm_t *progm, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
40 const mb_timeval_t *start, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
41 const mb_timeval_t *playing); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
42 extern void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
43 mb_timeval_t *now); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
44 extern void mb_progm_abort(mb_progm_t *progm, mb_tman_t *tman); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
45 extern subject_t *mb_progm_get_complete(mb_progm_t *progm); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
46 |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
47 /*! \defgroup ani_actions Animation Actions |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
48 * @{ |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
49 */ |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
50 extern mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
51 mb_word_t *word); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
52 extern mb_action_t *mb_chgcolor_new(co_comp_t r, co_comp_t g, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
53 co_comp_t b, co_comp_t a, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
54 paint_t *paint, mb_word_t *word); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
55 extern mb_action_t *mb_rotate_new(float angle1, float angle2, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
56 coord_t *coord, mb_word_t *word); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
57 |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
58 enum { VIS_VISIBLE, VIS_HIDDEN }; |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
59 extern mb_action_t *mb_visibility_new(int visib, coord_t *coord, |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
60 mb_word_t *word); |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
61 /* @} */ |
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
62 |
117 | 63 /*! \defgroup act_support Action Supports. |
64 * @{ | |
65 */ | |
123
9e2316dc6ecb
Program completion events
Thinker K.F. Li <thinker@branda.to>
parents:
117
diff
changeset
|
66 /*! \brief Basic class of animation actions. |
117 | 67 * |
68 * \sa \ref def_action | |
69 */ | |
116
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
70 struct _mb_action { |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
71 void (*start)(mb_action_t *act, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
72 const mb_timeval_t *now, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
73 const mb_timeval_t *playing_time, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
74 redraw_man_t *rdman); |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
75 void (*step)(mb_action_t *act, const mb_timeval_t *now, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
76 redraw_man_t *rdman); |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
77 void (*stop)(mb_action_t *act, const mb_timeval_t *now, |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
78 redraw_man_t *rdman); |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
79 void (*free)(mb_action_t *act); |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
80 mb_action_t *next; |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
81 }; |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
82 |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
83 extern void mb_word_add_action(mb_word_t *word, mb_action_t *act); |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
84 /* @} */ |
1d74eb3861b7
move animation actions from animate.c to files.
Thinker K.F. Li <thinker@branda.to>
parents:
104
diff
changeset
|
85 |
101 | 86 /* @} */ |
41 | 87 |
88 #endif /* __ANIMATE_H_ */ |