clutter: Remove ClutterAnimation

This removes ClutterAnimation and related tests. ClutterAnimation has
been deprecated for a long time, and replacements exist and are used by
e.g. GNOME Shell since a while back.

This also disables a few relatively unrelated interactive tests, as they
rely on ClutterAnimation to implement some animations they use to
illustrate what they actually test.

As interactive tests currently are more or less untestable due to any
interaction with them crashing, as well as they in practice means
rewriting the tests using non-deprecated animation APIs, they are not
ported right now. To actually port the interactive tests, it needs to be
possible to fist interact with them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
This commit is contained in:
Jonas Ådahl 2020-04-09 17:54:45 +02:00 committed by Georges Basile Stavracas Neto
parent b46bc98d44
commit 322b51cded
16 changed files with 19 additions and 1924 deletions

View File

@ -27,35 +27,23 @@
* @short_description: Interface for animatable classes
*
* #ClutterAnimatable is an interface that allows a #GObject class
* to control how a #ClutterAnimation will animate a property.
* to control how an actor will animate a property.
*
* Each #ClutterAnimatable should implement the
* #ClutterAnimatableInterface.interpolate_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_interpolate_property() passing the name of the
* currently animated property; the values interval; and the progress factor.
* The #ClutterAnimatable implementation should return the computed value for
* the animated
* property.
*
* #ClutterAnimatable is available since Clutter 1.0
*/
#include "clutter-build-config.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "clutter-animatable.h"
#include "clutter-interval.h"
#include "clutter-debug.h"
#include "clutter-private.h"
#include "deprecated/clutter-animation.h"
G_DEFINE_INTERFACE (ClutterAnimatable, clutter_animatable, G_TYPE_OBJECT);
static void

View File

@ -51,9 +51,6 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable,
* @interpolate_value: virtual function for interpolating the progress
* of a property
*
* Base interface for #GObject<!-- -->s that can be animated by a
* a #ClutterAnimation.
*
* Since: 1.0
*/
struct _ClutterAnimatableInterface

View File

@ -4,7 +4,6 @@
#define __CLUTTER_DEPRECATED_H_INSIDE__
#include "deprecated/clutter-actor.h"
#include "deprecated/clutter-animation.h"
#include "deprecated/clutter-box.h"
#include "deprecated/clutter-container.h"
#include "deprecated/clutter-group.h"

View File

@ -190,7 +190,7 @@ typedef enum /*< prefix=CLUTTER_REQUEST >*/
* @CLUTTER_ANIMATION_LAST: last animation mode, used as a guard for
* registered global alpha functions
*
* The animation modes used by #ClutterAnimation. This
* The animation modes used by #ClutterAnimatable. This
* enumeration can be expanded in later versions of Clutter.
*
* <figure id="easing-modes">

View File

@ -37,9 +37,6 @@
* any object taking a reference on a #ClutterInterval instance should
* also take ownership of the interval by using g_object_ref_sink().
*
* #ClutterInterval is used by #ClutterAnimation to define the
* interval of values that an implicit animation should tween over.
*
* #ClutterInterval can be subclassed to override the validation
* and value computation.
*

View File

