Mercurial > MadButterfly
annotate src/mb_types.h @ 17:41f0907b27ac
Unittest for rdman_redraw_changed().
geo_init() is seperated into geo_init() and geo_from_positions().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 01 Aug 2008 23:32:22 +0800 |
parents | e17e12b112c4 |
children | 0f3baa488a62 |
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 |
12 | 4 #include "tools.h" |
5 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 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
|
7 typedef struct _shape shape_t; |
12 | 8 typedef struct _geo geo_t; |
13 | 9 typedef struct _area area_t; |
10 | |
11 struct _area { | |
12 co_aix x, y; | |
13 co_aix w, h; | |
14 }; | |
15 | |
16 /*! \brief Geometry data of a shape or a group of shape. | |
17 */ | |
18 struct _geo { | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
19 #ifdef GEO_ORDER |
13 | 20 unsigned int order; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
21 #endif |
13 | 22 unsigned int flags; |
23 shape_t *shape; | |
24 geo_t *next; /*!< \brief Link all geo objects. */ | |
25 | |
26 area_t *cur_area, *last_area; | |
27 area_t areas[2]; | |
28 }; | |
29 #define GEF_DIRTY 0x1 | |
30 | |
31 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
|
32 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
|
33 extern void geo_init(geo_t *g); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
34 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); |
13 | 35 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, |
36 int *n_overlays, geo_t **overlays); | |
37 #define geo_get_shape(g) ((g)->shape) | |
38 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) | |
39 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 /*! \brief A coordination system. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 * |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 * 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
|
44 * coordination from source space to target space. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 * 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
|
46 * 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
|
47 * represented by this coord object. |
12 | 48 * |
49 * \dot | |
50 * digraph G { | |
51 * graph [rankdir=LR]; | |
52 * root -> child00 -> child10 -> child20 [label="children" color="blue"]; | |
53 * child00 -> child01 -> child02 [label="sibling"]; | |
54 * child10 -> child11 [label="sibling"]; | |
55 * } | |
56 * \enddot | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 */ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 typedef struct _coord { |
13 | 59 unsigned int order; |
60 unsigned int flags; | |
61 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
|
62 area_t areas[2]; |
13 | 63 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 co_aix matrix[6]; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 co_aix aggr_matrix[6]; |
13 | 66 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 struct _coord *parent; |
12 | 68 STAILQ(struct _coord) children; |
69 struct _coord *sibling; | |
13 | 70 |
71 STAILQ(shape_t) members; /*!< All shape_t objects in this coord. */ | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 } coord_t; |
13 | 73 #define COF_DIRTY 0x1 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
74 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
75 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
|
76 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
77 extern void compute_aggr_of_coord(coord_t *coord); |
10 | 78 extern void update_aggr_matrix(coord_t *start); |
13 | 79 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); |
12 | 80 |
81 | |
82 /*! \brief A grahpic shape. | |
83 * | |
84 * \dot | |
85 * digraph G { | |
86 * "shape" -> "coord"; | |
87 * "shape" -> "geo"; | |
88 * "geo" -> "shape"; | |
89 * "coord" -> "shape" [label="members"] | |
90 * "shape" -> "shape" [label="sibling"]; | |
91 * } | |
92 * \enddot | |
93 */ | |
94 struct _shape { | |
95 int sh_type; | |
96 geo_t *geo; | |
97 coord_t *coord; | |
98 shape_t *coord_mem_next; | |
99 }; | |
100 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT }; | |
101 | |
102 #define sh_attach_geo(sh, g) \ | |
103 do { \ | |
104 (sh)->geo = g; \ | |
105 (g)->shape = (shape_t *)(sh); \ | |
106 } while(0) | |
107 #define sh_detach_geo(sh) \ | |
108 do { \ | |
109 (sh)->geo->shape = NULL; \ | |
110 (sh)->geo = NULL; \ | |
111 } while(0) | |
112 extern void sh_attach_coord(shape_t *sh, coord_t *coord); | |
113 extern void sh_detach_coord(shape_t *sh); | |
114 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
115 #endif /* __MB_TYPES_H_ */ |