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