[layout] Add LayoutMeta

Instead of overloading ClutterChildMeta with both container and layout
metadata and delegate to every LayoutManager implementation to keep a
backpointer to the layout manager instance, we can simply subclass
ChildMeta into LayoutMeta and presto! everything works out pretty well
for everyone.
This commit is contained in:
Emmanuele Bassi 2009-09-15 17:37:11 +01:00
parent 899db6f226
commit a2086f1178
11 changed files with 364 additions and 108 deletions

View File

@ -82,6 +82,7 @@ source_h = \
$(srcdir)/clutter-interval.h \ $(srcdir)/clutter-interval.h \
$(srcdir)/clutter-keysyms.h \ $(srcdir)/clutter-keysyms.h \
$(srcdir)/clutter-layout-manager.h \ $(srcdir)/clutter-layout-manager.h \
$(srcdir)/clutter-layout-meta.h \
$(srcdir)/clutter-list-model.h \ $(srcdir)/clutter-list-model.h \
$(srcdir)/clutter-main.h \ $(srcdir)/clutter-main.h \
$(srcdir)/clutter-media.h \ $(srcdir)/clutter-media.h \
@ -150,6 +151,7 @@ source_c = \
$(srcdir)/clutter-id-pool.c \ $(srcdir)/clutter-id-pool.c \
$(srcdir)/clutter-interval.c \ $(srcdir)/clutter-interval.c \
$(srcdir)/clutter-layout-manager.c \ $(srcdir)/clutter-layout-manager.c \
$(srcdir)/clutter-layout-meta.c \
$(srcdir)/clutter-list-model.c \ $(srcdir)/clutter-list-model.c \
$(srcdir)/clutter-main.c \ $(srcdir)/clutter-main.c \
clutter-marshal.c \ clutter-marshal.c \

View File

