comparison src/visibility.c @ 116:1d74eb3861b7

move animation actions from animate.c to files.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 14 Sep 2008 09:42:07 +0800
parents
children c7e5b8779bb5
comparison
equal deleted inserted replaced
115:3895d2224e67 116:1d74eb3861b7
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "animate.h"
4
5 typedef struct _mb_visibility mb_visibility_t;
6
7 struct _mb_visibility {
8 mb_action_t action;
9 int visibility;
10 coord_t *coord;
11 };
12
13 static void mb_visibility_start(mb_action_t *act,
14 const mb_timeval_t *now,
15 const mb_timeval_t *playing_time,
16 redraw_man_t *rdman) {
17 mb_visibility_t *visibility = (mb_visibility_t *)act;
18
19 switch(visibility->visibility) {
20 case VIS_VISIBLE:
21 coord_show(visibility->coord);
22 break;
23 case VIS_HIDDEN:
24 coord_hide(visibility->coord);
25 break;
26 }
27 rdman_coord_changed(rdman, visibility->coord);
28 }
29
30 static void mb_visibility_step(mb_action_t *act,
31 const mb_timeval_t *now,
32 redraw_man_t *rdman) {
33 }
34
35 static void mb_visibility_stop(mb_action_t *act,
36 const mb_timeval_t *now,
37 redraw_man_t *rdman) {
38 }
39
40 static void mb_visibility_free(mb_action_t *act) {
41 free(act);
42 }
43
44 mb_action_t *mb_visibility_new(int visib, coord_t *coord,
45 mb_word_t *word) {
46 mb_visibility_t *visibility;
47
48 visibility = (mb_visibility_t *)malloc(sizeof(mb_visibility_t));
49 if(visibility == NULL)
50 return NULL;
51
52 visibility->visibility = visib;
53 visibility->coord = coord;
54
55 visibility->action.start = mb_visibility_start;
56 visibility->action.step = mb_visibility_step;
57 visibility->action.stop = mb_visibility_stop;
58 visibility->action.free = mb_visibility_free;
59
60 mb_word_add_action(word, (mb_action_t *)visibility);
61
62 return (mb_action_t *)visibility;
63 }
64