Mercurial > MadButterfly
comparison src/event.c @ 241:104d83378582
Add scene support in svg2code.py.
- Add mb_sprite_t::goto_scene()
- svg2code.py recoganize "scenes" tag in metadata of SVG file.
- tranform scenes into SCENE() macro.
- define SCENE macro in mb_c_*.m4
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 31 Dec 2008 02:08:40 +0800 |
parents | 65cabbdd5284 |
children | bd8ea44b421e |
comparison
equal
deleted
inserted
replaced
240:d347a577a232 | 241:104d83378582 |
---|---|
53 typedef struct _area area_t; | 53 typedef struct _area area_t; |
54 struct _area { | 54 struct _area { |
55 co_aix x, y; | 55 co_aix x, y; |
56 co_aix w, h; | 56 co_aix w, h; |
57 }; | 57 }; |
58 #define range_overlay(as, aw, bs, bw) \ | |
59 (((bs) - (as)) <= (aw) || ((as) - (bs)) <= (bw)) | |
60 #define areas_are_overlay(a1, a2) \ | |
61 (range_overlay((a1)->x, (a1)->w, \ | |
62 (a2)->x, (a2)->w) && \ | |
63 range_overlay((a1)->y, (a1)->h, \ | |
64 (a2)->y, (a2)->h)) | |
58 | 65 |
59 struct mb_obj { | 66 struct mb_obj { |
60 int obj_type; | 67 int obj_type; |
61 }; | 68 }; |
62 typedef struct mb_obj mb_obj_t; | 69 typedef struct mb_obj mb_obj_t; |
65 #define GEF_HIDDEN 0x2 | 72 #define GEF_HIDDEN 0x2 |
66 | 73 |
67 struct shape { | 74 struct shape { |
68 mb_obj_t obj; | 75 mb_obj_t obj; |
69 | 76 |
77 area_t area; | |
78 | |
70 void *fill, *stroke; | 79 void *fill, *stroke; |
71 struct shape *sibling; | 80 struct shape *sibling; |
72 int flags; | 81 int flags; |
73 | 82 |
74 int num_points; | 83 int num_points; |
93 return FALSE; | 102 return FALSE; |
94 } | 103 } |
95 #define sh_get_flags(shape, mask) ((shape)->flags & mask) | 104 #define sh_get_flags(shape, mask) ((shape)->flags & mask) |
96 #define sh_set_flags(shape, mask) do { (shape)->flags |= mask; } while(0) | 105 #define sh_set_flags(shape, mask) do { (shape)->flags |= mask; } while(0) |
97 #define sh_clear_flags(shape, mask) do { (shape)->flags &= ~(mask); } while(0) | 106 #define sh_clear_flags(shape, mask) do { (shape)->flags &= ~(mask); } while(0) |
107 #define sh_get_area(shape) (&(shape)->area) | |
98 | 108 |
99 typedef struct coord coord_t; | 109 typedef struct coord coord_t; |
100 struct coord { | 110 struct coord { |
101 mb_obj_t obj; | 111 mb_obj_t obj; |
102 | 112 |
113 area_t area; | |
114 int flags; | |
115 coord_t *parent; | |
103 coord_t *children; | 116 coord_t *children; |
104 coord_t *sibling; | 117 coord_t *sibling; |
105 shape_t *shapes; | 118 shape_t *shapes; |
106 }; | 119 }; |
107 | 120 |
121 #define COF_SKIP 0x1 | |
122 | |
123 #define coord_get_area(coord) (&(coord)->area) | |
124 #define FOR_COORD_SHAPES(coord, shape) \ | |
125 for(shape = (coord)->shapes; \ | |
126 shape != NULL; \ | |
127 shape = (shape)->sibling) | |
128 #define FOR_COORDS_PREORDER(root, last) \ | |
129 for(last = root; \ | |
130 last != NULL; \ | |
131 last = preorder_coord_subtree(root, last)) | |
132 | |
133 static | |
134 coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) { | |
135 if(last->children) | |
136 return last->children; | |
137 while(last->sibling == NULL) | |
138 last = last->parent; | |
139 return last->sibling; | |
140 } | |
108 | 141 |
109 static | 142 static |
110 coord_t *postorder_coord_subtree(coord_t *root, coord_t *last) { | 143 coord_t *postorder_coord_subtree(coord_t *root, coord_t *last) { |
111 if(last == NULL) | 144 coord_t *cur; |
112 return root; | 145 |
146 if(last != NULL) { | |
147 if(last->sibling == NULL) { | |
148 cur = last->parent; | |
149 return cur; | |
150 } | |
151 cur = last->sibling; | |
152 } | |
153 | |
154 cur = last; | |
155 while(cur->children) { | |
156 cur = cur->children; | |
157 } | |
158 return cur; | |
113 } | 159 } |
114 | 160 |
115 #define sh_path_draw(path, cr) | 161 #define sh_path_draw(path, cr) |
116 #define sh_text_draw(path, cr) | 162 #define sh_text_draw(path, cr) |
117 #define sh_rect_draw(path, cr) | 163 #define sh_rect_draw(path, cr) |