@ -43,6 +43,7 @@
#include "clutter-child-meta.h" #include "clutter-child-meta.h"
#include "clutter-debug.h" #include "clutter-debug.h"
#include "clutter-enum-types.h" #include "clutter-enum-types.h"
#include "clutter-layout-meta.h"
#include "clutter-private.h" #include "clutter-private.h"
#define CLUTTER_TYPE_BIN_LAYER (clutter_bin_layer_get_type ()) #define CLUTTER_TYPE_BIN_LAYER (clutter_bin_layer_get_type ())
@ -52,7 +53,7 @@
#define CLUTTER_BIN_LAYOUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BIN_LAYOUT, ClutterBinLayoutPrivate)) #define CLUTTER_BIN_LAYOUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BIN_LAYOUT, ClutterBinLayoutPrivate))
typedef struct _ClutterBinLayer ClutterBinLayer; typedef struct _ClutterBinLayer ClutterBinLayer;
typedef struct _ClutterChildMetaClass ClutterBinLayerClass; typedef struct _ClutterLayoutMetaClass ClutterBinLayerClass;
struct _ClutterBinLayoutPrivate struct _ClutterBinLayoutPrivate
{ {
@ -65,9 +66,7 @@ struct _ClutterBinLayoutPrivate
struct _ClutterBinLayer struct _ClutterBinLayer
{ {
ClutterChildMeta parent_instance; ClutterLayoutMeta parent_instance;
ClutterBinLayout *layout;
ClutterBinAlignment x_align; ClutterBinAlignment x_align;
ClutterBinAlignment y_align; ClutterBinAlignment y_align;
@ -91,7 +90,7 @@ enum
G_DEFINE_TYPE (ClutterBinLayer, G_DEFINE_TYPE (ClutterBinLayer,
clutter_bin_layer, clutter_bin_layer,
CLUTTER_TYPE_CHILD_META); CLUTTER_TYPE_LAYOUT_META);
G_DEFINE_TYPE (ClutterBinLayout, G_DEFINE_TYPE (ClutterBinLayout,
clutter_bin_layout, clutter_bin_layout,
@ -107,14 +106,15 @@ set_layer_x_align (ClutterBinLayer *self,
ClutterBinAlignment alignment) ClutterBinAlignment alignment)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
ClutterLayoutMeta *meta;
if (self->x_align == alignment) if (self->x_align == alignment)
return; return;
self->x_align = alignment; self->x_align = alignment;
g_assert (self->layout != NULL); meta = CLUTTER_LAYOUT_META (self);
manager = CLUTTER_LAYOUT_MANAGER (self->layout); manager = clutter_layout_meta_get_manager (meta);
clutter_layout_manager_layout_changed (manager); clutter_layout_manager_layout_changed (manager);
g_object_notify (G_OBJECT (self), "x-align"); g_object_notify (G_OBJECT (self), "x-align");
@ -125,14 +125,15 @@ set_layer_y_align (ClutterBinLayer *self,
ClutterBinAlignment alignment) ClutterBinAlignment alignment)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
ClutterLayoutMeta *meta;
if (self->y_align == alignment) if (self->y_align == alignment)
return; return;
self->y_align = alignment; self->y_align = alignment;
g_assert (self->layout != NULL); meta = CLUTTER_LAYOUT_META (self);
manager = CLUTTER_LAYOUT_MANAGER (self->layout); manager = clutter_layout_meta_get_manager (meta);
clutter_layout_manager_layout_changed (manager); clutter_layout_manager_layout_changed (manager);
g_object_notify (G_OBJECT (self), "y-align"); g_object_notify (G_OBJECT (self), "y-align");
@ -371,7 +372,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
for (l = children; l != NULL; l = l->next) for (l = children; l != NULL; l = l->next)
{ {
ClutterActor *child = l->data; ClutterActor *child = l->data;
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
ClutterBinLayer *layer; ClutterBinLayer *layer;
ClutterActorBox child_alloc = { 0, }; ClutterActorBox child_alloc = { 0, };
gfloat child_width, child_height; gfloat child_width, child_height;
@ -475,26 +476,22 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
g_list_free (children); g_list_free (children);
} }
static ClutterChildMeta * static ClutterLayoutMeta *
clutter_bin_layout_create_child_meta (ClutterLayoutManager *manager, clutter_bin_layout_create_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
{ {
ClutterBinLayoutPrivate *priv; ClutterBinLayoutPrivate *priv;
ClutterChildMeta *meta;
priv = CLUTTER_BIN_LAYOUT (manager)->priv; priv = CLUTTER_BIN_LAYOUT (manager)->priv;
meta = g_object_new (CLUTTER_TYPE_BIN_LAYER, return g_object_new (CLUTTER_TYPE_BIN_LAYER,
"container", container, "container", container,
"actor", actor, "actor", actor,
"manager", manager,
"x-align", priv->x_align, "x-align", priv->x_align,
"y_align", priv->y_align, "y_align", priv->y_align,
NULL); NULL);
CLUTTER_BIN_LAYER (meta)->layout = CLUTTER_BIN_LAYOUT (manager);
return meta;
} }
static void static void
@ -659,7 +656,7 @@ clutter_bin_layout_set_alignment (ClutterBinLayout *self,
ClutterBinAlignment y_align) ClutterBinAlignment y_align)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
ClutterBinLayer *layer; ClutterBinLayer *layer;
g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self));
@ -696,7 +693,7 @@ clutter_bin_layout_get_alignment (ClutterBinLayout *self,
ClutterBinAlignment *y_align) ClutterBinAlignment *y_align)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
ClutterBinLayer *layer; ClutterBinLayer *layer;
g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self));

View File

