[clutter/master-next: 25/51] keyframe-transition: Add direct accessors for key frames



commit d495255defb3ba1da2de7daf2ec0cfebeedcf2ee
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Apr 11 17:47:53 2012 +0100

    keyframe-transition: Add direct accessors for key frames
    
    This should allow modifying key frame details without requiring a full
    reset of the KeyframeTransition instance.

 clutter/clutter-keyframe-transition.c      |  102 ++++++++++++++++++++++++++++
 clutter/clutter-keyframe-transition.h      |   15 ++++
 clutter/clutter.symbols                    |    3 +
 doc/reference/clutter/clutter-sections.txt |    5 ++
 4 files changed, 125 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-keyframe-transition.c b/clutter/clutter-keyframe-transition.c
index 0703d7e..e19ff56 100644
--- a/clutter/clutter-keyframe-transition.c
+++ b/clutter/clutter-keyframe-transition.c
@@ -626,3 +626,105 @@ clutter_keyframe_transition_clear (ClutterKeyframeTransition *transition)
       transition->priv->frames = NULL;
     }
 }
+
+/**
+ * clutter_keyframe_transition_get_n_key_frames:
+ * @transition: a #ClutterKeyframeTransition
+ *
+ * Retrieves the number of key frames inside @transition.
+ *
+ * Return value: the number of key frames
+ *
+ * Since: 1.12
+ */
+guint
+clutter_keyframe_transition_get_n_key_frames (ClutterKeyframeTransition *transition)
+{
+  g_return_val_if_fail (CLUTTER_IS_KEYFRAME_TRANSITION (transition), 0);
+
+  if (transition->priv->frames == NULL)
+    return 0;
+
+  return transition->priv->frames->len - 1;
+}
+
+/**
+ * clutter_keyframe_transition_set_key_frame:
+ * @transition: a #ClutterKeyframeTransition
+ * @index_: the index of the key frame
+ * @key: the key of the key frame
+ * @mode: the easing mode of the key frame
+ * @value: a #GValue containing the value of the key frame
+ *
+ * Sets the details of the key frame at @index_ inside @transition.
+ *
+ * The @transition must already have a key frame at @index_, and @index_
+ * must be smaller than the number of key frames inside @transition.
+ *
+ * Since: 1.12
+ */
+void
+clutter_keyframe_transition_set_key_frame (ClutterKeyframeTransition *transition,
+                                           guint                      index_,
+                                           double                     key,
+                                           ClutterAnimationMode       mode,
+                                           const GValue              *value)
+{
+  ClutterKeyframeTransitionPrivate *priv;
+  KeyFrame *frame;
+
+  g_return_if_fail (CLUTTER_IS_KEYFRAME_TRANSITION (transition));
+
+  priv = transition->priv;
+  g_return_if_fail (priv->frames != NULL);
+  g_return_if_fail (index_ < priv->frames->len - 1);
+
+  frame = &g_array_index (priv->frames, KeyFrame, index_);
+  frame->key = key;
+  frame->mode = mode;
+  clutter_interval_set_final_value (frame->interval, value);
+}
+
+/**
+ * clutter_keyframe_transition_get_key_frame:
+ * @transition: a #ClutterKeyframeTransition
+ * @index_: the index of the key frame
+ * @key: (out) (allow-none): return location for the key, or %NULL
+ * @mode: (out) (allow-none): return location for the easing mode, or %NULL
+ * @value: (out caller-allocates): a #GValue initialized with the type of
+ *   the values
+ *
+ * Retrieves the details of the key frame at @index_ inside @transition.
+ *
+ * The @transition must already have key frames set, and @index_ must be
+ * smaller than the number of key frames.
+ *
+ * Since: 1.12
+ */
+void
+clutter_keyframe_transition_get_key_frame (ClutterKeyframeTransition *transition,
+                                           guint                      index_,
+                                           double                    *key,
+                                           ClutterAnimationMode      *mode,
+                                           GValue                    *value)
+{
+  ClutterKeyframeTransitionPrivate *priv;
+  const KeyFrame *frame;
+
+  g_return_if_fail (CLUTTER_IS_KEYFRAME_TRANSITION (transition));
+
+  priv = transition->priv;
+  g_return_if_fail (priv->frames != NULL);
+  g_return_if_fail (index_ < priv->frames->len - 1);
+
+  frame = &g_array_index (priv->frames, KeyFrame, index_);
+
+  if (key != NULL)
+    *key = frame->key;
+
+  if (mode != NULL)
+    *mode = frame->mode;
+
+  if (value != NULL)
+    clutter_interval_get_final_value (frame->interval, value);
+}
diff --git a/clutter/clutter-keyframe-transition.h b/clutter/clutter-keyframe-transition.h
index ce1016d..b6ac500 100644
--- a/clutter/clutter-keyframe-transition.h
+++ b/clutter/clutter-keyframe-transition.h
@@ -98,6 +98,21 @@ void                    clutter_keyframe_transition_set                 (Clutter
                                                                          ...);
 
 CLUTTER_AVAILABLE_IN_1_12
+void                    clutter_keyframe_transition_set_key_frame       (ClutterKeyframeTransition  *transition,
+                                                                         guint                       index_,
+                                                                         double                      key,
+                                                                         ClutterAnimationMode        mode,
+                                                                         const GValue               *value);
+CLUTTER_AVAILABLE_IN_1_12
+void                    clutter_keyframe_transition_get_key_frame       (ClutterKeyframeTransition  *transition,
+                                                                         guint                       index_,
+                                                                         double                     *key,
+                                                                         ClutterAnimationMode       *mode,
+                                                                         GValue                     *value);
+CLUTTER_AVAILABLE_IN_1_12
+guint                   clutter_keyframe_transition_get_n_key_frames    (ClutterKeyframeTransition  *transition);
+
+CLUTTER_AVAILABLE_IN_1_12
 void                    clutter_keyframe_transition_clear               (ClutterKeyframeTransition  *transition);
 
 G_END_DECLS
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index fc1e631..76d0b3b 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -800,9 +800,12 @@ clutter_input_device_ungrab
 clutter_input_device_update_from_event
 clutter_input_mode_get_type
 clutter_keyframe_transition_clear
+clutter_keyframe_transition_get_key_frame
+clutter_keyframe_transition_get_n_key_frames
 clutter_keyframe_transition_get_type
 clutter_keyframe_transition_new
 clutter_keyframe_transition_set_key_frames
+clutter_keyframe_transition_set_key_frame
 clutter_keyframe_transition_set_modes
 clutter_keyframe_transition_set_values
 clutter_keyframe_transition_set
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index 915b5b4..e407336 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -3231,6 +3231,11 @@ clutter_keyframe_transition_set
 clutter_keyframe_transition_set_key_frames
 clutter_keyframe_transition_set_modes
 clutter_keyframe_transition_set_values
+
+<SUBSECTION>
+clutter_keyframe_transition_get_n_key_frames
+clutter_keyframe_transition_set_key_frame
+clutter_keyframe_transition_get_key_frame
 clutter_keyframe_transition_clear
 <SECTION Standard>
 CLUTTER_TYPE_KEYFRAME_TRANSITION



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