Mercurial > MadButterfly
annotate include/mb_types.h @ 410:1a923ea699c1
shape_stext.c, now, is unittested.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 08 Jul 2009 21:12:14 +0800 |
parents | 27774b93521e |
children | 16116d84bc5e |
rev | line source |
---|---|
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #ifndef __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #define __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
4 #include <cairo.h> |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
5 #include "mb_tools.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
6 #include "mb_observer.h" |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
7 #include "mb_prop.h" |
12 | 8 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 typedef float co_aix; |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
10 typedef struct _shape shape_t; |
12 | 11 typedef struct _geo geo_t; |
13 | 12 typedef struct _area area_t; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
13 typedef struct _shnode shnode_t; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
14 typedef struct _paint paint_t; |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
15 typedef struct _mb_obj mb_obj_t; |
208 | 16 typedef struct _mb_sprite mb_sprite_t; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
17 /*! \todo Replace cairo_t with canvas_t. */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
18 typedef cairo_t canvas_t; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
19 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
20 struct _redraw_man; |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
21 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
22 /* \defgroup mb_obj_grp Object type |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
23 * @{ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
24 */ |
204 | 25 /*! \brief MadButterfly object. |
26 * | |
27 * All objects (coord and shapes) should have mb_obj_t as first member | |
28 * variable. obj_type is used to identify type of an object. Please, | |
29 * use MBO_TYPE() to return this value. MBO_TYPE() will type-casting the | |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
30 * object to mb_obj_t and return obj_type. |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
31 * |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
32 * mb_obj_t should be initialized with mb_obj_init() and destroied with |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
33 * mb_obj_destroy(). |
303
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
34 * |
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
35 * We have defined a set of convienent API which will wrap the coord_t or shape_t API accoridng to its type. |
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
36 * Please refer to http://www.assembla.com/wiki/show/dFrSMOtDer3BZUab7jnrAJ/MBAF_Object for the details. This |
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
37 * API is designed for regular programmers which can be used to change some common properties of objects without |
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
38 * checking its type. |
204 | 39 */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
40 struct _mb_obj { |
204 | 41 int obj_type; /*!< \brief Type of a MadButterfly object. */ |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
42 mb_prop_store_t props; /*!< Initialized by rdman. */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
43 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
44 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
45 enum { MBO_DUMMY, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
46 MBO_COORD, |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
47 MBO_SHAPES=0x1000, /*! \note Don't touch this. */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
48 MBO_PATH, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
49 MBO_TEXT, |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
250
diff
changeset
|
50 MBO_RECT, |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
51 MBO_IMAGE, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
52 MBO_STEXT |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
53 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
54 #define MBO_CLASS_MASK 0xf000 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
55 #define MBO_CLASS(x) (((mb_obj_t *)(x))->obj_type & MBO_CLASS_MASK) |
204 | 56 /*! \brief Return type of a MadBufferly object. */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
57 #define MBO_TYPE(x) (((mb_obj_t *)(x))->obj_type) |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
58 #define IS_MBO_SHAPES(obj) (MBO_CLASS(obj) == MBO_SHAPES) |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
59 #define IS_MBO_COORD(obj) (MBO_TYPE(obj) == MBO_COORD) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
60 #define mb_obj_init(obj, type) \ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
61 do { \ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
62 ((mb_obj_t *)(obj))->obj_type = type; \ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
63 } while(0) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
64 #define mb_obj_destroy(obj) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
65 #define mb_obj_prop_store(obj) (&(obj)->props) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
66 |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
67 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
68 /* @} */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
69 |
58 | 70 /*! \brief Base of paint types. |
71 * | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
72 * Paints should be freed by users by calling rdman_paint_free() of |
58 | 73 * the paint. |
74 * | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
75 * To define a foo paint, it should define a rdman_paint_foo_new() |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
76 * function. It return a paint object. |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
77 * |
58 | 78 * \todo move member functions to a seperate structure and setup a |
189
257af0ed5852
When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents:
186
diff
changeset
|
79 * singleton for each paint type. |
58 | 80 */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
81 struct _paint { |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
82 int pnt_type; |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
83 int flags; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
84 void (*prepare)(paint_t *paint, cairo_t *cr); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
85 void (*free)(struct _redraw_man *rdman, paint_t *paint); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
86 STAILQ(shnode_t) members; |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
87 paint_t *pnt_next; /*!< \brief Collect all paints of a rdman. */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
88 }; |
356
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
89 enum { MBP_DUMMY, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
90 MBP_COLOR, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
91 MBP_LINEAR, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
92 MBP_RADIAL, |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
93 MBP_IMAGE |
3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
94 }; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
95 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
96 #define PNTF_FREE 0x1 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
97 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
98 struct _shnode { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
99 shape_t *shape; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
100 shnode_t *next; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
101 }; |
13 | 102 |
103 struct _area { | |
104 co_aix x, y; | |
105 co_aix w, h; | |
106 }; | |
107 | |
108 /*! \brief Geometry data of a shape or a group of shape. | |
109 */ | |
110 struct _geo { | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
111 #ifdef GEO_ORDER |
13 | 112 unsigned int order; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
113 #endif |
13 | 114 unsigned int flags; |
115 shape_t *shape; | |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
116 geo_t *coord_next; /*!< \brief Link all member geos together. */ |
13 | 117 |
118 area_t *cur_area, *last_area; | |
119 area_t areas[2]; | |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
120 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
121 subject_t *mouse_event; |
13 | 122 }; |
123 #define GEF_DIRTY 0x1 | |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
124 #define GEF_HIDDEN 0x2 /*!< The geo is hidden. */ |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
125 #define GEF_FREE 0x4 |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
126 #define GEF_OV_DRAW 0x8 /*!< To flag drawed for a overlay testing. */ |
13 | 127 |
235 | 128 extern int areas_are_overlay(area_t *r1, area_t *r2); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
129 extern void area_init(area_t *area, int n_pos, co_aix pos[][2]); |
250
bd8ea44b421e
Fix bug and finish unit test for collision testing in event.c.
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
130 #define _in_range(a, s, w) ((a) >= (s) && (a) < ((s) + (w))) |
bd8ea44b421e
Fix bug and finish unit test for collision testing in event.c.
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
131 #define area_pos_is_in(area, _x, _y) \ |
bd8ea44b421e
Fix bug and finish unit test for collision testing in event.c.
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
132 (_in_range(_x, (area)->x, (area)->w) && \ |
bd8ea44b421e
Fix bug and finish unit test for collision testing in event.c.
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
133 _in_range(_y, (area)->y, (area)->h)) |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
134 extern void geo_init(geo_t *g); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
135 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); |
13 | 136 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, |
137 int *n_overlays, geo_t **overlays); | |
138 #define geo_get_shape(g) ((g)->shape) | |
235 | 139 #define geo_get_shape_safe(g) ((g)? (g)->shape: NULL) |
13 | 140 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) |
250
bd8ea44b421e
Fix bug and finish unit test for collision testing in event.c.
Thinker K.F. Li <thinker@branda.to>
parents:
241
diff
changeset
|
141 #define geo_pos_is_in(g, _x, _y) area_pos_is_in((g)->cur_area, _x, _y) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
142 #define geo_get_area(g) ((g)->cur_area) |
235 | 143 #define geo_get_flags(g, mask) ((g)->flags & (mask)) |
144 #define geo_set_flags(g, mask) do {(g)->flags |= mask;} while(0) | |
145 #define geo_clear_flags(g, mask) do {(g)->flags &= ~(mask);} while(0) | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
146 #define geo_get_coord(g) sh_get_coord(geo_get_shape(g)) |
13 | 147 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
148 /*! \defgroup coord Coordination |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
149 * @{ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
150 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
151 typedef struct _coord coord_t; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
152 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
153 DARRAY(areas, area_t *); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
154 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
155 /*! \brief Canvas information for a coord. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
156 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
157 typedef struct _coord_canvas_info { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
158 coord_t *owner; /*!< Cached one or opacity == 1 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
159 canvas_t *canvas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
160 areas_t dirty_areas; /*!< \brief Areas should be updated |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
161 * in canvas. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
162 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
163 area_t aggr_dirty_areas[2]; /*!< Used to aggregate updates to parent. */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
164 area_t cached_dirty_area; /*!< Used to dirty an area in cached space. */ |
322
c1afd14caa85
Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents:
314
diff
changeset
|
165 area_t owner_mems_area; /*!< \brief The area is covered by members |
c1afd14caa85
Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents:
314
diff
changeset
|
166 * of owner. |
c1afd14caa85
Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents:
314
diff
changeset
|
167 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
168 } coord_canvas_info_t; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
169 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
170 /*! \brief A coordination system. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
171 * |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
172 * It have a transform function defined by matrix to transform |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
173 * coordination from source space to target space. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
174 * Source space is where the contained is drawed, and target space |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
175 * is where the coordination of parent container of the element |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
176 * represented by this coord object. |
12 | 177 * |
178 * \dot | |
179 * digraph G { | |
180 * graph [rankdir=LR]; | |
181 * root -> child00 -> child10 -> child20 [label="children" color="blue"]; | |
182 * child00 -> child01 -> child02 [label="sibling"]; | |
183 * child10 -> child11 [label="sibling"]; | |
184 * } | |
185 * \enddot | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
186 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
187 struct _coord { |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
188 mb_obj_t obj; |
13 | 189 unsigned int order; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
190 unsigned int flags; /*!< \sa \ref coord_flags */ |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
191 co_aix opacity; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
192 /*! Own one or inherit from an ancestor. |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
193 * Setup it when clean coords. |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
194 * \sa |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
195 * - \ref COF_OWN_CANVAS |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
196 * - \ref redraw |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
197 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
198 coord_canvas_info_t *canvas_info; |
13 | 199 area_t *cur_area, *last_area; |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
200 area_t areas[2]; |
13 | 201 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
202 co_aix matrix[6]; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
203 co_aix aggr_matrix[6]; |
13 | 204 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
205 struct _coord *parent; |
12 | 206 STAILQ(struct _coord) children; |
207 struct _coord *sibling; | |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
208 unsigned int before_pmem; /*!< \brief The coord is before nth member |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
209 * of parent. */ |
13 | 210 |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
211 int num_members; |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
212 STAILQ(geo_t) members; /*!< \brief All geo_t members in this coord. */ |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
213 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
214 subject_t *mouse_event; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
215 }; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
216 /*! \defgroup coord_flags Coord Flags |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
217 * @{ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
218 */ |
13 | 219 #define COF_DIRTY 0x1 |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
220 #define COF_HIDDEN 0x2 /*!< A coord is hidden. */ |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
221 #define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
222 * from an ancestor. |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
223 */ |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
224 #define COF_SKIP_TRIVAL 0x8 /*!< temporary skip descendants |
151
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
225 * when trivaling. |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
226 */ |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
227 #define COF_FREE 0x10 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
228 #define COF_FAST_CACHE 0x20 /*!< \brief Cache raster image in fast way. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
229 * \sa \ref img_cache |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
230 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
231 #define COF_PRECISE_CACHE 0x40 /*!< \brief Cache raster image in |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
232 * precise way. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
233 * \sa \ref img_cache |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
234 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
235 #define COF_CACHE_MASK 0x60 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
236 #define COF_ANCESTOR_CACHE 0x80 /*!< \brief One ancestor is cached. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
237 * \sa \ref img_cache |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
238 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
239 #define COF_MUST_ZEROING 0x100 /*!< \sa \ref cache_imp */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
240 #define COF_JUST_CLEAN 0x200 /*!< \brief This coord is just cleaned by |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
241 * last clean. |
322
c1afd14caa85
Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents:
314
diff
changeset
|
242 * It is used by clean_rdman_dirties(). |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
243 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
244 #define COF_TEMP_MARK 0x400 /*!< \brief Temporary mark a coord. */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
245 /* @} */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
246 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
247 extern void matrix_mul(co_aix *m1, co_aix *m2, co_aix *dst); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
248 extern void matrix_trans_pos(co_aix *matrix, co_aix *x, co_aix *y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
249 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
250 extern void coord_init(coord_t *co, coord_t *parent); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
251 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); |
31
da770188a44d
resize font size for changige of coord.
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
252 extern co_aix coord_trans_size(coord_t *co, co_aix size); |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
253 extern void compute_aggr_of_coord(coord_t *coord); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
254 extern void compute_aggr_of_cached_coord(coord_t *coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
255 extern void compute_reverse(co_aix *orig, co_aix *reverse); |
10 | 256 extern void update_aggr_matrix(coord_t *start); |
13 | 257 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
258 extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last); |
151
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
259 #define preorder_coord_skip_subtree(sub) \ |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
260 do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0) |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
261 #define coord_hide(co) \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
262 do { \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
263 (co)->flags |= COF_HIDDEN; \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
264 } while(0) |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
35
diff
changeset
|
265 #define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
266 #define coord_fast_cache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
267 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
268 (co)->flags = \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
269 ((co)->flags & ~COF_CACHE_MASK) | COF_FAST_CACHE; \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
270 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
271 #define coord_precise_cache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
272 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
273 (co)->flags = \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
274 ((co)->flags & ~COF_CACHE_MASK) | COF_PRECISE_CACHE; \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
275 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
276 #define coord_nocache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
277 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
278 (co)->flags &= ~COF_CACHE_MASK; \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
279 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
280 #define coord_is_root(co) ((co)->parent == NULL) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
281 #define coord_is_cached(co) ((co)->flags & COF_CACHE_MASK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
282 #define coord_is_fast_cached(co) ((co)->flags & COF_FAST_MASK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
283 #define coord_is_precise_cached(co) ((co)->flags & COF_PRECISE_MASK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
284 #define coord_is_zeroing(co) ((co)->flags & COF_MUST_ZEROING) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
285 #define coord_set_zeroing(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
286 do { (co)->flags |= COF_MUST_ZEROING; } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
287 #define coord_clear_zeroing(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
288 do { (co)->flags &= ~COF_MUST_ZEROING; } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
289 #define coord_set_flags(co, _flags) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
290 do { (co)->flags |= (_flags); } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
291 #define coord_get_flags(co, _flags) ((co)->flags & (_flags)) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
292 #define coord_clear_flags(co, _flags) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
293 do { (co)->flags &= ~(_flags); } while(0) |
83 | 294 #define coord_get_mouse_event(coord) ((coord)->mouse_event) |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
250
diff
changeset
|
295 #define coord_get_aggr_matrix(coord) ((coord)->aggr_matrix) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
296 #define FOR_COORDS_POSTORDER(coord, cur) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
297 for((cur) = postorder_coord_subtree((coord), NULL); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
298 (cur) != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
299 (cur) = postorder_coord_subtree((coord), (cur))) |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
300 #define FOR_COORDS_PREORDER(coord, cur) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
301 for((cur) = (coord); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
302 (cur) != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
303 (cur) = preorder_coord_subtree((coord), (cur))) |
12 | 304 |
222
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
305 /*! \brief Coord operation function |
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
306 * These functions are used to move and scale the coord_t. Programmers should use these functions instead of using the matrix directly. |
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
307 * The x,y,sx,sy are all in co_aix type. |
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
308 * |
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
309 */ |
f7057177abbb
Add functions to move and scale the coord_t like the actionscript. Users should use these functions instead of the matrix directly.
wycc
parents:
211
diff
changeset
|
310 #define coord_move(co,x,y) do {(co)->matrix[2] = (x); (co)->matrix[5] = (y);} while(0) |
295 | 311 #define coord_set_scalex(co,sx) do {(co)->matrix[0] = sx;} while(0) |
303
f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
wycc
parents:
295
diff
changeset
|
312 #define coord_set_scaley(co,sy) do {(co)->matrix[3] = sy;} while(0) |
295 | 313 #define coord_scalex(co) ((co)->matrix[0]) |
314 #define coord_scaley(co) ((co)->matrix[3]) | |
315 #define coord_x(co) ((co)->matrix[2]) | |
316 #define coord_y(co) ((co)->matrix[5]) | |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
317 #define FOR_COORD_MEMBERS(coord, geo) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
318 for(geo = STAILQ_HEAD((coord)->members); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
319 geo != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
320 geo = STAILQ_NEXT(geo_t, coord_next, geo)) |
235 | 321 #define FOR_COORD_SHAPES(coord, shape) \ |
322 for(shape = geo_get_shape_safe(STAILQ_HEAD((coord)->members)); \ | |
323 shape != NULL; \ | |
324 shape = geo_get_shape_safe(STAILQ_NEXT(geo_t, coord_next, \ | |
325 sh_get_geo(shape)))) | |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
326 #define coord_get_area(coord) ((coord)->cur_area) |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
327 #define _coord_get_canvas(coord) ((coord)->canvas_info->canvas) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
328 #define _coord_set_canvas(coord, _canvas) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
329 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
330 (coord)->canvas_info->canvas = _canvas; \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
331 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
332 #define _coord_get_dirty_areas(coord) (&(coord)->canvas_info->dirty_areas) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
333 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
334 /* @} */ |
12 | 335 |
336 /*! \brief A grahpic shape. | |
337 * | |
338 * \dot | |
339 * digraph G { | |
340 * "shape" -> "coord"; | |
341 * "shape" -> "geo"; | |
342 * "geo" -> "shape"; | |
343 * "coord" -> "shape" [label="members"] | |
344 * "shape" -> "shape" [label="sibling"]; | |
345 * } | |
346 * \enddot | |
347 */ | |
348 struct _shape { | |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
349 mb_obj_t obj; |
12 | 350 geo_t *geo; |
351 coord_t *coord; | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
352 paint_t *fill, *stroke; |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
18
diff
changeset
|
353 co_aix stroke_width; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
354 int stroke_linecap:2; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
355 int stroke_linejoin:2; |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
356 struct _shape *sh_next; /*!< Link all shapes of a rdman together. */ |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
357 void (*free)(shape_t *shape); |
12 | 358 }; |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
359 /* enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; */ |
12 | 360 |
77 | 361 #define sh_get_mouse_event_subject(sh) ((sh)->geo->mouse_event) |
160
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
362 #define sh_hide(sh) \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
363 do { \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
364 (sh)->geo->flags |= GEF_HIDDEN; \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
365 } while(0) |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
366 #define sh_show(sh) \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
367 do { \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
368 (sh)->geo->flags &= ~GEF_HIDDEN; \ |
147c93163ef0
Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents:
159
diff
changeset
|
369 } while(0) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
370 #define sh_get_geo(sh) ((sh)->geo) |
235 | 371 #define sh_get_geo_safe(sh) ((sh)? (sh)->geo: NULL) |
372 #define sh_get_flags(sh, mask) geo_get_flags(sh_get_geo(sh), mask) | |
373 #define sh_set_flags(sh, mask) geo_set_flags(sh_get_geo(sh), mask) | |
374 #define sh_clear_flags(sh, mask) geo_clear_flags(sh_get_geo(sh), mask) | |
375 #define sh_pos_is_in(sh, x, y) geo_pos_is_in(sh_get_geo(sh), x, y) | |
376 #define sh_get_area(sh) geo_get_area(sh_get_geo(sh)) | |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
250
diff
changeset
|
377 #define sh_get_coord(sh) ((sh)->coord) |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
378 #define sh_get_aggr_matrix(sh) (coord_get_aggr_matrix(sh_get_coord(sh))) |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
379 #define sh_get_fill(sh) ((sh)->fill) |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
380 #define sh_get_stroke(sh) ((sh)->stroke) |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
381 |
12 | 382 |
208 | 383 /*! \brief A sprite is a set of graphics that being an object in animation. |
384 * | |
385 * A sprite include graphics comprise an object. For example, a tank, in | |
386 * example tank, is comprised a set of graphics that is represented as a | |
387 * sprite. | |
388 */ | |
389 struct _mb_sprite { | |
209
6f63aa67ed83
Define types for sprite shared object.
Thinker K.F. Li <thinker@branda.to>
parents:
208
diff
changeset
|
390 void (*free)(mb_sprite_t *); |
6f63aa67ed83
Define types for sprite shared object.
Thinker K.F. Li <thinker@branda.to>
parents:
208
diff
changeset
|
391 mb_obj_t *(*get_obj_with_name)(mb_sprite_t *sprite, const char *id); |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
392 /*! Return non-zero for error. */ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
393 int (*goto_scene)(mb_sprite_t *sprite, int scene_no); |
208 | 394 }; |
395 | |
211
41eab0a10651
Define convenience macros for sprite.
Thinker K.F. Li <thinker@branda.to>
parents:
210
diff
changeset
|
396 #define MB_SPRITE_FREE(sprite) ((mb_sprite_t *)(sprite))->free(sprite) |
241
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
397 #define MB_SPRITE_GET_OBJ(sprite, name) \ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
398 ((mb_sprite_t *)(sprite))->get_obj_with_name((mb_sprite_t *)(sprite), \ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
399 (name)) |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
400 #define MB_SPRITE_GOTO_SCENE(sprite, scene_no) \ |
104d83378582
Add scene support in svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
401 ((mb_sprite_t *)(sprite))->goto_scene((mb_sprite_t *)(sprite), scene_no) |
211
41eab0a10651
Define convenience macros for sprite.
Thinker K.F. Li <thinker@branda.to>
parents:
210
diff
changeset
|
402 |
210
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
403 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
404 /*! \defgroup mb_sprite_lsym Sprite with linear symbol table. |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
405 * @{ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
406 */ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
407 struct _mb_sprite_lsym_entry { |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
408 const char *sym; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
409 const int offset; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
410 }; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
411 typedef struct _mb_sprite_lsym_entry mb_sprite_lsym_entry_t; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
412 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
413 /*! \brief A sub-type of mb_sprite_t with linear symbol table. |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
414 * |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
415 * This type of sprite search symbols with linear/or binary searching. |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
416 */ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
417 struct _mb_sprite_lsym { |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
418 mb_sprite_t sprite; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
419 int num_entries; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
420 mb_sprite_lsym_entry_t *entries; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
421 }; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
422 typedef struct _mb_sprite_lsym mb_sprite_lsym_t; |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
423 |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
424 /* @} */ |
3fadd2f2742e
M4 macros to generate code for dynamic loading.
Thinker K.F. Li <thinker@branda.to>
parents:
209
diff
changeset
|
425 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
426 #endif /* __MB_TYPES_H_ */ |