[mutter] clutter/animatable: Add way to get an actor from an animatable



commit d77bcb90282e6e9d5808d9bb79947cc04a9fc189
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Jun 23 20:23:37 2020 +0200

    clutter/animatable: Add way to get an actor from an animatable
    
    This will be used by ClutterTransition to associate the timeline with an
    actor, which itself will be used to determine what frame clock should
    drive the timeline.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285

 clutter/clutter/clutter-actor.c      |  7 +++++++
 clutter/clutter/clutter-animatable.c | 22 ++++++++++++++++++++++
 clutter/clutter/clutter-animatable.h |  5 +++++
 3 files changed, 34 insertions(+)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 095e80ed5f..1c323bc08d 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -13589,12 +13589,19 @@ clutter_actor_set_final_state (ClutterAnimatable *animatable,
   g_free (p_name);
 }
 
+static ClutterActor *
+clutter_actor_get_actor (ClutterAnimatable *animatable)
+{
+  return CLUTTER_ACTOR (animatable);
+}
+
 static void
 clutter_animatable_iface_init (ClutterAnimatableInterface *iface)
 {
   iface->find_property = clutter_actor_find_property;
   iface->get_initial_state = clutter_actor_get_initial_state;
   iface->set_final_state = clutter_actor_set_final_state;
+  iface->get_actor = clutter_actor_get_actor;
 }
 
 /**
diff --git a/clutter/clutter/clutter-animatable.c b/clutter/clutter/clutter-animatable.c
index e14012c5d8..8ea28de771 100644
--- a/clutter/clutter/clutter-animatable.c
+++ b/clutter/clutter/clutter-animatable.c
@@ -194,3 +194,25 @@ clutter_animatable_interpolate_value (ClutterAnimatable *animatable,
   else
     return clutter_interval_compute_value (interval, progress, value);
 }
+
+/**
+ * clutter_animatable_get_actor:
+ * @animatable: a #ClutterAnimatable
+ *
+ * Get animated actor.
+ *
+ * Return value: (transfer none): a #ClutterActor
+ */
+ClutterActor *
+clutter_animatable_get_actor (ClutterAnimatable *animatable)
+{
+  ClutterAnimatableInterface *iface;
+
+  g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), NULL);
+
+  iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
+
+  g_return_val_if_fail (iface->get_actor, NULL);
+
+  return iface->get_actor (animatable);
+}
diff --git a/clutter/clutter/clutter-animatable.h b/clutter/clutter/clutter-animatable.h
index d03e0589de..5b18f37959 100644
--- a/clutter/clutter/clutter-animatable.h
+++ b/clutter/clutter/clutter-animatable.h
@@ -50,6 +50,7 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable,
  *   animatable property
  * @interpolate_value: virtual function for interpolating the progress
  *   of a property
+ * @get_actor: virtual function for getting associated actor
  *
  * Since: 1.0
  */
@@ -72,6 +73,7 @@ struct _ClutterAnimatableInterface
                                      ClutterInterval   *interval,
                                      gdouble            progress,
                                      GValue            *value);
+  ClutterActor * (* get_actor)      (ClutterAnimatable *animatable);
 };
 
 CLUTTER_EXPORT
@@ -92,6 +94,9 @@ gboolean    clutter_animatable_interpolate_value (ClutterAnimatable *animatable,
                                                   gdouble            progress,
                                                   GValue            *value);
 
+CLUTTER_EXPORT
+ClutterActor * clutter_animatable_get_actor      (ClutterAnimatable *animatable);
+
 G_END_DECLS
 
 #endif /* __CLUTTER_ANIMATABLE_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]