Mercurial > MadButterfly
annotate include/mb_types.h @ 208:e01acb80f0e7
Define mb_sprite_t
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 10 Dec 2008 14:57:21 +0800 |
parents | eb6ff421da7e |
children | 6f63aa67ed83 |
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" |
12 | 7 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 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
|
9 typedef struct _shape shape_t; |
12 | 10 typedef struct _geo geo_t; |
13 | 11 typedef struct _area area_t; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
12 typedef struct _shnode shnode_t; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
13 typedef struct _paint paint_t; |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
14 typedef struct _mb_obj mb_obj_t; |
208 | 15 typedef struct _mb_sprite mb_sprite_t; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
16 |
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
|
17 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
|
18 |
204 | 19 /*! \brief MadButterfly object. |
20 * | |
21 * All objects (coord and shapes) should have mb_obj_t as first member | |
22 * variable. obj_type is used to identify type of an object. Please, | |
23 * use MBO_TYPE() to return this value. MBO_TYPE() will type-casting the | |
24 * object to mb_obj_t and return obj_type. MBO_TYPE() is a left-side | |
25 * value. | |
26 */ | |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
27 struct _mb_obj { |
204 | 28 int obj_type; /*!< \brief Type of a MadButterfly object. */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
29 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
30 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
31 enum { MBO_DUMMY, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
32 MBO_COORD, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
33 MBO_SHAPES=0x1000, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
34 MBO_PATH, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
35 MBO_TEXT, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
36 MBO_RECT |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
37 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
38 #define MBO_CLASS_MASK 0xf000 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
39 #define MBO_CLASS(x) (((mb_obj_t *)(x))->obj_type & MBO_CLASS_MASK) |
204 | 40 /*! \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
|
41 #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
|
42 #define IS_MBO_SHAPES(obj) (MBO_CLASS(obj) == MBO_SHAPES) |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
43 #define IS_MBO_COORD(obj) (MBO_TYPE(obj) == MB_COORD) |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
44 |
58 | 45 /*! \brief Base of paint types. |
46 * | |
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
|
47 * Paints should be freed by users by calling rdman_paint_free() of |
58 | 48 * the paint. |
49 * | |
50 * \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
|
51 * singleton for each paint type. |
58 | 52 */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
53 struct _paint { |
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
|
54 int flags; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 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
|
59 }; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
60 |
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
|
61 #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
|
62 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
63 struct _shnode { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
64 shape_t *shape; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
65 shnode_t *next; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
66 }; |
13 | 67 |
68 struct _area { | |
69 co_aix x, y; | |
70 co_aix w, h; | |
71 }; | |
72 | |
73 /*! \brief Geometry data of a shape or a group of shape. | |
74 */ | |
75 struct _geo { | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
76 #ifdef GEO_ORDER |
13 | 77 unsigned int order; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
78 #endif |
13 | 79 unsigned int flags; |
80 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
|
81 geo_t *coord_next; /*!< \brief Link all member geos together. */ |
13 | 82 |
83 area_t *cur_area, *last_area; | |
84 area_t areas[2]; | |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
85 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
86 subject_t *mouse_event; |
13 | 87 }; |
88 #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
|
89 #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
|
90 #define GEF_FREE 0x4 |
13 | 91 |
92 extern int is_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
|
93 extern void area_init(area_t *area, int n_pos, co_aix pos[][2]); |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
94 extern void geo_init(geo_t *g); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
95 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); |
13 | 96 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, |
97 int *n_overlays, geo_t **overlays); | |
98 #define geo_get_shape(g) ((g)->shape) | |
99 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) | |
28 | 100 #define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w))) |
101 #define geo_pos_is_in(g, _x, _y) \ | |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
28
diff
changeset
|
102 (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \ |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
28
diff
changeset
|
103 _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h)) |
13 | 104 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
105 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
106 /*! \brief A coordination system. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
107 * |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
108 * 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
|
109 * coordination from source space to target space. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
110 * 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
|
111 * 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
|
112 * represented by this coord object. |
12 | 113 * |
114 * \dot | |
115 * digraph G { | |
116 * graph [rankdir=LR]; | |
117 * root -> child00 -> child10 -> child20 [label="children" color="blue"]; | |
118 * child00 -> child01 -> child02 [label="sibling"]; | |
119 * child10 -> child11 [label="sibling"]; | |
120 * } | |
121 * \enddot | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
122 */ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
123 typedef struct _coord { |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
124 mb_obj_t obj; |
13 | 125 unsigned int order; |
126 unsigned int flags; | |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
127 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
|
128 /*! 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
|
129 * 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
|
130 * \sa |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
131 * - \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
|
132 * - \ref redraw |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
133 */ |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
134 cairo_t *canvas; |
13 | 135 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
|
136 area_t areas[2]; |
13 | 137 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 co_aix matrix[6]; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
139 co_aix aggr_matrix[6]; |
13 | 140 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
141 struct _coord *parent; |
12 | 142 STAILQ(struct _coord) children; |
143 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
|
144 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
|
145 * of parent. */ |
13 | 146 |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
147 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
|
148 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
|
149 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
150 subject_t *mouse_event; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 } coord_t; |
13 | 152 #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
|
153 #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
|
154 #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
|
155 * 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
|
156 */ |
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
|
157 #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
|
158 * when trivaling. |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
159 */ |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
160 #define COF_FREE 0x10 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
161 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 extern void compute_aggr_of_coord(coord_t *coord); |
10 | 166 extern void update_aggr_matrix(coord_t *start); |
13 | 167 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
|
168 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
|
169 extern void preorder_coord_skip_subtree(coord_t *subroot); |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
170 #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
|
171 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
|
172 #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
|
173 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
|
174 (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
|
175 } while(0) |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
35
diff
changeset
|
176 #define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) |
83 | 177 #define coord_get_mouse_event(coord) ((coord)->mouse_event) |
12 | 178 |
179 | |
180 /*! \brief A grahpic shape. | |
181 * | |
182 * \dot | |
183 * digraph G { | |
184 * "shape" -> "coord"; | |
185 * "shape" -> "geo"; | |
186 * "geo" -> "shape"; | |
187 * "coord" -> "shape" [label="members"] | |
188 * "shape" -> "shape" [label="sibling"]; | |
189 * } | |
190 * \enddot | |
191 */ | |
192 struct _shape { | |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
193 mb_obj_t obj; |
12 | 194 geo_t *geo; |
195 coord_t *coord; | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
196 paint_t *fill, *stroke; |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
18
diff
changeset
|
197 co_aix stroke_width; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
198 int stroke_linecap:2; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
199 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
|
200 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
|
201 void (*free)(shape_t *shape); |
12 | 202 }; |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
203 /* enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; */ |
12 | 204 |
77 | 205 #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
|
206 #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
|
207 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
|
208 (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
|
209 } 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
|
210 #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
|
211 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
|
212 (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
|
213 } while(0) |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
214 |
12 | 215 |
208 | 216 /*! \brief A sprite is a set of graphics that being an object in animation. |
217 * | |
218 * A sprite include graphics comprise an object. For example, a tank, in | |
219 * example tank, is comprised a set of graphics that is represented as a | |
220 * sprite. | |
221 */ | |
222 struct _mb_sprite { | |
223 void (*free)(struct _mb_sprite *); | |
224 mb_obj_t *(*get_obj_with_name)(const char *id); | |
225 }; | |
226 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
227 #endif /* __MB_TYPES_H_ */ |