@ -50,6 +50,7 @@
#include "clutter-debug.h" #include "clutter-debug.h"
#include "clutter-layout-manager.h" #include "clutter-layout-manager.h"
#include "clutter-layout-meta.h"
#include "clutter-marshal.h" #include "clutter-marshal.h"
#include "clutter-private.h" #include "clutter-private.h"
@ -115,7 +116,7 @@ layout_manager_real_allocate (ClutterLayoutManager *manager,
LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate"); LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate");
} }
static ClutterChildMeta * static ClutterLayoutMeta *
layout_manager_real_create_child_meta (ClutterLayoutManager *manager, layout_manager_real_create_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
@ -298,7 +299,7 @@ clutter_layout_manager_layout_changed (ClutterLayoutManager *manager)
g_signal_emit (manager, manager_signals[LAYOUT_CHANGED], 0); g_signal_emit (manager, manager_signals[LAYOUT_CHANGED], 0);
} }
static inline ClutterChildMeta * static inline ClutterLayoutMeta *
create_child_meta (ClutterLayoutManager *manager, create_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
@ -310,18 +311,23 @@ create_child_meta (ClutterLayoutManager *manager,
return klass->create_child_meta (manager, container, actor); return klass->create_child_meta (manager, container, actor);
} }
static inline ClutterChildMeta * static inline ClutterLayoutMeta *
get_child_meta (ClutterLayoutManager *manager, get_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *layout;
meta = g_object_get_qdata (G_OBJECT (actor), quark_layout_meta); layout = g_object_get_qdata (G_OBJECT (actor), quark_layout_meta);
if (meta != NULL && if (layout != NULL)
meta->container == container && {
meta->actor == actor) ClutterChildMeta *child = CLUTTER_CHILD_META (layout);
return meta;
if (layout->manager == manager &&
child->container == container &&
child->actor == actor)
return layout;
}
return NULL; return NULL;
} }
@ -332,14 +338,14 @@ get_child_meta (ClutterLayoutManager *manager,
* @container: a #ClutterContainer using @manager * @container: a #ClutterContainer using @manager
* @actor: a #ClutterActor child of @container * @actor: a #ClutterActor child of @container
* *
* Retrieves the #ClutterChildMeta that the layout @manager associated * Retrieves the #ClutterLayoutMeta that the layout @manager associated
* to the @actor child of @container * to the @actor child of @container
* *
* Return value: a #ClutterChildMeta or %NULL * Return value: a #ClutterLayoutMeta or %NULL
* *
* Since: 1.0 * Since: 1.0
*/ */
ClutterChildMeta * ClutterLayoutMeta *
clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager, clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
@ -357,13 +363,13 @@ clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager,
* @container: a #ClutterContainer using @manager * @container: a #ClutterContainer using @manager
* @actor: a #ClutterActor child of @container * @actor: a #ClutterActor child of @container
* *
* Creates and binds a #ClutterChildMeta for @manager to * Creates and binds a #ClutterLayoutMeta for @manager to
* a child of @container * a child of @container
* *
* This function should only be used when implementing containers * This function should only be used when implementing containers
* using #ClutterLayoutManager and not by application code * using #ClutterLayoutManager and not by application code
* *
* Typically, containers should bind a #ClutterChildMeta created * Typically, containers should bind a #ClutterLayoutMeta created
* by a #ClutterLayoutManager when adding a new child, e.g.: * by a #ClutterLayoutManager when adding a new child, e.g.:
* *
* |[ * |[
@ -386,7 +392,7 @@ clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager,
* } * }
* ]| * ]|
* *
* The #ClutterChildMeta should be removed when removing an * The #ClutterLayoutMeta should be removed when removing an
* actor; see clutter_layout_manager_remove_child_meta() * actor; see clutter_layout_manager_remove_child_meta()
* *
* Since: 1.2 * Since: 1.2
@ -396,7 +402,7 @@ clutter_layout_manager_add_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
meta = create_child_meta (manager, container, actor); meta = create_child_meta (manager, container, actor);
if (meta == NULL) if (meta == NULL)
@ -413,13 +419,13 @@ clutter_layout_manager_add_child_meta (ClutterLayoutManager *manager,
* @container: a #ClutterContainer using @manager * @container: a #ClutterContainer using @manager
* @actor: a #ClutterActor child of @container * @actor: a #ClutterActor child of @container
* *
* Unbinds and unrefs a #ClutterChildMeta for @manager from * Unbinds and unrefs a #ClutterLayoutMeta for @manager from
* a child of @container * a child of @container
* *
* This function should only be used when implementing containers * This function should only be used when implementing containers
* using #ClutterLayoutManager and not by application code * using #ClutterLayoutManager and not by application code
* *
* Typically, containers should remove a #ClutterChildMeta created * Typically, containers should remove a #ClutterLayoutMeta created
* by a #ClutterLayoutManager when removing a child, e.g.: * by a #ClutterLayoutManager when removing a child, e.g.:
* *
* |[ * |[
@ -517,7 +523,7 @@ layout_get_property_internal (ClutterLayoutManager *manager,
* @first_property: the first property name * @first_property: the first property name
* @Varargs: a list of property name and value pairs * @Varargs: a list of property name and value pairs
* *
* Sets a list of properties and their values on the #ClutterChildMeta * Sets a list of properties and their values on the #ClutterLayoutMeta
* associated by @manager to a child of @container * associated by @manager to a child of @container
* *
* Languages bindings should use clutter_layout_manager_child_set_property() * Languages bindings should use clutter_layout_manager_child_set_property()
@ -532,7 +538,7 @@ clutter_layout_manager_child_set (ClutterLayoutManager *manager,
const gchar *first_property, const gchar *first_property,
...) ...)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
GObjectClass *klass; GObjectClass *klass;
const gchar *pname; const gchar *pname;
va_list var_args; va_list var_args;
@ -604,7 +610,7 @@ clutter_layout_manager_child_set (ClutterLayoutManager *manager,
* @property_name: the name of the property to set * @property_name: the name of the property to set
* @value: a #GValue with the value of the property to set * @value: a #GValue with the value of the property to set
* *
* Sets a property on the #ClutterChildMeta created by @manager and * Sets a property on the #ClutterLayoutMeta created by @manager and
* attached to a child of @container * attached to a child of @container
* *
* Since: 1.2 * Since: 1.2
@ -616,7 +622,7 @@ clutter_layout_manager_child_set_property (ClutterLayoutManager *manager,
const gchar *property_name, const gchar *property_name,
const GValue *value) const GValue *value)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
GObjectClass *klass; GObjectClass *klass;
GParamSpec *pspec; GParamSpec *pspec;
@ -658,7 +664,7 @@ clutter_layout_manager_child_set_property (ClutterLayoutManager *manager,
* @Varargs: a list of property name and return location for the value pairs * @Varargs: a list of property name and return location for the value pairs
* *
* Retrieves the values for a list of properties out of the * Retrieves the values for a list of properties out of the
* #ClutterChildMeta created by @manager and attached to the * #ClutterLayoutMeta created by @manager and attached to the
* child of a @container * child of a @container
* *
* Since: 1.2 * Since: 1.2
@ -670,7 +676,7 @@ clutter_layout_manager_child_get (ClutterLayoutManager *manager,
const gchar *first_property, const gchar *first_property,
...) ...)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
GObjectClass *klass; GObjectClass *klass;
const gchar *pname; const gchar *pname;
va_list var_args; va_list var_args;
@ -746,7 +752,7 @@ clutter_layout_manager_child_get (ClutterLayoutManager *manager,
* @property_name: the name of the property to get * @property_name: the name of the property to get
* @value: a #GValue with the value of the property to get * @value: a #GValue with the value of the property to get
* *
* Gets a property on the #ClutterChildMeta created by @manager and * Gets a property on the #ClutterLayoutMeta created by @manager and
* attached to a child of @container * attached to a child of @container
* *
* The #GValue must already be initialized to the type of the property * The #GValue must already be initialized to the type of the property
@ -762,7 +768,7 @@ clutter_layout_manager_child_get_property (ClutterLayoutManager *manager,
const gchar *property_name, const gchar *property_name,
GValue *value) GValue *value)
{ {
ClutterChildMeta *meta; ClutterLayoutMeta *meta;
GObjectClass *klass; GObjectClass *klass;
GParamSpec *pspec; GParamSpec *pspec;

View File

@ -31,6 +31,7 @@
#include <clutter/clutter-actor.h> #include <clutter/clutter-actor.h>
#include <clutter/clutter-container.h> #include <clutter/clutter-container.h>
#include <clutter/clutter-types.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -86,26 +87,26 @@ struct _ClutterLayoutManagerClass
GInitiallyUnownedClass parent_class; GInitiallyUnownedClass parent_class;
/*< public >*/ /*< public >*/
void (* get_preferred_width) (ClutterLayoutManager *manager, void (* get_preferred_width) (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
gfloat for_height, gfloat for_height,
gfloat *minimum_width_p, gfloat *minimum_width_p,
gfloat *natural_width_p); gfloat *natural_width_p);
void (* get_preferred_height) (ClutterLayoutManager *manager, void (* get_preferred_height) (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
gfloat for_width, gfloat for_width,
gfloat *minimum_height_p, gfloat *minimum_height_p,
gfloat *natural_height_p); gfloat *natural_height_p);
void (* allocate) (ClutterLayoutManager *manager, void (* allocate) (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
const ClutterActorBox *allocation, const ClutterActorBox *allocation,
ClutterAllocationFlags flags); ClutterAllocationFlags flags);
ClutterChildMeta *(* create_child_meta) (ClutterLayoutManager *manager, ClutterLayoutMeta *(* create_child_meta) (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor); ClutterActor *actor);
void (* layout_changed) (ClutterLayoutManager *manager); void (* layout_changed) (ClutterLayoutManager *manager);
/*< private >*/ /*< private >*/
/* padding for future expansion */ /* padding for future expansion */
@ -121,53 +122,53 @@ struct _ClutterLayoutManagerClass
GType clutter_layout_manager_get_type (void) G_GNUC_CONST; GType clutter_layout_manager_get_type (void) G_GNUC_CONST;
void clutter_layout_manager_get_preferred_width (ClutterLayoutManager *manager, void clutter_layout_manager_get_preferred_width (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
gfloat for_height, gfloat for_height,
gfloat *min_width_p, gfloat *min_width_p,
gfloat *nat_width_p); gfloat *nat_width_p);
void clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager, void clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
gfloat for_width, gfloat for_width,
gfloat *min_height_p, gfloat *min_height_p,
gfloat *nat_height_p); gfloat *nat_height_p);
void clutter_layout_manager_allocate (ClutterLayoutManager *manager, void clutter_layout_manager_allocate (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
const ClutterActorBox *allocation, const ClutterActorBox *allocation,
ClutterAllocationFlags flags); ClutterAllocationFlags flags);
void clutter_layout_manager_layout_changed (ClutterLayoutManager *manager); void clutter_layout_manager_layout_changed (ClutterLayoutManager *manager);
ClutterChildMeta *clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager, ClutterLayoutMeta *clutter_layout_manager_get_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor); ClutterActor *actor);
void clutter_layout_manager_add_child_meta (ClutterLayoutManager *manager, void clutter_layout_manager_add_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor); ClutterActor *actor);
void clutter_layout_manager_remove_child_meta (ClutterLayoutManager *manager, void clutter_layout_manager_remove_child_meta (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor); ClutterActor *actor);
void clutter_layout_manager_child_set (ClutterLayoutManager *manager, void clutter_layout_manager_child_set (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor, ClutterActor *actor,
const gchar *first_property, const gchar *first_property,
...) G_GNUC_NULL_TERMINATED;
void clutter_layout_manager_child_get (ClutterLayoutManager *manager,
ClutterContainer *container,
ClutterActor *actor,
const gchar *first_property,
...) G_GNUC_NULL_TERMINATED; ...) G_GNUC_NULL_TERMINATED;
void clutter_layout_manager_child_get (ClutterLayoutManager *manager, void clutter_layout_manager_child_set_property (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor, ClutterActor *actor,
const gchar *first_property, const gchar *property_name,
...) G_GNUC_NULL_TERMINATED; const GValue *value);
void clutter_layout_manager_child_set_property (ClutterLayoutManager *manager, void clutter_layout_manager_child_get_property (ClutterLayoutManager *manager,
ClutterContainer *container, ClutterContainer *container,
ClutterActor *actor, ClutterActor *actor,
const gchar *property_name, const gchar *property_name,
const GValue *value); GValue *value);
void clutter_layout_manager_child_get_property (ClutterLayoutManager *manager,
ClutterContainer *container,
ClutterActor *actor,
const gchar *property_name,
GValue *value);
G_END_DECLS G_END_DECLS

