comparison src/animate.c @ 57:ab028c9f0930

Ability to hidden shapes and action of visibility.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 10 Aug 2008 20:25:14 +0800
parents 59a295651480
children 8feb89b19619
comparison
equal deleted inserted replaced
56:e444a8c01735 57:ab028c9f0930
448 mb_word_add_action(word, (mb_action_t *)chg); 448 mb_word_add_action(word, (mb_action_t *)chg);
449 449
450 return (mb_action_t *)chg; 450 return (mb_action_t *)chg;
451 } 451 }
452 452
453
454 typedef struct _mb_visibility mb_visibility_t;
455
456 struct _mb_visibility {
457 mb_action_t action;
458 int visibility;
459 coord_t *coord;
460 };
461
462 static void mb_visibility_start(mb_action_t *act,
463 const mb_timeval_t *now,
464 const mb_timeval_t *playing_time,
465 redraw_man_t *rdman) {
466 mb_visibility_t *visibility = (mb_visibility_t *)act;
467
468 switch(visibility->visibility) {
469 case VIS_VISIBLE:
470 coord_show(visibility->coord);
471 break;
472 case VIS_HIDDEN:
473 coord_hide(visibility->coord);
474 break;
475 }
476 rdman_coord_changed(rdman, visibility->coord);
477 }
478
479 static void mb_visibility_step(mb_action_t *act,
480 const mb_timeval_t *now,
481 redraw_man_t *rdman) {
482 }
483
484 static void mb_visibility_stop(mb_action_t *act,
485 const mb_timeval_t *now,
486 redraw_man_t *rdman) {
487 }
488
489 static void mb_visibility_free(mb_action_t *act) {
490 free(act);
491 }
492
493 mb_action_t *mb_visibility_new(int visib, coord_t *coord,
494 mb_word_t *word) {
495 mb_visibility_t *visibility;
496
497 visibility = (mb_visibility_t *)malloc(sizeof(mb_visibility_t));
498 if(visibility == NULL)
499 return NULL;
500
501 visibility->visibility = visib;
502 visibility->coord = coord;
503
504 visibility->action.start = mb_visibility_start;
505 visibility->action.step = mb_visibility_step;
506 visibility->action.stop = mb_visibility_stop;
507 visibility->action.free = mb_visibility_free;
508
509 mb_word_add_action(word, (mb_action_t *)visibility);
510
511 return (mb_action_t *)visibility;
512 }
513
453 #ifdef UNITTEST 514 #ifdef UNITTEST
454 515
455 #include <CUnit/Basic.h> 516 #include <CUnit/Basic.h>
456 517
457 typedef struct _mb_dummy mb_dummy_t; 518 typedef struct _mb_dummy mb_dummy_t;