comparison src/mb_types.h @ 12:79e9edf4c00a

Add redraw manager
author Thinker K.F. Li <thinker@branda.to>
date Mon, 28 Jul 2008 17:45:36 +0800
parents 128af06c876c
children ed55009d96d3
comparison
equal deleted inserted replaced
11:128af06c876c 12:79e9edf4c00a
1 #ifndef __MB_TYPES_H_ 1 #ifndef __MB_TYPES_H_
2 #define __MB_TYPES_H_ 2 #define __MB_TYPES_H_
3 3
4 #include "tools.h"
5
4 typedef float co_aix; 6 typedef float co_aix;
5 typedef struct _shape shape_t; 7 typedef struct _shape shape_t;
8 typedef struct _geo geo_t;
6 9
7 /*! \brief A coordination system. 10 /*! \brief A coordination system.
8 * 11 *
9 * It have a transform function defined by matrix to transform 12 * It have a transform function defined by matrix to transform
10 * coordination from source space to target space. 13 * coordination from source space to target space.
11 * Source space is where the contained is drawed, and target space 14 * Source space is where the contained is drawed, and target space
12 * is where the coordination of parent container of the element 15 * is where the coordination of parent container of the element
13 * represented by this coord object. 16 * represented by this coord object.
17 *
18 * \dot
19 * digraph G {
20 * graph [rankdir=LR];
21 * root -> child00 -> child10 -> child20 [label="children" color="blue"];
22 * child00 -> child01 -> child02 [label="sibling"];
23 * child10 -> child11 [label="sibling"];
24 * }
25 * \enddot
14 */ 26 */
15 typedef struct _coord { 27 typedef struct _coord {
16 int seq; 28 unsigned int seq;
17 co_aix matrix[6]; 29 co_aix matrix[6];
18 co_aix aggr_matrix[6]; 30 co_aix aggr_matrix[6];
19 struct _coord *parent; 31 struct _coord *parent;
20 struct _coord *children, *sibling; 32 STAILQ(struct _coord) children;
21 shape_t *members; 33 struct _coord *sibling;
34 STAILQ(shape_t) members; /*!< All shape objects in this coord. */
22 } coord_t; 35 } coord_t;
23
24
25 typedef struct _geo geo_t;
26 struct _shape {
27 int sh_type;
28 geo_t *geo;
29 struct _shape *sibling;
30 };
31
32 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT };
33 36
34 extern void coord_init(coord_t *co, coord_t *parent); 37 extern void coord_init(coord_t *co, coord_t *parent);
35 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); 38 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y);
36 extern void update_aggr_matrix(coord_t *start); 39 extern void update_aggr_matrix(coord_t *start);
40 extern coord_t *preorder_coord_tree(coord_t *last);
41
42
43 /*! \brief A grahpic shape.
44 *
45 * \dot
46 * digraph G {
47 * "shape" -> "coord";
48 * "shape" -> "geo";
49 * "geo" -> "shape";
50 * "coord" -> "shape" [label="members"]
51 * "shape" -> "shape" [label="sibling"];
52 * }
53 * \enddot
54 */
55 struct _shape {
56 int sh_type;
57 geo_t *geo;
58 coord_t *coord;
59 shape_t *coord_mem_next;
60 struct _shape *sibling;
61 };
62 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT };
63
64 #define sh_attach_geo(sh, g) \
65 do { \
66 (sh)->geo = g; \
67 (g)->shape = (shape_t *)(sh); \
68 } while(0)
69 #define sh_detach_geo(sh) \
70 do { \
71 (sh)->geo->shape = NULL; \
72 (sh)->geo = NULL; \
73 } while(0)
74 extern void sh_attach_coord(shape_t *sh, coord_t *coord);
75 extern void sh_detach_coord(shape_t *sh);
76
77
78 /*! \brief Geometry data of a shape or a group of shape.
79 */
80 struct _geo {
81 shape_t *shape;
82 co_aix x, y;
83 co_aix w, h;
84 geo_t *next; /*!< \brief Link geo_t objects. */
85 unsigned int seq;
86 };
87
88 extern int is_overlay(geo_t *r1, geo_t *r2);
89 extern void geo_init(geo_t *g, int n_pos, co_aix pos[][2]);
90 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others,
91 int *n_overlays, geo_t **overlays);
92 #define geo_get_shape(g) ((g)->shape)
93 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0)
37 94
38 #endif /* __MB_TYPES_H_ */ 95 #endif /* __MB_TYPES_H_ */