View File

@ -0,0 +1,142 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author:
* Emmanuele Bassi <ebassi@linux.intel.com>
*/
/**
* SECTION:clutter-layout-meta
* @short_description: Wrapper for actors inside a layout manager
*
* #ClutterLayoutMeta is a wrapper object created by #ClutterLayoutManager
* implementations in order to store child-specific data and properties.
*
* A #ClutterLayoutMeta wraps a #ClutterActor inside a #ClutterContainer
* using a #ClutterLayoutManager.
*
* #ClutterLayoutMeta is available since Clutter 1.2
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "clutter-layout-meta.h"
#include "clutter-debug.h"
#include "clutter-private.h"
G_DEFINE_ABSTRACT_TYPE (ClutterLayoutMeta,
clutter_layout_meta,
CLUTTER_TYPE_CHILD_META);
enum
{
PROP_0,
PROP_MANAGER
};
static void
clutter_layout_meta_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterLayoutMeta *layout_meta = CLUTTER_LAYOUT_META (object);
switch (prop_id)
{
case PROP_MANAGER:
layout_meta->manager = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_layout_meta_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterLayoutMeta *layout_meta = CLUTTER_LAYOUT_META (object);
switch (prop_id)
{
case PROP_MANAGER:
g_value_set_object (value, layout_meta->manager);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_layout_meta_class_init (ClutterLayoutMetaClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = clutter_layout_meta_set_property;
gobject_class->get_property = clutter_layout_meta_get_property;
/**
* ClutterLayoutMeta:manager:
*
* The #ClutterLayoutManager that created this #ClutterLayoutMeta.
*
* Since: 1.2
*/
pspec = g_param_spec_object ("manager",
"Manager",
"The manager that created this data",
CLUTTER_TYPE_LAYOUT_MANAGER,
G_PARAM_CONSTRUCT_ONLY |
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_MANAGER, pspec);
}
static void
clutter_layout_meta_init (ClutterLayoutMeta *self)
{
}
/**
* clutter_layout_meta_get_manager:
* @data: a #ClutterLayoutMeta
*
* Retrieves the actor wrapped by @data
*
* Return value: (transfer none): a #ClutterLayoutManager
*
* Since: 1.2
*/
ClutterLayoutManager *
clutter_layout_meta_get_manager (ClutterLayoutMeta *data)
{
g_return_val_if_fail (CLUTTER_IS_LAYOUT_META (data), NULL);
return data->manager;
}

