changeset 47:f3818d996f4f

change interface of creating a animation action
author Thinker K.F. Li <thinker@branda.to>
date Sat, 09 Aug 2008 16:41:33 +0800
parents 46b77c92d118
children bdf711cbf0fb
files src/X_main.c src/animate.c src/animate.h
diffstat 3 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/X_main.c	Sat Aug 09 16:33:33 2008 +0800
+++ b/src/X_main.c	Sat Aug 09 16:41:33 2008 +0800
@@ -306,24 +306,20 @@
 	MB_TIMEVAL_SET(&start, 1, 0);
 	MB_TIMEVAL_SET(&playing, 2, 0);
 	word = mb_progm_next_word(progm, &start, &playing);
-	act = mb_shift_new(0, 20, coord1);
-	mb_word_add_action(word, act);
+	act = mb_shift_new(0, 20, coord1, word);
 	
 	MB_TIMEVAL_SET(&start, 3, 0);
 	MB_TIMEVAL_SET(&playing, 2, 0);
-	act = mb_shift_new(0, 20, coord2);
-	mb_word_add_action(word, act);
+	act = mb_shift_new(0, 20, coord2, word);
 	
 	MB_TIMEVAL_SET(&start, 3, 0);
 	MB_TIMEVAL_SET(&playing, 2, 0);
 	word = mb_progm_next_word(progm, &start, &playing);
-	act = mb_shift_new(0, -20, coord1);
-	mb_word_add_action(word, act);
+	act = mb_shift_new(0, -20, coord1, word);
 	
 	MB_TIMEVAL_SET(&start, 3, 0);
 	MB_TIMEVAL_SET(&playing, 2, 0);
-	act = mb_shift_new(0, -20, coord2);
-	mb_word_add_action(word, act);
+	act = mb_shift_new(0, -20, coord2, word);
 	
 	gettimeofday(&tv, NULL);
 	MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec);
--- a/src/animate.c	Sat Aug 09 16:33:33 2008 +0800
+++ b/src/animate.c	Sat Aug 09 16:41:33 2008 +0800
@@ -120,7 +120,7 @@
     return word;
 }
 
-void mb_word_add_action(mb_word_t *word, mb_action_t *act) {
+static void mb_word_add_action(mb_word_t *word, mb_action_t *act) {
     STAILQ_INS_TAIL(word->actions, mb_action_t, next, act);
 }
 
@@ -323,7 +323,8 @@
     free(act);
 }
 
-mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord) {
+mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord,
+			  mb_word_t *word) {
     mb_shift_t *shift;
 
     shift = (mb_shift_t *)malloc(sizeof(mb_shift_t));
@@ -339,5 +340,7 @@
     shift->action.stop = mb_shift_stop;
     shift->action.free = mb_shift_free;
 
+    mb_word_add_action(word, (mb_action_t *)shift);
+
     return (mb_action_t *)shift;
 }
--- a/src/animate.h	Sat Aug 09 16:33:33 2008 +0800
+++ b/src/animate.h	Sat Aug 09 16:41:33 2008 +0800
@@ -14,11 +14,11 @@
 extern mb_word_t *mb_progm_next_word(mb_progm_t *progm,
 				     const mb_timeval_t *start,
 				     const mb_timeval_t *playing);
-extern void mb_word_add_action(mb_word_t *word, mb_action_t *act);
 extern void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman,
 			   mb_timeval_t *now);
 extern void mb_progm_abort(mb_progm_t *progm, mb_tman_t *tman);
-extern mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord);
+extern mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord,
+				 mb_word_t *word);
 
 
 #endif /* __ANIMATE_H_ */