@ -798,87 +798,6 @@ parse_signals (ClutterScript *script,
return retval;
}
/* define the names of the animation modes to match the ones
* that developers might be more accustomed to
*/
static const struct
{
const gchar *name;
ClutterAnimationMode mode;
} animation_modes[] = {
{ "linear", CLUTTER_LINEAR },
{ "easeInQuad", CLUTTER_EASE_IN_QUAD },
{ "easeOutQuad", CLUTTER_EASE_OUT_QUAD },
{ "easeInOutQuad", CLUTTER_EASE_IN_OUT_QUAD },
{ "easeInCubic", CLUTTER_EASE_IN_CUBIC },
{ "easeOutCubic", CLUTTER_EASE_OUT_CUBIC },
{ "easeInOutCubic", CLUTTER_EASE_IN_OUT_CUBIC },
{ "easeInQuart", CLUTTER_EASE_IN_QUART },
{ "easeOutQuart", CLUTTER_EASE_OUT_QUART },
{ "easeInOutQuart", CLUTTER_EASE_IN_OUT_QUART },
{ "easeInQuint", CLUTTER_EASE_IN_QUINT },
{ "easeOutQuint", CLUTTER_EASE_OUT_QUINT },
{ "easeInOutQuint", CLUTTER_EASE_IN_OUT_QUINT },
{ "easeInSine", CLUTTER_EASE_IN_SINE },
{ "easeOutSine", CLUTTER_EASE_OUT_SINE },
{ "easeInOutSine", CLUTTER_EASE_IN_OUT_SINE },
{ "easeInExpo", CLUTTER_EASE_IN_EXPO },
{ "easeOutExpo", CLUTTER_EASE_OUT_EXPO },
{ "easeInOutExpo", CLUTTER_EASE_IN_OUT_EXPO },
{ "easeInCirc", CLUTTER_EASE_IN_CIRC },
{ "easeOutCirc", CLUTTER_EASE_OUT_CIRC },
{ "easeInOutCirc", CLUTTER_EASE_IN_OUT_CIRC },
{ "easeInElastic", CLUTTER_EASE_IN_ELASTIC },
{ "easeOutElastic", CLUTTER_EASE_OUT_ELASTIC },
{ "easeInOutElastic", CLUTTER_EASE_IN_OUT_ELASTIC },
{ "easeInBack", CLUTTER_EASE_IN_BACK },
{ "easeOutBack", CLUTTER_EASE_OUT_BACK },
{ "easeInOutBack", CLUTTER_EASE_IN_OUT_BACK },
{ "easeInBounce", CLUTTER_EASE_IN_BOUNCE },
{ "easeOutBounce", CLUTTER_EASE_OUT_BOUNCE },
{ "easeInOutBounce", CLUTTER_EASE_IN_OUT_BOUNCE },
};
static const gint n_animation_modes = G_N_ELEMENTS (animation_modes);
gulong
_clutter_script_resolve_animation_mode (JsonNode *node)
{
gint i, res = CLUTTER_CUSTOM_MODE;
if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE)
return CLUTTER_CUSTOM_MODE;
if (json_node_get_value_type (node) == G_TYPE_INT64)
return json_node_get_int (node);
if (json_node_get_value_type (node) == G_TYPE_STRING)
{
const gchar *name = json_node_get_string (node);
/* XXX - we might be able to optimize by changing the ordering
* of the animation_modes array, e.g.
* - special casing linear
* - tokenizing ('ease', 'In', 'Sine') and matching on token
* - binary searching?
*/
for (i = 0; i < n_animation_modes; i++)
{
if (strcmp (animation_modes[i].name, name) == 0)
return animation_modes[i].mode;
}
if (_clutter_script_enum_from_string (CLUTTER_TYPE_ANIMATION_MODE,
name,
&res))
return res;
g_warning ("Unable to find the animation mode '%s'", name);
}
return CLUTTER_CUSTOM_MODE;
}
static void
clutter_script_parser_object_end (JsonParser *json_parser,
JsonObject *object)

View File