View File

@ -0,0 +1,85 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author:
* Emmanuele Bassi <ebassi@linux.intel.com>
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_LAYOUT_META_H__
#define __CLUTTER_LAYOUT_META_H__
#include <clutter/clutter-types.h>
#include <clutter/clutter-child-meta.h>
#include <clutter/clutter-layout-manager.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_LAYOUT_META (clutter_layout_meta_get_type ())
#define CLUTTER_LAYOUT_META(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_LAYOUT_META, ClutterLayoutMeta))
#define CLUTTER_IS_LAYOUT_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_LAYOUT_META))
#define CLUTTER_LAYOUT_META_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_LAYOUT_META, ClutterLayoutMetaClass))
#define CLUTTER_IS_LAYOUT_META_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_LAYOUT_META))
#define CLUTTER_LAYOUT_META_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_LAYOUT_META, ClutterLayoutMetaClass))
/* ClutterLayoutMeta is defined in clutter-types.h */
typedef struct _ClutterLayoutMetaClass ClutterLayoutMetaClass;
/**
* ClutterLayoutMeta
* @manager: the layout manager handling this data
*
* Sub-class of #ClutterChildMeta specific for layout managers
*
* A #ClutterLayoutManager sub-class should create a #ClutterLayoutMeta
* instance by overriding the #ClutterLayoutManager::create_child_meta()
* virtual function
*
* Since: 1.2
*/
struct _ClutterLayoutMeta
{
/*< private >*/
ClutterChildMeta parent_instance;
/*< public >*/
ClutterLayoutManager *manager;
/*< private >*/
/* padding */
gpointer dummy;
};
struct _ClutterLayoutMetaClass
{
ClutterChildMetaClass parent_class;
};
GType clutter_layout_meta_get_type (void) G_GNUC_CONST;
ClutterLayoutManager *clutter_layout_meta_get_manager (ClutterLayoutMeta *data);
G_END_DECLS
#endif /* __CLUTTER_LAYOUT_META_H__ */

