Merge branch 'animatable-iface' into animation-improvements
* animatable-iface: [docs] Add ClutterAnimatable to the API reference Add license notice to ClutterAnimation files [animation] Use ClutterAnimatable inside Animation [animation] Add ClutterAnimatable
This commit is contained in:
commit
db3d2e9568
@ -47,6 +47,7 @@ BUILT_SOURCES = $(MARSHALFILES) $(ENUMFILES)
|
|||||||
source_h = \
|
source_h = \
|
||||||
$(srcdir)/clutter-actor.h \
|
$(srcdir)/clutter-actor.h \
|
||||||
$(srcdir)/clutter-alpha.h \
|
$(srcdir)/clutter-alpha.h \
|
||||||
|
$(srcdir)/clutter-animatable.h \
|
||||||
$(srcdir)/clutter-animation.h \
|
$(srcdir)/clutter-animation.h \
|
||||||
$(srcdir)/clutter-backend.h \
|
$(srcdir)/clutter-backend.h \
|
||||||
$(srcdir)/clutter-behaviour.h \
|
$(srcdir)/clutter-behaviour.h \
|
||||||
@ -138,6 +139,7 @@ CLEANFILES = $(STAMPFILES)
|
|||||||
source_c = \
|
source_c = \
|
||||||
clutter-actor.c \
|
clutter-actor.c \
|
||||||
clutter-alpha.c \
|
clutter-alpha.c \
|
||||||
|
clutter-animatable.c \
|
||||||
clutter-animation.c \
|
clutter-animation.c \
|
||||||
clutter-backend.c \
|
clutter-backend.c \
|
||||||
clutter-behaviour.c \
|
clutter-behaviour.c \
|
||||||
|
117
clutter/clutter-animatable.c
Normal file
117
clutter/clutter-animatable.c
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* 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-animatable
|
||||||
|
* @short_description: Interface for animatable classes
|
||||||
|
*
|
||||||
|
* #ClutterAnimatable is an interface that allows a #GObject class
|
||||||
|
* to control how a #ClutterAnimation will animate a property.
|
||||||
|
*
|
||||||
|
* Each #ClutterAnimatable should implement the animate_property()
|
||||||
|
* virtual function of the interface to compute the animation state
|
||||||
|
* between two values of an interval depending on a progress factor,
|
||||||
|
* expressed as a floating point value.
|
||||||
|
*
|
||||||
|
* If a #ClutterAnimatable is animated by a #ClutterAnimation
|
||||||
|
* instance, the #ClutterAnimation will call
|
||||||
|
* clutter_animatable_animate_property() passing the name of the
|
||||||
|
* currently animated property; the initial and final values of
|
||||||
|
* the animation interval; the progress factor. The #ClutterAnimatable
|
||||||
|
* implementation should return the computed value for the animated
|
||||||
|
* property.
|
||||||
|
*
|
||||||
|
* #ClutterAnimatable is available since Clutter 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "clutter-animatable.h"
|
||||||
|
#include "clutter-debug.h"
|
||||||
|
#include "clutter-private.h"
|
||||||
|
|
||||||
|
GType
|
||||||
|
clutter_animatable_get_type (void)
|
||||||
|
{
|
||||||
|
static GType a_type = 0;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (a_type == 0))
|
||||||
|
a_type = g_type_register_static_simple (G_TYPE_INTERFACE,
|
||||||
|
I_("ClutterAnimatable"),
|
||||||
|
sizeof (ClutterAnimatableIface),
|
||||||
|
NULL, 0, NULL, 0);
|
||||||
|
|
||||||
|
return a_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_animatable_animate_property:
|
||||||
|
* @animatable: a #ClutterAnimatable
|
||||||
|
* @animation: a #ClutterAnimation
|
||||||
|
* @property_name: the name of the animated property
|
||||||
|
* @initial_value: the initial value of the animation interval
|
||||||
|
* @final_value: the final value of the animation interval
|
||||||
|
* @progress: the progress factor
|
||||||
|
* @value: return location for the animation value
|
||||||
|
*
|
||||||
|
* Calls the animate_property() virtual function for @animatable.
|
||||||
|
*
|
||||||
|
* The @initial_value and @final_value #GValue<!-- -->s must contain
|
||||||
|
* the same type; @value must have been initialized to the same
|
||||||
|
* type of @initial_value and @final_value.
|
||||||
|
*
|
||||||
|
* All implementation of the #ClutterAnimatable interface must
|
||||||
|
* implement this function.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_animatable_animate_property (ClutterAnimatable *animatable,
|
||||||
|
ClutterAnimation *animation,
|
||||||
|
const gchar *property_name,
|
||||||
|
const GValue *initial_value,
|
||||||
|
const GValue *final_value,
|
||||||
|
gdouble progress,
|
||||||
|
GValue *value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
|
||||||
|
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
|
||||||
|
g_return_if_fail (property_name != NULL);
|
||||||
|
g_return_if_fail (initial_value != NULL && final_value != NULL);
|
||||||
|
g_return_if_fail (G_VALUE_TYPE (initial_value) != G_TYPE_INVALID);
|
||||||
|
g_return_if_fail (G_VALUE_TYPE (final_value) != G_TYPE_INVALID);
|
||||||
|
g_return_if_fail (value != NULL);
|
||||||
|
g_return_if_fail (G_VALUE_TYPE (value) == G_VALUE_TYPE (initial_value) &&
|
||||||
|
G_VALUE_TYPE (value) == G_VALUE_TYPE (final_value));
|
||||||
|
|
||||||
|
CLUTTER_ANIMATABLE_GET_IFACE (animatable)->animate_property (animatable,
|
||||||
|
animation,
|
||||||
|
property_name,
|
||||||
|
initial_value,
|
||||||
|
final_value,
|
||||||
|
progress,
|
||||||
|
value);
|
||||||
|
}
|
80
clutter/clutter-animatable.h
Normal file
80
clutter/clutter-animatable.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CLUTTER_ANIMATABLE_H__
|
||||||
|
#define __CLUTTER_ANIMATABLE_H__
|
||||||
|
|
||||||
|
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||||
|
#error "Only <clutter/clutter.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <clutter/clutter-animation.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_ANIMATABLE (clutter_animatable_get_type ())
|
||||||
|
#define CLUTTER_ANIMATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ANIMATABLE, ClutterAnimatable))
|
||||||
|
#define CLUTTER_IS_ANIMATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ANIMATABLE))
|
||||||
|
#define CLUTTER_ANIMATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_ANIMATABLE, ClutterAnimatableIface))
|
||||||
|
|
||||||
|
typedef struct _ClutterAnimatable ClutterAnimatable; /* dummy typedef */
|
||||||
|
typedef struct _ClutterAnimatableIface ClutterAnimatableIface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterAnimatableIface:
|
||||||
|
* @animate_property: virtual function for animating a property
|
||||||
|
*
|
||||||
|
* Base interface for #GObject<!-- -->s that can be animated by a
|
||||||
|
* a #ClutterAnimation.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
struct _ClutterAnimatableIface
|
||||||
|
{
|
||||||
|
/*< private >*/
|
||||||
|
GTypeInterface parent_iface;
|
||||||
|
|
||||||
|
/*< public >*/
|
||||||
|
void (* animate_property) (ClutterAnimatable *animatable,
|
||||||
|
ClutterAnimation *animation,
|
||||||
|
const gchar *property_name,
|
||||||
|
const GValue *initial_value,
|
||||||
|
const GValue *final_value,
|
||||||
|
gdouble progress,
|
||||||
|
GValue *value);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType clutter_animatable_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void clutter_animatable_animate_property (ClutterAnimatable *animatable,
|
||||||
|
ClutterAnimation *animation,
|
||||||
|
const gchar *property_name,
|
||||||
|
const GValue *initial_value,
|
||||||
|
const GValue *final_value,
|
||||||
|
gdouble progress,
|
||||||
|
GValue *value);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CLUTTER_ANIMATABLE_H__ */
|
@ -50,6 +50,7 @@
|
|||||||
#include <gobject/gvaluecollector.h>
|
#include <gobject/gvaluecollector.h>
|
||||||
|
|
||||||
#include "clutter-alpha.h"
|
#include "clutter-alpha.h"
|
||||||
|
#include "clutter-animatable.h"
|
||||||
#include "clutter-animation.h"
|
#include "clutter-animation.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-enum-types.h"
|
#include "clutter-enum-types.h"
|
||||||
@ -662,9 +663,17 @@ on_alpha_notify (GObject *gobject,
|
|||||||
ClutterAnimationPrivate *priv = animation->priv;
|
ClutterAnimationPrivate *priv = animation->priv;
|
||||||
GList *properties, *p;
|
GList *properties, *p;
|
||||||
guint32 alpha_value;
|
guint32 alpha_value;
|
||||||
|
gboolean is_animatable = FALSE;
|
||||||
|
ClutterAnimatable *animatable = NULL;
|
||||||
|
|
||||||
alpha_value = clutter_alpha_get_alpha (CLUTTER_ALPHA (gobject));
|
alpha_value = clutter_alpha_get_alpha (CLUTTER_ALPHA (gobject));
|
||||||
|
|
||||||
|
if (CLUTTER_IS_ANIMATABLE (priv->object))
|
||||||
|
{
|
||||||
|
animatable = CLUTTER_ANIMATABLE (priv->object);
|
||||||
|
is_animatable = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_freeze_notify (priv->object);
|
g_object_freeze_notify (priv->object);
|
||||||
|
|
||||||
properties = g_hash_table_get_keys (priv->properties);
|
properties = g_hash_table_get_keys (priv->properties);
|
||||||
@ -682,8 +691,29 @@ on_alpha_notify (GObject *gobject,
|
|||||||
|
|
||||||
factor = (gdouble) alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
|
factor = (gdouble) alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
|
||||||
|
|
||||||
if (clutter_interval_compute_value (interval, factor, &value))
|
if (is_animatable)
|
||||||
g_object_set_property (priv->object, p_name, &value);
|
{
|
||||||
|
const GValue *initial, *final;
|
||||||
|
|
||||||
|
initial = clutter_interval_peek_initial_value (interval);
|
||||||
|
final = clutter_interval_peek_final_value (interval);
|
||||||
|
|
||||||
|
CLUTTER_NOTE (ANIMATION, "Animatable property `%s'", p_name);
|
||||||
|
clutter_animatable_animate_property (animatable, animation,
|
||||||
|
p_name,
|
||||||
|
initial, final,
|
||||||
|
factor,
|
||||||
|
&value);
|
||||||
|
|
||||||
|
g_object_set_property (priv->object, p_name, &value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLUTTER_NOTE (ANIMATION, "Standard property `%s'", p_name);
|
||||||
|
|
||||||
|
if (clutter_interval_compute_value (interval, factor, &value))
|
||||||
|
g_object_set_property (priv->object, p_name, &value);
|
||||||
|
}
|
||||||
|
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "clutter-actor.h"
|
#include "clutter-actor.h"
|
||||||
#include "clutter-alpha.h"
|
#include "clutter-alpha.h"
|
||||||
|
#include "clutter-animatable.h"
|
||||||
#include "clutter-animation.h"
|
#include "clutter-animation.h"
|
||||||
#include "clutter-backend.h"
|
#include "clutter-backend.h"
|
||||||
#include "clutter-behaviour-depth.h"
|
#include "clutter-behaviour-depth.h"
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
|
|
||||||
<xi:include href="xml/clutter-interval.xml"/>
|
<xi:include href="xml/clutter-interval.xml"/>
|
||||||
<xi:include href="xml/clutter-animation.xml"/>
|
<xi:include href="xml/clutter-animation.xml"/>
|
||||||
|
<xi:include href="xml/clutter-animatable.xml"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
</part>
|
</part>
|
||||||
|
@ -210,6 +210,35 @@ ClutterCloneTexturePrivate
|
|||||||
clutter_clone_texture_get_type
|
clutter_clone_texture_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>clutter-cairo-texture</FILE>
|
||||||
|
<TITLE>ClutterCairoTexture</TITLE>
|
||||||
|
ClutterCairoTexture
|
||||||
|
ClutterCairoTextureClass
|
||||||
|
clutter_cairo_texture_new
|
||||||
|
clutter_cairo_texture_set_surface_size
|
||||||
|
clutter_cairo_texture_get_surface_size
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
clutter_cairo_texture_create
|
||||||
|
clutter_cairo_texture_create_region
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
clutter_cairo_set_source_color
|
||||||
|
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
CLUTTER_TYPE_CAIRO_TEXTURE
|
||||||
|
CLUTTER_CAIRO_TEXTURE
|
||||||
|
CLUTTER_IS_CAIRO_TEXTURE
|
||||||
|
CLUTTER_CAIRO_TEXTURE_CLASS
|
||||||
|
CLUTTER_IS_CAIRO_TEXTURE_CLASS
|
||||||
|
CLUTTER_CAIRO_TEXTURE_GET_CLASS
|
||||||
|
|
||||||
|
<SUBSECTION Private>
|
||||||
|
ClutterCairoTexturePrivate
|
||||||
|
clutter_cairo_texture_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>clutter-group</FILE>
|
<FILE>clutter-group</FILE>
|
||||||
<TITLE>ClutterGroup</TITLE>
|
<TITLE>ClutterGroup</TITLE>
|
||||||
@ -1641,6 +1670,10 @@ clutter_interval_get_interval
|
|||||||
clutter_interval_validate
|
clutter_interval_validate
|
||||||
clutter_interval_compute_value
|
clutter_interval_compute_value
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
ClutterProgressFunc
|
||||||
|
clutter_interval_register_progress_func
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
CLUTTER_TYPE_INTERVAL
|
CLUTTER_TYPE_INTERVAL
|
||||||
CLUTTER_INTERVAL
|
CLUTTER_INTERVAL
|
||||||
@ -1654,6 +1687,23 @@ ClutterIntervalPrivate
|
|||||||
clutter_interval_get_type
|
clutter_interval_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>clutter-animatable</FILE>
|
||||||
|
<TITLE>ClutterAnimatable</TITLE>
|
||||||
|
ClutterAnimatable
|
||||||
|
ClutterAnimatableIface
|
||||||
|
clutter_animatable_animate_property
|
||||||
|
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
CLUTTER_TYPE_ANIMATABLE
|
||||||
|
CLUTTER_ANIMATABLE
|
||||||
|
CLUTTER_IS_ANIMATABLE
|
||||||
|
CLUTTER_ANIMATABLE_GET_IFACE
|
||||||
|
|
||||||
|
<SUBSECTION Private>
|
||||||
|
clutter_animatable_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<TITLE>Key Bindings</TITLE>
|
<TITLE>Key Bindings</TITLE>
|
||||||
<FILE>clutter-binding-pool</FILE>
|
<FILE>clutter-binding-pool</FILE>
|
||||||
@ -1677,32 +1727,3 @@ clutter_binding_pool_unblock_action
|
|||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
clutter_binding_pool_activate
|
clutter_binding_pool_activate
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
|
||||||
<TITLE>ClutterCairoTexture</TITLE>
|
|
||||||
<FILE>clutter-cairo-texture</FILE>
|
|
||||||
ClutterCairoTexture
|
|
||||||
ClutterCairoTextureClass
|
|
||||||
clutter_cairo_texture_new
|
|
||||||
clutter_cairo_texture_set_surface_size
|
|
||||||
clutter_cairo_texture_get_surface_size
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
clutter_cairo_texture_create
|
|
||||||
clutter_cairo_texture_create_region
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
clutter_cairo_set_source_color
|
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
|
||||||
CLUTTER_TYPE_CAIRO_TEXTURE
|
|
||||||
CLUTTER_CAIRO_TEXTURE
|
|
||||||
CLUTTER_IS_CAIRO_TEXTURE
|
|
||||||
CLUTTER_CAIRO_TEXTURE_CLASS
|
|
||||||
CLUTTER_IS_CAIRO_TEXTURE_CLASS
|
|
||||||
CLUTTER_CAIRO_TEXTURE_GET_CLASS
|
|
||||||
|
|
||||||
<SUBSECTION Private>
|
|
||||||
ClutterCairoTexturePrivate
|
|
||||||
clutter_cairo_texture_get_type
|
|
||||||
</SECTION>
|
|
||||||
|
@ -29,3 +29,4 @@ clutter_score_get_type
|
|||||||
clutter_shader_get_type
|
clutter_shader_get_type
|
||||||
clutter_child_meta_get_type
|
clutter_child_meta_get_type
|
||||||
clutter_cairo_texture_get_type
|
clutter_cairo_texture_get_type
|
||||||
|
clutter_animatable_get_type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user