Mercurial > MadButterfly
annotate src/redraw_man.h @ 23:56f592f56ff7
Fix bug and add linear gradient paint.
- fix the bug that forget to clear n_dirty_geos in rdman_redraw_all().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 02 Aug 2008 23:10:42 +0800 |
parents | 8fcf2d878ecd |
children | e598bc809c0f |
rev | line source |
---|---|
12 | 1 #ifndef __REDRAW_MAN_H_ |
2 #define __REDRAW_MAN_H_ | |
3 | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
4 #include <cairo.h> |
12 | 5 #include "tools.h" |
6 #include "mb_types.h" | |
7 | |
13 | 8 /*! \brief Manage redrawing of shapes (graphic elements). |
9 * | |
10 * Every coord_t and geo_t object is assigned with a unique | |
11 * incremental order. The order is a unsigned integer. | |
12 * Every time a new coord_t or geo_t object is added, it is | |
13 * assigned with a order number that 1 bigger than last one | |
14 * until reaching maximum of unsigned integer. | |
15 * When a maximum is meet, all coord_t or geo_t objects | |
16 * are reasigned with a new order number from 1. It means | |
17 * order numbers that have been assigned and then removed | |
18 * later are recycled. | |
19 * | |
20 * Dirty flag is clear when the transformation matrix of a coord | |
21 * object been recomputed or when a geo_t objects been redrawed. | |
22 */ | |
12 | 23 typedef struct _redraw_man { |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
24 #ifdef GEO_ORDER |
13 | 25 unsigned int next_geo_order; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
26 #endif |
12 | 27 int n_geos; |
28 STAILQ(geo_t) all_geos; | |
13 | 29 |
30 unsigned int next_coord_order; | |
31 int n_coords; | |
12 | 32 coord_t *root_coord; |
13 | 33 |
12 | 34 elmpool_t *geo_pool; |
35 elmpool_t *coord_pool; | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
36 elmpool_t *shnode_pool; |
13 | 37 |
38 int max_dirty_coords; | |
39 int n_dirty_coords; | |
40 coord_t **dirty_coords; | |
41 | |
14 | 42 int max_dirty_geos; |
43 int n_dirty_geos; | |
44 geo_t **dirty_geos; | |
13 | 45 |
46 int max_dirty_areas; | |
47 int n_dirty_areas; | |
48 area_t **dirty_areas; | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
49 |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
50 cairo_t *cr; |
12 | 51 } redraw_man_t; |
52 | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
53 extern int redraw_man_init(redraw_man_t *rdman, cairo_t *cr); |
12 | 54 extern void redraw_man_destroy(redraw_man_t *rdman); |
55 extern int rdman_find_overlaid_shapes(redraw_man_t *rdman, | |
56 geo_t *geo, | |
57 geo_t ***overlays); | |
58 extern int rdman_add_shape(redraw_man_t *rdman, | |
59 shape_t *shape, coord_t *coord); | |
60 extern int rdman_remove_shape(redraw_man_t *rdman, shape_t *shape); | |
61 extern coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent); | |
62 extern int rdman_coord_free(redraw_man_t *rdman, coord_t *coord); | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
63 extern int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord); |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
64 extern int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
65 extern int rdman_redraw_changed(redraw_man_t *rdman); |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
66 extern int rdman_redraw_all(redraw_man_t *rdman); |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
67 extern shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape); |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
68 #define shnode_free(rdman, node) elmpool_elm_free((rdman)->shnode_pool, node) |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
69 #define shnode_list_free(rdman, q) \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
70 do { \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
71 shnode_t *__node, *__last; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
72 __last = STAILQ_HEAD(q); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
73 if(__last == NULL) break; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
74 for(__node = STAILQ_NEXT(shnode_t, next, __last); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
75 __node != NULL; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
76 __node = STAILQ_NEXT(shnode_t, next, __node)) { \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
77 shnode_free(rdman, __last); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
78 __last = __node; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
79 } \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
80 shnode_free(rdman, __last); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
81 } while(0) |
22 | 82 #define _rdman_paint_child(rdman, paint, shape) \ |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
83 do { \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
84 shnode_t *__node; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
85 if((shape)->fill != (paint) && \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
86 (shape)->stroke != (paint)) { \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
87 __node = shnode_new(rdman, shape); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
88 STAILQ_INS_TAIL((paint)->members, \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
89 shnode_t, next, __node); \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
90 } \ |
22 | 91 } while(0) |
92 #define rdman_paint_fill(rdman, paint, shape) \ | |
93 do { \ | |
94 _rdman_paint_child(rdman, paint, shape); \ | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
95 shape->fill = paint; \ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
96 } while(0) |
22 | 97 #define rdman_paint_stroke(rdman, paint, shape) \ |
98 do { \ | |
99 _rdman_paint_child(rdman, paint, shape); \ | |
100 shape->stroke = paint; \ | |
101 } while(0) | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
102 extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint); |
12 | 103 |
104 | |
105 #endif /* __REDRAW_MAN_H_ */ |