annotate src/subtree_free.c @ 1395:a768d74e5f49

Fix the svg:use. For a svg:use, it is a group which include the content it reference. It means that we can not tween it to its origin object directly. Instead, we need to ungroup it and then use the result matrix to generate the tweened transformation matrix. Therefore, we need to concate its matrix to the referenced object. Ad center object when the bbox-x is not available.
author wycc
date Sat, 02 Apr 2011 05:36:36 +0800
parents 586e50f82c1f
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 194
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 194
diff changeset
2 // vim: sw=4:ts=8:sts=4
194
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include "mb_redraw_man.h"
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #include "mb_animate.h"
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 struct _subtree_free {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 mb_action_t action;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 coord_t *coord;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 };
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 typedef struct _subtree_free subtree_free_t;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 void mb_subtree_free_start(mb_action_t *action,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 const mb_timeval_t *now,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 const mb_timeval_t *playing_time,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 redraw_man_t *rdman) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 subtree_free_t *sfree = (subtree_free_t *)action;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 rdman_coord_subtree_free(rdman, sfree->coord);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 void mb_subtree_free_step(mb_action_t *act, const mb_timeval_t *now,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 redraw_man_t *rdman) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 void mb_subtree_free_stop(mb_action_t *act, const mb_timeval_t *now,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 redraw_man_t *rdman) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 void mb_subtree_free_free(mb_action_t *act) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 free(act);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 mb_action_t *mb_subtree_free_new(coord_t *coord,
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 mb_word_t *word) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 subtree_free_t *sfree;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 sfree = (subtree_free_t *)malloc(sizeof(subtree_free_t));
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 if(sfree == NULL)
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 return NULL;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 sfree->action.start = mb_subtree_free_start;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 sfree->action.step = mb_subtree_free_step;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 sfree->action.stop = mb_subtree_free_stop;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 sfree->action.free = mb_subtree_free_free;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 sfree->coord = coord;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 mb_word_add_action(word, (mb_action_t *)sfree);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 return (mb_action_t *)sfree;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 }