@ -110,8 +110,6 @@ gboolean _clutter_script_parse_node (ClutterScript *script,
GType _clutter_script_get_type_from_symbol (const gchar *symbol);
GType _clutter_script_get_type_from_class (const gchar *name);
gulong _clutter_script_resolve_animation_mode (JsonNode *node);
gboolean _clutter_script_enum_from_string (GType gtype,
const gchar *string,
gint *enum_value);

View File

@ -24,7 +24,6 @@
/**
* SECTION:clutter-timeline
* @short_description: A class for time-based events
* @see_also: #ClutterAnimation, #ClutterAnimator, #ClutterState
*
* #ClutterTimeline is a base class for managing time-based event that cause
* Clutter to redraw a stage, such as animations.
@ -71,7 +70,7 @@
* when reaching completion by using the #ClutterTimeline:auto-reverse property.
*
* Timelines are used in the Clutter animation framework by classes like
* #ClutterAnimation, #ClutterAnimator, and #ClutterState.
* #ClutterTransition.
*
* ## Defining Timelines in ClutterScript
*

View File

@ -79,8 +79,6 @@ typedef struct _ClutterKnot ClutterKnot;
typedef struct _ClutterMargin ClutterMargin;
typedef struct _ClutterPerspective ClutterPerspective;
typedef struct _ClutterAnimation ClutterAnimation;
typedef struct _ClutterInputDeviceTool ClutterInputDeviceTool;
typedef struct _ClutterInputDevice ClutterInputDevice;
typedef struct _ClutterVirtualInputDevice ClutterVirtualInputDevice;

File diff suppressed because it is too large Load Diff

View File

@ -1,152 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2008 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_ANIMATION_H__
#define __CLUTTER_ANIMATION_H__
#include <clutter/clutter-types.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_ANIMATION (clutter_animation_get_type ())
#define CLUTTER_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ANIMATION, ClutterAnimation))
#define CLUTTER_IS_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ANIMATION))
#define CLUTTER_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ANIMATION, ClutterAnimationClass))
#define CLUTTER_IS_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ANIMATION))
#define CLUTTER_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ANIMATION, ClutterAnimationClass))
typedef struct _ClutterAnimationPrivate ClutterAnimationPrivate;
typedef struct _ClutterAnimationClass ClutterAnimationClass;
/**
* ClutterAnimation:
*
* The #ClutterAnimation structure contains only private data and should
* be accessed using the provided functions.
*
* Since: 1.0
*
* Deprecated: 1.12: Use the implicit animation on #ClutterActor
*/
struct _ClutterAnimation
{
/*< private >*/
GObject parent_instance;
ClutterAnimationPrivate *priv;
};
/**
* ClutterAnimationClass:
* @started: class handler for the #ClutterAnimation::started signal
* @completed: class handler for the #ClutterAnimation::completed signal
*
* The #ClutterAnimationClass structure contains only private data and
* should be accessed using the provided functions.
*
* Since: 1.0
*
* Deprecated: 1.12: Use the implicit animation on #ClutterActor
*/
struct _ClutterAnimationClass
{
/*< private >*/
GObjectClass parent_class;
/*< public >*/
void (* started) (ClutterAnimation *animation);
void (* completed) (ClutterAnimation *animation);
/*< private >*/
/* padding for future expansion */
void (*_clutter_reserved1) (void);
void (*_clutter_reserved2) (void);
void (*_clutter_reserved3) (void);
void (*_clutter_reserved4) (void);
void (*_clutter_reserved5) (void);
void (*_clutter_reserved6) (void);
void (*_clutter_reserved7) (void);
void (*_clutter_reserved8) (void);
};
CLUTTER_DEPRECATED
GType clutter_animation_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED_FOR(clutter_property_transition_new)
ClutterAnimation * clutter_animation_new (void);
CLUTTER_DEPRECATED_FOR(clutter_transition_set_animatable)
void clutter_animation_set_object (ClutterAnimation *animation,
GObject *object);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_progress_mode)
void clutter_animation_set_mode (ClutterAnimation *animation,
gulong mode);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_progress_mode)
gulong clutter_animation_get_mode (ClutterAnimation *animation);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_duration)
void clutter_animation_set_duration (ClutterAnimation *animation,
guint msecs);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_duration)
guint clutter_animation_get_duration (ClutterAnimation *animation);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_repeat_count)
void clutter_animation_set_loop (ClutterAnimation *animation,
gboolean loop);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_repeat_count)
gboolean clutter_animation_get_loop (ClutterAnimation *animation);
CLUTTER_DEPRECATED
void clutter_animation_set_timeline (ClutterAnimation *animation,
ClutterTimeline *timeline);
CLUTTER_DEPRECATED
ClutterTimeline * clutter_animation_get_timeline (ClutterAnimation *animation);
CLUTTER_DEPRECATED
gboolean clutter_animation_has_property (ClutterAnimation *animation,
const gchar *property_name);
CLUTTER_DEPRECATED
ClutterInterval * clutter_animation_get_interval (ClutterAnimation *animation,
const gchar *property_name);
/*
* ClutterActor API
*/
CLUTTER_DEPRECATED
ClutterAnimation * clutter_actor_animate (ClutterActor *actor,
gulong mode,
guint duration,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
CLUTTER_DEPRECATED
ClutterAnimation * clutter_actor_animate_with_timeline (ClutterActor *actor,
gulong mode,
ClutterTimeline *timeline,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
#endif /* __CLUTTER_ANIMATION_DEPRECATED_H__ */

View File

@ -219,7 +219,6 @@ clutter_nonintrospected_sources = [
clutter_deprecated_headers = [
'deprecated/clutter-actor.h',
'deprecated/clutter-animation.h',
'deprecated/clutter-box.h',
'deprecated/clutter-container.h',
'deprecated/clutter-group.h',
@ -229,7 +228,6 @@ clutter_deprecated_headers = [
]
clutter_deprecated_sources = [
'deprecated/clutter-animation.c',
'deprecated/clutter-box.c',
'deprecated/clutter-group.c',
'deprecated/clutter-rectangle.c',

View File

@ -251,28 +251,6 @@ script_named_object (void)
g_free (test_file);
}
static void
script_animation (void)
{
ClutterScript *script = clutter_script_new ();
GObject *animation = NULL;
GError *error = NULL;
gchar *test_file;
test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-animation.json", NULL);
clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error)
g_print ("Error: %s", error->message);
g_assert_no_error (error);
animation = clutter_script_get_object (script, "test");
g_assert (CLUTTER_IS_ANIMATION (animation));
g_object_unref (script);
g_free (test_file);
}
static void
script_layout_property (void)
{
@ -383,7 +361,6 @@ CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/script/single-object", script_single)
CLUTTER_TEST_UNIT ("/script/container-child", script_child)
CLUTTER_TEST_UNIT ("/script/named-object", script_named_object)
CLUTTER_TEST_UNIT ("/script/animation", script_animation)
CLUTTER_TEST_UNIT ("/script/object-property", script_object_property)
CLUTTER_TEST_UNIT ("/script/layout-property", script_layout_property)
CLUTTER_TEST_UNIT ("/script/actor-margin", script_margin)

View File

@ -1,14 +0,0 @@
{
"type" : "ClutterAnimation",
"id" : "test",
"mode" : "easeInCubic",
"duration" : 500,
"object" : {
"type" : "ClutterRectangle",
"id" : "rect",
"opacity" : 128,
"width" : 100,
"height" : 16,
"color" : "white"
}
}

View File

@ -17,7 +17,6 @@ clutter_tests_interactive_link_args = [
clutter_tests_interactive_test_sources = [
'test-events.c',
'test-actors.c',
'test-shader-effects.c',
'test-script.c',
'test-grab.c',
'test-cogl-shader-glsl.c',
@ -25,9 +24,7 @@ clutter_tests_interactive_test_sources = [
'test-cogl-tex-convert.c',
'test-cogl-offscreen.c',
'test-cogl-tex-polygon.c',
'test-cogl-multitexture.c',
'test-paint-wrapper.c',
'test-layout.c',
'test-animation.c',
'test-easing.c',
'test-binding-pool.c',
@ -38,11 +35,9 @@ clutter_tests_interactive_test_sources = [
'test-stage-sizing.c',
'test-swipe-action.c',
'test-cogl-point-sprites.c',
'test-path-constraint.c',
'test-devices.c',
'test-content.c',
'test-keyframe-transition.c',
'test-bind-constraint.c',
'test-touch-events.c',
'test-rotate-zoom.c',
'test-image.c',

View File

@ -53,8 +53,6 @@ static gboolean recenter = FALSE;
static ClutterActor *main_stage = NULL;
static ClutterActor *easing_mode_label = NULL;
static ClutterAnimation *last_animation = NULL;
int
test_easing_main (int argc, char *argv[]);
@ -66,21 +64,23 @@ test_easing_describe (void);
* repositions (through an animation) the bouncer at the center of the stage
*/
static void
recenter_bouncer (ClutterAnimation *animation,
ClutterActor *rectangle)
recenter_bouncer (ClutterActor *rectangle)
{
gfloat base_x, base_y;
gint cur_mode;
cur_mode = easing_modes[current_mode].mode;
base_x = clutter_actor_get_width (main_stage) / 2;
base_y = clutter_actor_get_height (main_stage) / 2;
cur_mode = easing_modes[current_mode].mode;
clutter_actor_set_easing_duration (rectangle, 250);
clutter_actor_set_easing_mode (rectangle, cur_mode);
clutter_actor_set_position (rectangle, base_x, base_y);
clutter_actor_animate (rectangle, cur_mode, 250,
"x", base_x,
"y", base_y,
NULL);
g_signal_connect_after (rectangle, "transition-completed",
G_CALLBACK (clutter_actor_restore_easing_state),
NULL);
}
static gboolean
@ -108,28 +108,22 @@ on_button_press (ClutterActor *actor,
}
else if (event->button == CLUTTER_BUTTON_PRIMARY)
{
ClutterAnimation *animation;
ClutterAnimationMode cur_mode;
cur_mode = easing_modes[current_mode].mode;
/* tween the actor using the current easing mode */
animation =
clutter_actor_animate (rectangle, cur_mode, duration * 1000,
"x", event->x,
"y", event->y,
NULL);
clutter_actor_save_easing_state (rectangle);
clutter_actor_set_easing_duration (rectangle, duration * 1000);
clutter_actor_set_easing_mode (rectangle, cur_mode);
clutter_actor_set_position (rectangle, event->x, event->y);
/* if we were asked to, recenter the bouncer at the end of the
* animation. we keep track of the animation to avoid connecting
* the signal handler to the same Animation twice.
*/
if (recenter && last_animation != animation)
g_signal_connect_after (animation, "completed",
G_CALLBACK (recenter_bouncer),
rectangle);
last_animation = animation;
g_signal_connect_after (rectangle, "transition-completed",
G_CALLBACK (recenter_bouncer),
rectangle);
}
return TRUE;