View File

@ -43,6 +43,7 @@ typedef struct _ClutterActor ClutterActor;
typedef struct _ClutterStage ClutterStage; typedef struct _ClutterStage ClutterStage;
typedef struct _ClutterContainer ClutterContainer; /* dummy */ typedef struct _ClutterContainer ClutterContainer; /* dummy */
typedef struct _ClutterChildMeta ClutterChildMeta; typedef struct _ClutterChildMeta ClutterChildMeta;
typedef struct _ClutterLayoutMeta ClutterLayoutMeta;
/** /**
* ClutterGravity: * ClutterGravity:

View File

@ -58,6 +58,7 @@
#include "clutter-interval.h" #include "clutter-interval.h"
#include "clutter-keysyms.h" #include "clutter-keysyms.h"
#include "clutter-layout-manager.h" #include "clutter-layout-manager.h"
#include "clutter-layout-meta.h"
#include "clutter-list-model.h" #include "clutter-list-model.h"
#include "clutter-main.h" #include "clutter-main.h"
#include "clutter-media.h" #include "clutter-media.h"

View File

@ -56,6 +56,7 @@
<xi:include href="xml/clutter-child-meta.xml"/> <xi:include href="xml/clutter-child-meta.xml"/>
<xi:include href="xml/clutter-media.xml"/> <xi:include href="xml/clutter-media.xml"/>
<xi:include href="xml/clutter-layout-manager.xml"/> <xi:include href="xml/clutter-layout-manager.xml"/>
<xi:include href="xml/clutter-layout-meta.xml"/>
</chapter> </chapter>
<chapter> <chapter>
@ -207,13 +208,13 @@
<chapter id="clutterobjecthierarchy"> <chapter id="clutterobjecthierarchy">
<title>Object Hierarchy</title> <title>Object Hierarchy</title>
<xi:include href="xml/tree_index.sgml"/> <xi:include href="xml/tree_index.sgml"><xi:fallback /></xi:include>
</chapter> </chapter>
<chapter id="clutterobjectindex"> <chapter id="clutterobjectindex">
<title>Object Index</title> <title>Object Index</title>
<xi:include href="xml/object_index.sgml"/> <xi:include href="xml/object_index.sgml"><xi:fallback /></xi:include>
</chapter> </chapter>
</part> </part>

View File

@ -1819,3 +1819,22 @@ CLUTTER_BOX_GET_CLASS
ClutterBoxPrivate ClutterBoxPrivate
clutter_box_get_type clutter_box_get_type
</SECTION> </SECTION>
<SECTION>
<TITLE>ClutterLayoutMeta</TITLE>
<FILE>clutter-layout-meta</FILE>
ClutterLayoutMeta
ClutterLayoutMetaClass
clutter_layout_meta_get_manager
<SUBSECTION Standard>
CLUTTER_TYPE_LAYOUT_META
CLUTTER_LAYOUT_META
CLUTTER_LAYOUT_META_CLASS
CLUTTER_IS_LAYOUT_META
CLUTTER_IS_LAYOUT_META_CLASS
CLUTTER_LAYOUT_META_GET_CLASS
<SUBSECTION Private>
clutter_layout_meta_get_type
</SECTION>

View File

@ -35,5 +35,6 @@ clutter_stage_manager_get_type
clutter_binding_pool_get_type clutter_binding_pool_get_type
clutter_box_get_type clutter_box_get_type
clutter_layout_manager_get_type clutter_layout_manager_get_type
clutter_layout_meta_get_type
clutter_fixed_layout_get_type clutter_fixed_layout_get_type
clutter_bin_layout_get_type clutter_bin_layout_get_type