Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-container.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) 2006 OpenedHand
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  * ClutterContainer: Generic actor container interface.
24  * Author: Emmanuele Bassi <ebassi@openedhand.com>
25  */
26
27 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
28 #error "Only <clutter/clutter.h> can be included directly."
29 #endif
30
31 #ifndef __CLUTTER_CONTAINER_H__
32 #define __CLUTTER_CONTAINER_H__
33
34 #include <clutter/clutter-actor.h>
35 #include <clutter/clutter-child-meta.h>
36 #include <clutter/clutter-types.h>
37
38 G_BEGIN_DECLS
39
40 #define CLUTTER_TYPE_CONTAINER                  (clutter_container_get_type ())
41 #define CLUTTER_CONTAINER(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CONTAINER, ClutterContainer))
42 #define CLUTTER_IS_CONTAINER(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CONTAINER))
43 #define CLUTTER_CONTAINER_GET_IFACE(obj)        (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_CONTAINER, ClutterContainerIface))
44
45 typedef struct _ClutterContainerIface   ClutterContainerIface;
46
47 /**
48  * ClutterContainer:
49  *
50  * #ClutterContainer is an opaque structure whose members cannot be directly
51  * accessed
52  *
53  * Since: 0.4
54  */
55
56 /**
57  * ClutterContainerIface:
58  * @add: virtual function for adding an actor to the container. This virtual
59  *   function is deprecated, and it should not be overridden.
60  * @remove: virtual function for removing an actor from the container. This
61  *   virtual function is deprecated, and it should not be overridden.
62  * @foreach: virtual function for iterating over the container's children.
63  *   This virtual function is deprecated, and it should not be overridden.
64  * @foreach_with_internals: virtual functions for iterating over the
65  *   container's children, both added using the #ClutterContainer API
66  *   and internal children. The implementation of this virtual function
67  *   is required only if the #ClutterContainer implementation has
68  *   internal children. This virtual function is deprecated, and it should
69  *   not be overridden.
70  * @raise: virtual function for raising a child. This virtual function is
71  *   deprecated and it should not be overridden.
72  * @lower: virtual function for lowering a child. This virtual function is
73  *   deprecated and it should not be overridden.
74  * @sort_depth_order: virtual function for sorting the children of a
75  *   container depending on their depth. This virtual function is deprecated
76  *   and it should not be overridden.
77  * @child_meta_type: The GType used for storing auxiliary information about
78  *   each of the containers children.
79  * @create_child_meta: virtual function that gets called for each added
80  *   child, the function should instantiate an object of type
81  *   #ClutterContainerIface::child_meta_type, set the container and actor
82  *   fields in the instance and add the record to a data structure for
83  *   subsequent access for #ClutterContainerIface::get_child_meta
84  * @destroy_child_meta: virtual function that gets called when a child is
85  *   removed; it shuld release all resources held by the record
86  * @get_child_meta: return the record for a container child
87  * @actor_added: class handler for #ClutterContainer::actor-added
88  * @actor_removed: class handler for #ClutterContainer::actor-removed
89  * @child_notify: class handler for #ClutterContainer::child-notify
90  *
91  * Base interface for container actors. The @add, @remove and @foreach
92  * virtual functions must be provided by any implementation; the other
93  * virtual functions are optional.
94  *
95  * Since: 0.4
96  */
97 struct _ClutterContainerIface
98 {
99   /*< private >*/
100   GTypeInterface g_iface;
101
102   /*< public >*/
103   void (* add)              (ClutterContainer *container,
104                              ClutterActor     *actor);
105   void (* remove)           (ClutterContainer *container,
106                              ClutterActor     *actor);
107   void (* foreach)          (ClutterContainer *container,
108                              ClutterCallback   callback,
109                              gpointer          user_data);
110
111   void (* foreach_with_internals) (ClutterContainer *container,
112                                    ClutterCallback   callback,
113                                    gpointer          user_data);
114
115   /* child stacking */
116   void (* raise)            (ClutterContainer *container,
117                              ClutterActor     *actor,
118                              ClutterActor     *sibling);
119   void (* lower)            (ClutterContainer *container,
120                              ClutterActor     *actor,
121                              ClutterActor     *sibling);
122   void (* sort_depth_order) (ClutterContainer *container);
123
124   /* ClutterChildMeta management */
125   GType                child_meta_type;
126   void              (* create_child_meta)  (ClutterContainer *container,
127                                             ClutterActor     *actor);
128   void              (* destroy_child_meta) (ClutterContainer *container,
129                                             ClutterActor     *actor);
130   ClutterChildMeta *(* get_child_meta)     (ClutterContainer *container,
131                                             ClutterActor     *actor);
132
133   /* signals */
134   void (* actor_added)   (ClutterContainer *container,
135                           ClutterActor     *actor);
136   void (* actor_removed) (ClutterContainer *container,
137                           ClutterActor     *actor);
138
139   void (* child_notify)  (ClutterContainer *container,
140                           ClutterActor     *child,
141                           GParamSpec       *pspec);
142 };
143
144 GType         clutter_container_get_type         (void) G_GNUC_CONST;
145
146 ClutterActor *clutter_container_find_child_by_name     (ClutterContainer *container,
147                                                         const gchar      *child_name);
148
149 GParamSpec *      clutter_container_class_find_child_property   (GObjectClass     *klass,
150                                                                  const gchar      *property_name);
151 GParamSpec **     clutter_container_class_list_child_properties (GObjectClass     *klass,
152                                                                  guint            *n_properties);
153
154 void              clutter_container_create_child_meta           (ClutterContainer *container,
155                                                                  ClutterActor     *actor);
156 void              clutter_container_destroy_child_meta          (ClutterContainer *container,
157                                                                  ClutterActor     *actor);
158 ClutterChildMeta *clutter_container_get_child_meta              (ClutterContainer *container,
159                                                                  ClutterActor     *actor);
160
161 void              clutter_container_child_set_property          (ClutterContainer *container,
162                                                                  ClutterActor     *child,
163                                                                  const gchar      * property,
164                                                                  const GValue     *value);
165 void              clutter_container_child_get_property          (ClutterContainer *container,
166                                                                  ClutterActor     *child,
167                                                                  const gchar      *property,
168                                                                  GValue           *value);
169 void              clutter_container_child_set                   (ClutterContainer *container,
170                                                                  ClutterActor     *actor,
171                                                                  const gchar      *first_prop,
172                                                                  ...) G_GNUC_NULL_TERMINATED;
173 void              clutter_container_child_get                   (ClutterContainer *container,
174                                                                  ClutterActor     *actor,
175                                                                  const gchar      *first_prop,
176                                                                  ...) G_GNUC_NULL_TERMINATED;
177
178 void              clutter_container_child_notify                (ClutterContainer *container,
179                                                                  ClutterActor     *child,
180                                                                  GParamSpec       *pspec);
181
182 G_END_DECLS
183
184 #endif /* __CLUTTER_CONTAINER_H__ */