Mercurial > MadButterfly
annotate include/mb_shapes.h @ 257:50d253d0fcba
Simple image loader and image shape.
- img_ldr.c is a simple image loader that rooted on a directory
specified when a loader instance been created.
- sh_image_t is corresponding shape of image tag in SVG.
- This changeset is still buggy. It need more testing.
- svg2code.py is not ready for image tag.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 15 Jan 2009 16:46:47 +0800 |
parents | bcad1ccdf45c |
children | 29acbd8a0dd0 |
rev | line source |
---|---|
101 | 1 /*! \file |
2 * \brief Declare interfaces of shapes. | |
3 * | |
4 * \todo Add ellipse shape. | |
5 * \todo Add circle shape. | |
6 */ | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #ifndef __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 #define __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 |
12 | 10 #include <cairo.h> |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 #include "mb_types.h" |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
12 #include "mb_redraw_man.h" |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
13 #include "mb_img_ldr.h" |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
101 | 15 /*! \page define_shape How to Define Shapes |
27 | 16 * |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
17 * A shape implementation must include |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
18 * - rdman_shape_*_new() |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
19 * - clear memory for shape_t member. |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
20 * - assign *_free() to \ref shape_t::free. |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
21 * - make new object been managed by a redraw manager. |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
22 * - call rdman_shape_man() |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
23 * - *_free() |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
24 * - assigned to \ref shape_t::free. |
27 | 25 * - *_transform() |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
26 * - *_draw() |
108 | 27 * - first member variable of a shape type must be a shape_t. |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
28 * |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
29 * Must modify |
101 | 30 * - event.c::draw_shape_path() |
31 * - redraw_man.c::clean_shape() | |
32 * - redraw_man.c::draw_shape() | |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
33 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
34 * \section shape_transform Shape Transform |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
35 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
36 * All shape types must have a shape transform function. It is invoked by |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
37 * redraw_man.c::clean_shape(). It's task is to update \ref geo_t of the |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
38 * shape object. In most situtation, it call geo_from_positions() to |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
39 * update geo_t. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
40 * |
27 | 41 */ |
42 | |
101 | 43 /*! \defgroup shapes Shapes |
44 * @{ | |
45 */ | |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
46 |
101 | 47 /*! \defgroup shape_path Shape of Path |
48 * @{ | |
49 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
50 extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data); |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
51 extern shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, char *commands, co_aix *arg,int arg_cnt,int *fix_arg,int fix_arg_cnt); |
12 | 52 extern void sh_path_transform(shape_t *shape); |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
53 extern void sh_path_draw(shape_t *shape, cairo_t *cr); |
101 | 54 /* @} */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 |
101 | 56 /*! \defgroup shape_text Shape of Text |
57 * @{ | |
58 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
59 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
60 const char *txt, co_aix x, co_aix y, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
61 co_aix font_size, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
62 cairo_font_face_t *face); |
88
dd813dcc232c
New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
63 extern void sh_text_set_text(shape_t *shape, const char *txt); |
27 | 64 extern void sh_text_transform(shape_t *shape); |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
65 extern void sh_text_draw(shape_t *shape, cairo_t *cr); |
101 | 66 /* @} */ |
27 | 67 |
101 | 68 /*! \defgroup shape_rect Shape of Rectangle |
69 * @{ | |
70 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
71 extern shape_t *rdman_shape_rect_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
72 co_aix x, co_aix y, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
73 co_aix w, co_aix h, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
74 co_aix rx, co_aix ry); |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
75 extern void sh_rect_transform(shape_t *shape); |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
76 extern void sh_rect_draw(shape_t *shape, cairo_t *cr); |
40 | 77 extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, |
78 co_aix w, co_aix h, co_aix rx, co_aix ry); | |
101 | 79 /* @} */ |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
80 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
81 /*! \defgroup shape_image Shape of Image |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
82 * @{ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
83 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
84 extern shape_t *rdman_shape_image_new(redraw_man_t *rdman, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
85 mb_img_data_t *img_data, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
86 co_aix x, co_aix y, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
87 co_aix w, co_aix h); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
88 extern void sh_image_transform(shape_t *shape); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
89 extern void sh_image_draw(shape_t *shape, cairo_t *cr); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
90 extern void sh_image_set(shape_t *shape, co_aix x, co_aix y, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
91 co_aix w, co_aix h); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
92 /* @} */ |
101 | 93 /* @} */ |
27 | 94 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
95 #endif /* __SHAPES_H_ */ |