comparison src/mb_types.h @ 13:ed55009d96d3

refactory for redrawing
author Thinker K.F. Li <thinker@branda.to>
date Thu, 31 Jul 2008 08:10:00 +0800
parents 79e9edf4c00a
children d34232f15863
comparison
equal deleted inserted replaced
12:79e9edf4c00a 13:ed55009d96d3
4 #include "tools.h" 4 #include "tools.h"
5 5
6 typedef float co_aix; 6 typedef float co_aix;
7 typedef struct _shape shape_t; 7 typedef struct _shape shape_t;
8 typedef struct _geo geo_t; 8 typedef struct _geo geo_t;
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 {
19 unsigned int order;
20 unsigned int flags;
21 shape_t *shape;
22 geo_t *next; /*!< \brief Link all geo objects. */
23
24 area_t *cur_area, *last_area;
25 area_t areas[2];
26 };
27 #define GEF_DIRTY 0x1
28
29 extern int is_overlay(area_t *r1, area_t *r2);
30 extern void geo_init(geo_t *g, int n_pos, co_aix pos[][2]);
31 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others,
32 int *n_overlays, geo_t **overlays);
33 #define geo_get_shape(g) ((g)->shape)
34 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0)
35
9 36
10 /*! \brief A coordination system. 37 /*! \brief A coordination system.
11 * 38 *
12 * It have a transform function defined by matrix to transform 39 * It have a transform function defined by matrix to transform
13 * coordination from source space to target space. 40 * coordination from source space to target space.
23 * child10 -> child11 [label="sibling"]; 50 * child10 -> child11 [label="sibling"];
24 * } 51 * }
25 * \enddot 52 * \enddot
26 */ 53 */
27 typedef struct _coord { 54 typedef struct _coord {
28 unsigned int seq; 55 unsigned int order;
56 unsigned int flags;
57 area_t *cur_area, *last_area;
58
29 co_aix matrix[6]; 59 co_aix matrix[6];
30 co_aix aggr_matrix[6]; 60 co_aix aggr_matrix[6];
61
31 struct _coord *parent; 62 struct _coord *parent;
32 STAILQ(struct _coord) children; 63 STAILQ(struct _coord) children;
33 struct _coord *sibling; 64 struct _coord *sibling;
34 STAILQ(shape_t) members; /*!< All shape objects in this coord. */ 65
66 STAILQ(shape_t) members; /*!< All shape_t objects in this coord. */
35 } coord_t; 67 } coord_t;
68 #define COF_DIRTY 0x1
69 #define COF_RECOMP 0x2
36 70
37 extern void coord_init(coord_t *co, coord_t *parent); 71 extern void coord_init(coord_t *co, coord_t *parent);
38 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); 72 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y);
39 extern void update_aggr_matrix(coord_t *start); 73 extern void update_aggr_matrix(coord_t *start);
40 extern coord_t *preorder_coord_tree(coord_t *last); 74 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last);
41 75
42 76
43 /*! \brief A grahpic shape. 77 /*! \brief A grahpic shape.
44 * 78 *
45 * \dot 79 * \dot
55 struct _shape { 89 struct _shape {
56 int sh_type; 90 int sh_type;
57 geo_t *geo; 91 geo_t *geo;
58 coord_t *coord; 92 coord_t *coord;
59 shape_t *coord_mem_next; 93 shape_t *coord_mem_next;
60 struct _shape *sibling;
61 }; 94 };
62 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT }; 95 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT };
63 96
64 #define sh_attach_geo(sh, g) \ 97 #define sh_attach_geo(sh, g) \
65 do { \ 98 do { \
72 (sh)->geo = NULL; \ 105 (sh)->geo = NULL; \
73 } while(0) 106 } while(0)
74 extern void sh_attach_coord(shape_t *sh, coord_t *coord); 107 extern void sh_attach_coord(shape_t *sh, coord_t *coord);
75 extern void sh_detach_coord(shape_t *sh); 108 extern void sh_detach_coord(shape_t *sh);
76 109
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)
94
95 #endif /* __MB_TYPES_H_ */ 110 #endif /* __MB_TYPES_H_ */