Mercurial > MadButterfly
annotate include/mb_types.h @ 1535:9aff42a7e2b9 tip
Fix issue of add/remove a frame at a scene before all key frames of a layer.
When you added or removed a frame at a scene before all key frames of
a layer, frameline was not updated correctly. It seems nothing
happened, but domview is updated. This changeset fix this issue by
correcting logic for boundary case.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 30 Sep 2011 22:07:28 +0800 |
parents | e22df2f3bffe |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
816
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:
816
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #ifndef __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #define __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
6 #include "mb_graph_engine.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
|
7 #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
|
8 #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
|
9 #include "mb_prop.h" |
12 | 10 |
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
|
11 typedef struct _shape shape_t; |
12 | 12 typedef struct _geo geo_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; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
17 /*! \todo Replace mbe_t with canvas_t. */ |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
18 typedef mbe_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 * |
1063 | 35 * We have defined a set of convienent API which will wrap the coord_t |
36 * or shape_t API accoridng to its type. Please refer to | |
37 * http://www.assembla.com/wiki/show/dFrSMOtDer3BZUab7jnrAJ/MBAF_Object | |
38 * for the details. This API is designed for regular programmers which | |
39 * can be used to change some common properties of objects without | |
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
|
40 * checking its type. |
204 | 41 */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
42 struct _mb_obj { |
204 | 43 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
|
44 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
|
45 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
46 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
47 enum { MBO_DUMMY, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
48 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
|
49 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
|
50 MBO_PATH, |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
51 MBO_TEXT, |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
250
diff
changeset
|
52 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
|
53 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
|
54 MBO_STEXT |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
55 }; |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
56 #define MBO_CLASS_MASK 0xf000 |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
57 #define MBO_CLASS(x) (((mb_obj_t *)(x))->obj_type & MBO_CLASS_MASK) |
204 | 58 /*! \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
|
59 #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
|
60 #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
|
61 #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
|
62 #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
|
63 do { \ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
64 ((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
|
65 } while(0) |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
66 #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
|
67 #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
|
68 |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
69 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
223
diff
changeset
|
70 /* @} */ |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
71 |
58 | 72 /*! \brief Base of paint types. |
73 * | |
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
|
74 * Paints should be freed by users by calling rdman_paint_free() of |
58 | 75 * the paint. |
76 * | |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
77 * 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
|
78 * function. It return a paint object. |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
79 * |
58 | 80 * \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
|
81 * singleton for each paint type. |
58 | 82 */ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
83 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
|
84 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
|
85 int flags; |
881
a17c4e231e54
Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents:
851
diff
changeset
|
86 void (*prepare)(paint_t *paint, mbe_t *cr, shape_t *sh); |
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 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
|
88 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
|
89 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
|
90 }; |
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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 }; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
97 |
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
|
98 #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
|
99 |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
100 struct _shnode { |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
101 shape_t *shape; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
102 shnode_t *next; |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
103 }; |
13 | 104 |
105 /*! \brief Geometry data of a shape or a group of shape. | |
106 */ | |
107 struct _geo { | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
108 #ifdef GEO_ORDER |
13 | 109 unsigned int order; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
110 #endif |
13 | 111 unsigned int flags; |
112 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
|
113 geo_t *coord_next; /*!< \brief Link all member geos together. */ |
13 | 114 |
115 area_t *cur_area, *last_area; | |
116 area_t areas[2]; | |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
117 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
118 subject_t *mouse_event; |
13 | 119 }; |
120 #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
|
121 #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
|
122 #define GEF_FREE 0x4 |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
123 #define GEF_OV_DRAW 0x8 /*!< To flag drawed for a overlay testing. */ |
541
f42419c08a65
Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
124 #define GEF_SWAP 0x10 |
747
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
125 #define GEF_NOT_SHOWED 0x20 /*!< This geo is not showed. |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
126 * |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
127 * A geo is not showed if it is hidden |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
128 * or one of its ancestors is hidden. |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
129 * Redraw manager uses this flag to |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
130 * determine who is not showed. |
d2f2ed27b84d
Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents:
570
diff
changeset
|
131 */ |
13 | 132 |
235 | 133 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
|
134 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
|
135 #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
|
136 #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
|
137 (_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
|
138 _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
|
139 extern void geo_init(geo_t *g); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
140 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); |
13 | 141 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, |
142 int *n_overlays, geo_t **overlays); | |
143 #define geo_get_shape(g) ((g)->shape) | |
235 | 144 #define geo_get_shape_safe(g) ((g)? (g)->shape: NULL) |
13 | 145 #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
|
146 #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
|
147 #define geo_get_area(g) ((g)->cur_area) |
235 | 148 #define geo_get_flags(g, mask) ((g)->flags & (mask)) |
149 #define geo_set_flags(g, mask) do {(g)->flags |= mask;} while(0) | |
150 #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
|
151 #define geo_get_coord(g) sh_get_coord(geo_get_shape(g)) |
13 | 152 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
153 /*! \defgroup coord Coordination |
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 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
156 typedef struct _coord coord_t; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
157 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
158 DARRAY(areas, area_t *); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
159 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
160 /*! \brief Canvas information for a coord. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
161 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
162 typedef struct _coord_canvas_info { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
163 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
|
164 canvas_t *canvas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
165 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
|
166 * in canvas. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
167 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
168 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
|
169 area_t cached_dirty_area; /*!< Used to dirty an area in cached space. */ |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
170 area_t pcache_areas[2]; /*!< The area in the space of parent |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
171 * cached. */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
172 area_t *pcache_cur_area; /*!< Current area for parent cached. */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
173 area_t *pcache_last_area; /*!< Last area for parent cached. */ |
850
33fd5fdc8b48
Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents:
840
diff
changeset
|
174 co_aix cache_2_pdev[6]; /*!< Transfrom matrix from space of |
33fd5fdc8b48
Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents:
840
diff
changeset
|
175 * cached one to its parent. */ |
33fd5fdc8b48
Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents:
840
diff
changeset
|
176 co_aix cache_2_pdev_rev[6]; /*!< Reverse of cache_2_pdev. */ |
851
85f22a771e4a
Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents:
850
diff
changeset
|
177 co_aix aggr_2_pdev[6]; /*!< Aggregation of cache_2_pdev from root */ |
85f22a771e4a
Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents:
850
diff
changeset
|
178 co_aix aggr_2_pdev_rev[6]; /*!< Aggregation of cache_2_pdev_rev |
85f22a771e4a
Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents:
850
diff
changeset
|
179 * from root */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
180 } coord_canvas_info_t; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
181 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
182 /*! \brief A coordination system. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
183 * |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
184 * 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
|
185 * coordination from source space to target space. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
186 * 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
|
187 * 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
|
188 * represented by this coord object. |
12 | 189 * |
190 * \dot | |
191 * digraph G { | |
192 * graph [rankdir=LR]; | |
193 * root -> child00 -> child10 -> child20 [label="children" color="blue"]; | |
194 * child00 -> child01 -> child02 [label="sibling"]; | |
195 * child10 -> child11 [label="sibling"]; | |
196 * } | |
197 * \enddot | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
198 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
199 struct _coord { |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
200 mb_obj_t obj; |
13 | 201 unsigned int order; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
202 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
|
203 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
|
204 /*! 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
|
205 * 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
|
206 * \sa |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
207 * - \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
|
208 * - \ref redraw |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
83
diff
changeset
|
209 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
210 coord_canvas_info_t *canvas_info; |
13 | 211 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
|
212 area_t areas[2]; |
13 | 213 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
214 co_aix matrix[6]; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
215 co_aix aggr_matrix[6]; |
13 | 216 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
217 struct _coord *parent; |
12 | 218 STAILQ(struct _coord) children; |
219 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
|
220 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
|
221 * of parent. */ |
13 | 222 |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
223 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
|
224 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
|
225 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
226 subject_t *mouse_event; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
227 }; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
228 /*! \defgroup coord_flags Coord Flags |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
229 * @{ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
230 */ |
13 | 231 #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
|
232 #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
|
233 #define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
816
diff
changeset
|
234 * 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
|
235 */ |
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
|
236 #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
|
237 * when trivaling. |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
140
diff
changeset
|
238 */ |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
239 #define COF_FREE 0x10 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
240 #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
|
241 * \sa \ref img_cache |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
242 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
243 #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
|
244 * precise way. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
245 * \sa \ref img_cache |
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 #define COF_CACHE_MASK 0x60 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
248 #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
|
249 * \sa \ref img_cache |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
250 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
251 #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
|
252 #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
|
253 * 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
|
254 * 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
|
255 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
256 #define COF_TEMP_MARK 0x400 /*!< \brief Temporary mark a coord. */ |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
257 #define COF_JUST_ZERO 0x800 /*!< \brief The coord is real peformed zeroing. |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
816
diff
changeset
|
258 * |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
259 * It's canvas is changed by zeroing. |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
260 */ |
837
0b66b585b364
Since it is COF_DIRTY_PCACHE_AREA, donot add it again
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
261 /*! \brief pcache_area shoud be updated. |
0b66b585b364
Since it is COF_DIRTY_PCACHE_AREA, donot add it again
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
262 * |
840
048cc704bef7
Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents:
838
diff
changeset
|
263 * A coord is marked with COF_DIRTY_PCACHE_AREA means its pcache_area |
048cc704bef7
Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents:
838
diff
changeset
|
264 * must be re-computed when zeroing. |
837
0b66b585b364
Since it is COF_DIRTY_PCACHE_AREA, donot add it again
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
265 */ |
0b66b585b364
Since it is COF_DIRTY_PCACHE_AREA, donot add it again
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
266 #define COF_DIRTY_PCACHE_AREA 0x1000 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
267 #define COF_SKIP_ZERO 0x2000 /*!< \brief The coord just skip zeroing. |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
268 * No real zeroing was performed. |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
269 */ |
816
0e56a1ca19b2
Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents:
753
diff
changeset
|
270 #define COF_ALWAYS_CACHE 0x4000 /*!< \brief The coord always own a canvas */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
271 /* @} */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
272 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
273 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
|
274 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
|
275 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 extern void compute_aggr_of_cached_coord(coord_t *coord); |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
281 extern void compute_aggr(coord_t *coord); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
282 extern void compute_reverse(co_aix *orig, co_aix *reverse); |
10 | 283 extern void update_aggr_matrix(coord_t *start); |
13 | 284 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
|
285 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
|
286 #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
|
287 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
|
288 #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
|
289 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
|
290 (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
|
291 } while(0) |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
35
diff
changeset
|
292 #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
|
293 #define coord_fast_cache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
294 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
295 (co)->flags = \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
296 ((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
|
297 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
298 #define coord_precise_cache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
299 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
300 (co)->flags = \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
301 ((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
|
302 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
303 #define coord_nocache(co) \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
304 do { \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
305 (co)->flags &= ~COF_CACHE_MASK; \ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
306 } while(0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
307 #define coord_is_root(co) ((co)->parent == NULL) |
83 | 308 #define coord_get_mouse_event(coord) ((coord)->mouse_event) |
753
cedfe4966fd6
Clear unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents:
747
diff
changeset
|
309 #define coord_get_opacity(coord) ((coord)->opacity) |
cedfe4966fd6
Clear unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents:
747
diff
changeset
|
310 #define coord_set_opacity(coord, v) do { (coord)->opacity = v; } while(0) |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
250
diff
changeset
|
311 #define coord_get_aggr_matrix(coord) ((coord)->aggr_matrix) |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
312 #define coord_get_matrix(coord) ((coord)->matrix) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
313 #define FOR_COORDS_POSTORDER(coord, cur) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
314 for((cur) = postorder_coord_subtree((coord), NULL); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
315 (cur) != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
316 (cur) = postorder_coord_subtree((coord), (cur))) |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
317 #define FOR_COORDS_PREORDER(coord, cur) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
318 for((cur) = (coord); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
319 (cur) != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
320 (cur) = preorder_coord_subtree((coord), (cur))) |
12 | 321 |
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
|
322 /*! \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
|
323 * 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
|
324 * 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
|
325 * |
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
|
326 */ |
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
|
327 #define coord_move(co,x,y) do {(co)->matrix[2] = (x); (co)->matrix[5] = (y);} while(0) |
295 | 328 #define coord_set_scalex(co,sx) do {(co)->matrix[0] = sx;} while(0) |
1143
18d718a76a45
Fix incorrect index of y-scale in the matrix
Thinker K.F. Li <thinker@codemud.net>
parents:
1073
diff
changeset
|
329 #define coord_set_scaley(co,sy) do {(co)->matrix[4] = sy;} while(0) |
295 | 330 #define coord_scalex(co) ((co)->matrix[0]) |
1143
18d718a76a45
Fix incorrect index of y-scale in the matrix
Thinker K.F. Li <thinker@codemud.net>
parents:
1073
diff
changeset
|
331 #define coord_scaley(co) ((co)->matrix[4]) |
295 | 332 #define coord_x(co) ((co)->matrix[2]) |
333 #define coord_y(co) ((co)->matrix[5]) | |
1454
e22df2f3bffe
Provide number of children for coords
Thinker K.F. Li <thinker@codemud.net>
parents:
1370
diff
changeset
|
334 #define FOR_COORD_CHILDREN(parent, child) \ |
e22df2f3bffe
Provide number of children for coords
Thinker K.F. Li <thinker@codemud.net>
parents:
1370
diff
changeset
|
335 for((child) = STAILQ_HEAD((parent)->children); \ |
e22df2f3bffe
Provide number of children for coords
Thinker K.F. Li <thinker@codemud.net>
parents:
1370
diff
changeset
|
336 (child) != NULL; \ |
e22df2f3bffe
Provide number of children for coords
Thinker K.F. Li <thinker@codemud.net>
parents:
1370
diff
changeset
|
337 (child) = STAILQ_NEXT(coord_t, sibling, (child))) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
338 #define FOR_COORD_MEMBERS(coord, geo) \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
339 for(geo = STAILQ_HEAD((coord)->members); \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
340 geo != NULL; \ |
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
341 geo = STAILQ_NEXT(geo_t, coord_next, geo)) |
235 | 342 #define FOR_COORD_SHAPES(coord, shape) \ |
343 for(shape = geo_get_shape_safe(STAILQ_HEAD((coord)->members)); \ | |
344 shape != NULL; \ | |
345 shape = geo_get_shape_safe(STAILQ_NEXT(geo_t, coord_next, \ | |
346 sh_get_geo(shape)))) | |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
347 #define coord_get_area(coord) ((coord)->cur_area) |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
521
diff
changeset
|
348 #define coord_get_last_area(coord) ((coord)->last_area) |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
349 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
303
diff
changeset
|
350 /* @} */ |
12 | 351 |
352 /*! \brief A grahpic shape. | |
353 * | |
354 * \dot | |
355 * digraph G { | |
356 * "shape" -> "coord"; | |
357 * "shape" -> "geo"; | |
358 * "geo" -> "shape"; | |
359 * "coord" -> "shape" [label="members"] | |
360 * "shape" -> "shape" [label="sibling"]; | |
361 * } | |
362 * \enddot | |
363 */ | |
364 struct _shape { | |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
365 mb_obj_t obj; |
12 | 366 geo_t *geo; |
367 coord_t *coord; | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
368 paint_t *fill, *stroke; |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
18
diff
changeset
|
369 co_aix stroke_width; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
370 int stroke_linecap:2; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
371 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
|
372 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
|
373 void (*free)(shape_t *shape); |
12 | 374 }; |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
375 /* enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; */ |
12 | 376 |
77 | 377 #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
|
378 #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
|
379 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
|
380 (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
|
381 } 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
|
382 #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
|
383 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
|
384 (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
|
385 } while(0) |
232
527894c2ad39
Add functions for collision test.
Thinker K.F. Li <thinker@branda.to>
parents:
224
diff
changeset
|
386 #define sh_get_geo(sh) ((sh)->geo) |
235 | 387 #define sh_get_geo_safe(sh) ((sh)? (sh)->geo: NULL) |
388 #define sh_get_flags(sh, mask) geo_get_flags(sh_get_geo(sh), mask) | |
389 #define sh_set_flags(sh, mask) geo_set_flags(sh_get_geo(sh), mask) | |
390 #define sh_clear_flags(sh, mask) geo_clear_flags(sh_get_geo(sh), mask) | |
391 #define sh_pos_is_in(sh, x, y) geo_pos_is_in(sh_get_geo(sh), x, y) | |
392 #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
|
393 #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
|
394 #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
|
395 #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
|
396 #define sh_get_stroke(sh) ((sh)->stroke) |
512
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
397 #define sh_set_stroke_width(sh, v) do { (sh)->stroke_width = (v); } while(0) |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
541
diff
changeset
|
398 #define sh_get_stroke_width(sh) (sh)->stroke_width |
1370
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
399 #define sh_copy_style(rdman, sh_src, sh_dst) do { \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
400 if(sh_get_fill(sh_src)) \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
401 rdman_paint_fill((rdman), sh_get_fill(sh_src), (sh_dst)); \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
402 if(sh_get_stroke(sh_src)) \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
403 rdman_paint_stroke((rdman), sh_get_stroke(sh_src), (sh_dst)); \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
404 (sh_dst)->stroke_width = (sh_src)->stroke_width; \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
405 (sh_dst)->stroke_linecap = (sh_src)->stroke_linecap; \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
406 (sh_dst)->stroke_linejoin = (sh_src)->stroke_linejoin; \ |
bae104d8d247
Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents:
1143
diff
changeset
|
407 } while(0) |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
408 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
409 #endif /* __MB_TYPES_H_ */ |