Clean up ClutterEffect

Make ClutterEffectTemplate use a pointer to the private data to avoid
a type check each time it dereferences the ClutterEffectTemplatePrivate
structure pointer.

Clean up the header file for parsing purposes.

Add a description for the gtk-doc reference.
This commit is contained in:
Emmanuele Bassi 2007-07-01 10:29:34 +00:00
parent 52b5bad316
commit 255edd4e26
2 changed files with 80 additions and 72 deletions

View File

@ -29,6 +29,11 @@
* SECTION:clutter-effect * SECTION:clutter-effect
* @short_description: Utility Class for basic visual effects * @short_description: Utility Class for basic visual effects
* *
* The #ClutterEffectTemplate class provides a simple API for applying
* pre-defined effects to a single actor. It works as a wrapper around
* the #ClutterBehaviour objects
*
* Since: 0.4
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -71,8 +76,6 @@ G_DEFINE_TYPE (ClutterEffectTemplate, clutter_effect_template, G_TYPE_OBJECT);
CLUTTER_TYPE_EFFECT_TEMPLATE, \ CLUTTER_TYPE_EFFECT_TEMPLATE, \
ClutterEffectTemplatePrivate)) ClutterEffectTemplatePrivate))
typedef struct _ClutterEffectTemplatePrivate ClutterEffectTemplatePrivate;
struct _ClutterEffectTemplatePrivate struct _ClutterEffectTemplatePrivate
{ {
ClutterTimeline *timeline; ClutterTimeline *timeline;
@ -82,6 +85,7 @@ struct _ClutterEffectTemplatePrivate
enum enum
{ {
PROP_0, PROP_0,
PROP_ALPHA_FUNC, PROP_ALPHA_FUNC,
PROP_TIMELINE, PROP_TIMELINE,
}; };
@ -92,25 +96,17 @@ clutter_effect_template_dispose (GObject *object)
ClutterEffectTemplate *template; ClutterEffectTemplate *template;
ClutterEffectTemplatePrivate *priv; ClutterEffectTemplatePrivate *priv;
template = CLUTTER_EFFECT_TEMPLATE(object); template = CLUTTER_EFFECT_TEMPLATE (object);
priv = EFFECT_TEMPLATE_PRIVATE(template); priv = template->priv;
g_object_unref (priv->timeline); g_object_unref (priv->timeline);
priv->timeline = NULL; priv->timeline = NULL;
priv->alpha_func = NULL; priv->alpha_func = NULL;
if (G_OBJECT_CLASS (clutter_effect_template_parent_class)->dispose)
G_OBJECT_CLASS (clutter_effect_template_parent_class)->dispose (object); G_OBJECT_CLASS (clutter_effect_template_parent_class)->dispose (object);
} }
static void
clutter_effect_template_finalize (GObject *object)
{
G_OBJECT_CLASS (clutter_effect_template_parent_class)->finalize (object);
}
static void static void
clutter_effect_template_set_property (GObject *object, clutter_effect_template_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -120,8 +116,8 @@ clutter_effect_template_set_property (GObject *object,
ClutterEffectTemplate *template; ClutterEffectTemplate *template;
ClutterEffectTemplatePrivate *priv; ClutterEffectTemplatePrivate *priv;
template = CLUTTER_EFFECT_TEMPLATE(object); template = CLUTTER_EFFECT_TEMPLATE (object);
priv = EFFECT_TEMPLATE_PRIVATE(template); priv = template->priv;
switch (prop_id) switch (prop_id)
{ {
@ -147,8 +143,8 @@ clutter_effect_template_get_property (GObject *object,
ClutterEffectTemplate *template; ClutterEffectTemplate *template;
ClutterEffectTemplatePrivate *priv; ClutterEffectTemplatePrivate *priv;
template = CLUTTER_EFFECT_TEMPLATE(object); template = CLUTTER_EFFECT_TEMPLATE (object);
priv = EFFECT_TEMPLATE_PRIVATE(template); priv = template->priv;
switch (prop_id) switch (prop_id)
{ {
@ -172,8 +168,6 @@ clutter_effect_template_class_init (ClutterEffectTemplateClass *klass)
g_type_class_add_private (klass, sizeof (ClutterEffectTemplatePrivate)); g_type_class_add_private (klass, sizeof (ClutterEffectTemplatePrivate));
object_class->dispose = clutter_effect_template_dispose; object_class->dispose = clutter_effect_template_dispose;
object_class->finalize = clutter_effect_template_finalize;
object_class->set_property = clutter_effect_template_set_property; object_class->set_property = clutter_effect_template_set_property;
object_class->get_property = clutter_effect_template_get_property; object_class->get_property = clutter_effect_template_get_property;
@ -200,6 +194,7 @@ clutter_effect_template_class_init (ClutterEffectTemplateClass *klass)
static void static void
clutter_effect_template_init (ClutterEffectTemplate *self) clutter_effect_template_init (ClutterEffectTemplate *self)
{ {
self->priv = EFFECT_TEMPLATE_PRIVATE (self);
} }
/** /**
@ -239,7 +234,7 @@ clutter_effect_closure_destroy (ClutterEffectClosure *c)
g_slice_free (ClutterEffectClosure, c); g_slice_free (ClutterEffectClosure, c);
} }
static ClutterEffectClosure* static ClutterEffectClosure *
clutter_effect_closure_new (ClutterEffectTemplate *template, clutter_effect_closure_new (ClutterEffectTemplate *template,
ClutterActor *actor, ClutterActor *actor,
GCallback complete) GCallback complete)

View File

@ -27,6 +27,7 @@
#define _CLUTTER_EFFECT #define _CLUTTER_EFFECT
#include <glib-object.h> #include <glib-object.h>
#include <clutter/clutter-actor.h>
#include <clutter/clutter-timeline.h> #include <clutter/clutter-timeline.h>
#include <clutter/clutter-alpha.h> #include <clutter/clutter-alpha.h>
#include <clutter/clutter-behaviour.h> #include <clutter/clutter-behaviour.h>
@ -59,40 +60,52 @@ typedef void (*ClutterEffectCompleteFunc) (ClutterActor *actor,
CLUTTER_TYPE_EFFECT_TEMPLATE, ClutterEffectTemplateClass)) CLUTTER_TYPE_EFFECT_TEMPLATE, ClutterEffectTemplateClass))
typedef struct _ClutterEffectTemplate ClutterEffectTemplate; typedef struct _ClutterEffectTemplate ClutterEffectTemplate;
typedef struct _ClutterEffectTemplatePrivate ClutterEffectTemplatePrivate;
typedef struct _ClutterEffectTemplateClass ClutterEffectTemplateClass; typedef struct _ClutterEffectTemplateClass ClutterEffectTemplateClass;
struct _ClutterEffectTemplate{
GObject parent; struct _ClutterEffectTemplate
{
GObject parent_instance;
/*< private >*/
ClutterEffectTemplatePrivate *priv;
}; };
struct _ClutterEffectTemplateClass{ struct _ClutterEffectTemplateClass
{
GObjectClass parent_class; GObjectClass parent_class;
/*< private >*/
/* padding, for future expansion */
void (*_clutter_reserved1) (void);
void (*_clutter_reserved2) (void);
void (*_clutter_reserved3) (void);
void (*_clutter_reserved4) (void);
}; };
GType clutter_effect_template_get_type (void); GType clutter_effect_template_get_type (void) G_GNUC_CONST;
ClutterEffectTemplate *clutter_effect_template_new (ClutterTimeline *timeline,
ClutterEffectTemplate*
clutter_effect_template_new (ClutterTimeline *timeline,
ClutterAlphaFunc alpha_func); ClutterAlphaFunc alpha_func);
ClutterTimeline* /*
clutter_effect_fade (ClutterEffectTemplate *template, * Clutter effects
*/
ClutterTimeline *clutter_effect_fade (ClutterEffectTemplate *template_,
ClutterActor *actor, ClutterActor *actor,
guint8 start_opacity, guint8 start_opacity,
guint8 end_opacity, guint8 end_opacity,
ClutterEffectCompleteFunc completed_func, ClutterEffectCompleteFunc completed_func,
gpointer completed_data); gpointer completed_data);
ClutterTimeline *clutter_effect_move (ClutterEffectTemplate *template_,
ClutterTimeline*
clutter_effect_move (ClutterEffectTemplate *template,
ClutterActor *actor, ClutterActor *actor,
const ClutterKnot *knots, const ClutterKnot *knots,
guint n_knots, guint n_knots,
ClutterEffectCompleteFunc completed_func, ClutterEffectCompleteFunc completed_func,
gpointer completed_data); gpointer completed_data);
ClutterTimeline *clutter_effect_scale (ClutterEffectTemplate *template_,
ClutterTimeline*
clutter_effect_scale (ClutterEffectTemplate *template,
ClutterActor *actor, ClutterActor *actor,
gdouble scale_begin, gdouble scale_begin,
gdouble scale_end, gdouble scale_end,