Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-path.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By Matthew Allum  <mallum@openedhand.com>
7  *
8  * Copyright (C) 2008 Intel Corporation
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
25 #error "Only <clutter/clutter.h> can be included directly."
26 #endif
27
28 #ifndef __CLUTTER_PATH_H__
29 #define __CLUTTER_PATH_H__
30
31 #include <cairo.h>
32 #include <clutter/clutter-types.h>
33
34 G_BEGIN_DECLS
35
36 #define CLUTTER_TYPE_PATH               (clutter_path_get_type ())
37 #define CLUTTER_TYPE_PATH_NODE          (clutter_path_node_get_type ())
38 #define CLUTTER_PATH(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_PATH, ClutterPath))
39 #define CLUTTER_PATH_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_PATH, ClutterPathClass))
40 #define CLUTTER_IS_PATH(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_PATH))
41 #define CLUTTER_IS_PATH_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_PATH))
42 #define CLUTTER_PATH_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_PATH, ClutterPathClass))
43
44 typedef struct _ClutterPathClass   ClutterPathClass;
45 typedef struct _ClutterPathPrivate ClutterPathPrivate;
46 typedef struct _ClutterPathNode    ClutterPathNode;
47
48 /**
49  * ClutterPathCallback:
50  * @node: the node
51  * @data: (closure): optional data passed to the function
52  *
53  * This function is passed to clutter_path_foreach() and will be
54  * called for each node contained in the path.
55  *
56  * Since: 1.0
57  */
58 typedef void (* ClutterPathCallback) (const ClutterPathNode *node,
59                                       gpointer               data);
60
61 /**
62  * ClutterPath:
63  *
64  * The #ClutterPath struct contains only private data and should
65  * be accessed with the functions below.
66  *
67  * Since: 1.0
68  */
69 struct _ClutterPath
70 {
71   /*< private >*/
72   GInitiallyUnowned parent;
73
74   ClutterPathPrivate *priv;
75 };
76
77 /**
78  * ClutterPathClass:
79  *
80  * The #ClutterPathClass struct contains only private data.
81  *
82  * Since: 1.0
83  */
84 struct _ClutterPathClass
85 {
86   /*< private >*/
87   GInitiallyUnownedClass parent_class;
88 };
89
90 /**
91  * ClutterPathNode:
92  * @type: the node's type
93  * @points: the coordinates of the node
94  *
95  * Represents a single node of a #ClutterPath.
96  *
97  * Some of the coordinates in @points may be unused for some node
98  * types. %CLUTTER_PATH_MOVE_TO and %CLUTTER_PATH_LINE_TO use only one
99  * pair of coordinates, %CLUTTER_PATH_CURVE_TO uses all three and
100  * %CLUTTER_PATH_CLOSE uses none.
101  *
102  * Since: 1.0
103  */
104 struct _ClutterPathNode
105 {
106   ClutterPathNodeType type;
107
108   ClutterKnot points[3];
109 };
110
111 GType clutter_path_get_type (void) G_GNUC_CONST;
112 GType clutter_path_node_get_type (void) G_GNUC_CONST;
113
114 ClutterPath *clutter_path_new                  (void);
115 ClutterPath *clutter_path_new_with_description (const gchar           *desc);
116 void         clutter_path_add_move_to          (ClutterPath           *path,
117                                                 gint                   x,
118                                                 gint                   y);
119 void         clutter_path_add_rel_move_to      (ClutterPath           *path,
120                                                 gint                   x,
121                                                 gint                   y);
122 void         clutter_path_add_line_to          (ClutterPath           *path,
123                                                 gint                   x,
124                                                 gint                   y);
125 void         clutter_path_add_rel_line_to      (ClutterPath           *path,
126                                                 gint                   x,
127                                                 gint                   y);
128 void         clutter_path_add_curve_to         (ClutterPath           *path,
129                                                 gint                   x_1,
130                                                 gint                   y_1,
131                                                 gint                   x_2,
132                                                 gint                   y_2,
133                                                 gint                   x_3,
134                                                 gint                   y_3);
135 void         clutter_path_add_rel_curve_to     (ClutterPath           *path,
136                                                 gint                   x_1,
137                                                 gint                   y_1,
138                                                 gint                   x_2,
139                                                 gint                   y_2,
140                                                 gint                   x_3,
141                                                 gint                   y_3);
142 void         clutter_path_add_close            (ClutterPath           *path);
143 gboolean     clutter_path_add_string           (ClutterPath           *path,
144                                                 const gchar           *str);
145 void         clutter_path_add_node             (ClutterPath           *path,
146                                                 const ClutterPathNode *node);
147 void         clutter_path_add_cairo_path       (ClutterPath           *path,
148                                                 const cairo_path_t    *cpath);
149 guint        clutter_path_get_n_nodes          (ClutterPath           *path);
150 void         clutter_path_get_node             (ClutterPath           *path,
151                                                 guint                  index_,
152                                                 ClutterPathNode       *node);
153 GSList *     clutter_path_get_nodes            (ClutterPath           *path);
154 void         clutter_path_foreach              (ClutterPath           *path,
155                                                 ClutterPathCallback    callback,
156                                                 gpointer               user_data);
157 void         clutter_path_insert_node          (ClutterPath           *path,
158                                                 gint                   index_,
159                                                 const ClutterPathNode *node);
160 void         clutter_path_remove_node          (ClutterPath           *path,
161                                                 guint                  index_);
162 void         clutter_path_replace_node         (ClutterPath           *path,
163                                                 guint                  index_,
164                                                 const ClutterPathNode *node);
165 gchar *      clutter_path_get_description      (ClutterPath           *path);
166 gboolean     clutter_path_set_description      (ClutterPath           *path,
167                                                 const gchar           *str);
168 void         clutter_path_clear                (ClutterPath           *path);
169 void         clutter_path_to_cairo_path        (ClutterPath           *path,
170                                                 cairo_t               *cr);
171 guint        clutter_path_get_position         (ClutterPath           *path,
172                                                 gdouble                progress,
173                                                 ClutterKnot           *position);
174 guint        clutter_path_get_length           (ClutterPath           *path);
175
176 ClutterPathNode *clutter_path_node_copy  (const ClutterPathNode *node);
177 void             clutter_path_node_free  (ClutterPathNode       *node);
178 gboolean         clutter_path_node_equal (const ClutterPathNode *node_a,
179                                           const ClutterPathNode *node_b);
180
181 G_END_DECLS
182
183 #endif /* __CLUTTER_PATH_H__ */