[libhandy/wip/exalm/leaflet-transltions: 26/26] leaflet: Add mode-transition-progress property



commit 590c7848e6dc55ae3548d1f7e4e522acb5c4341b
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri May 29 17:30:51 2020 +0500

    leaflet: Add mode-transition-progress property
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 src/hdy-leaflet.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 src/hdy-leaflet.h |  2 ++
 2 files changed, 42 insertions(+), 1 deletion(-)
---
diff --git a/src/hdy-leaflet.c b/src/hdy-leaflet.c
index 898a2744..106809d5 100644
--- a/src/hdy-leaflet.c
+++ b/src/hdy-leaflet.c
@@ -58,6 +58,7 @@ enum {
   PROP_VISIBLE_CHILD_NAME,
   PROP_TRANSITION_TYPE,
   PROP_MODE_TRANSITION_DURATION,
+  PROP_MODE_TRANSITION_PROGRESS,
   PROP_CHILD_TRANSITION_DURATION,
   PROP_CHILD_TRANSITION_RUNNING,
   PROP_INTERPOLATE_SIZE,
@@ -279,6 +280,25 @@ hdy_leaflet_set_mode_transition_duration (HdyLeaflet *self,
   hdy_stackable_box_set_mode_transition_duration (HDY_GET_HELPER (self), duration);
 }
 
+/**
+ * hdy_leaflet_get_mode_transition_progress:
+ * @self: a #HdyLeaflet
+ *
+ * Returns the current animation progress value of the mode transition. 0 means
+ * folded, 1 means unfolded.
+ *
+ * Returns: the mode transition progress
+ *
+ * Since: 1.0
+ */
+gdouble
+hdy_leaflet_get_mode_transition_progress (HdyLeaflet *self)
+{
+  g_return_val_if_fail (HDY_IS_LEAFLET (self), 0);
+
+  return hdy_stackable_box_get_mode_transition_progress (HDY_GET_HELPER (self));
+}
+
 /**
  * hdy_leaflet_get_child_transition_duration:
  * @self: a #HdyLeaflet
@@ -691,6 +711,9 @@ hdy_leaflet_get_property (GObject    *object,
   case PROP_MODE_TRANSITION_DURATION:
     g_value_set_uint (value, hdy_leaflet_get_mode_transition_duration (self));
     break;
+  case PROP_MODE_TRANSITION_PROGRESS:
+    g_value_set_double (value, hdy_leaflet_get_mode_transition_progress (self));
+    break;
   case PROP_CHILD_TRANSITION_DURATION:
     g_value_set_uint (value, hdy_leaflet_get_child_transition_duration (self));
     break;
@@ -1051,6 +1074,21 @@ hdy_leaflet_class_init (HdyLeafletClass *klass)
                        0, G_MAXUINT, 250,
                        G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
+  /**
+   * HdyLeaflet:mode-transition-progress:
+   *
+   * The mode transition animation progress value. 0 means folded, 1 means
+   * unfolded.
+   *
+   * Since: 1.0
+   */
+  props[PROP_MODE_TRANSITION_PROGRESS] =
+    g_param_spec_double ("mode-transition-progress",
+                         _("Mode transition progress"),
+                         _("The mode transition animation progress value"),
+                         0.0, 1.0, 1.0,
+                         G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
+
   props[PROP_CHILD_TRANSITION_DURATION] =
     g_param_spec_uint ("child-transition-duration",
                        _("Child transition duration"),
@@ -1176,12 +1214,12 @@ NOTIFY (notify_visible_child_cb, PROP_VISIBLE_CHILD);
 NOTIFY (notify_visible_child_name_cb, PROP_VISIBLE_CHILD_NAME);
 NOTIFY (notify_transition_type_cb, PROP_TRANSITION_TYPE);
 NOTIFY (notify_mode_transition_duration_cb, PROP_MODE_TRANSITION_DURATION);
+NOTIFY (notify_mode_transition_progress_cb, PROP_MODE_TRANSITION_PROGRESS);
 NOTIFY (notify_child_transition_duration_cb, PROP_CHILD_TRANSITION_DURATION);
 NOTIFY (notify_child_transition_running_cb, PROP_CHILD_TRANSITION_RUNNING);
 NOTIFY (notify_interpolate_size_cb, PROP_INTERPOLATE_SIZE);
 NOTIFY (notify_can_swipe_back_cb, PROP_CAN_SWIPE_BACK);
 NOTIFY (notify_can_swipe_forward_cb, PROP_CAN_SWIPE_FORWARD);
-
 static void
 notify_orientation_cb (HdyLeaflet *self)
 {
@@ -1218,6 +1256,7 @@ hdy_leaflet_init (HdyLeaflet *self)
   g_signal_connect_object (priv->box, "notify::visible-child-name", G_CALLBACK 
(notify_visible_child_name_cb), self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::transition-type", G_CALLBACK (notify_transition_type_cb), 
self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::mode-transition-duration", G_CALLBACK 
(notify_mode_transition_duration_cb), self, G_CONNECT_SWAPPED);
+  g_signal_connect_object (priv->box, "notify::mode-transition-progress", G_CALLBACK 
(notify_mode_transition_progress_cb), self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::child-transition-duration", G_CALLBACK 
(notify_child_transition_duration_cb), self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::child-transition-running", G_CALLBACK 
(notify_child_transition_running_cb), self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::interpolate-size", G_CALLBACK (notify_interpolate_size_cb), 
self, G_CONNECT_SWAPPED);
diff --git a/src/hdy-leaflet.h b/src/hdy-leaflet.h
index 096c1cac..cada036a 100644
--- a/src/hdy-leaflet.h
+++ b/src/hdy-leaflet.h
@@ -59,6 +59,8 @@ guint            hdy_leaflet_get_mode_transition_duration (HdyLeaflet *self);
 void             hdy_leaflet_set_mode_transition_duration (HdyLeaflet *self,
                                                            guint       duration);
 
+gdouble          hdy_leaflet_get_mode_transition_progress (HdyLeaflet *self);
+
 guint            hdy_leaflet_get_child_transition_duration (HdyLeaflet *self);
 void             hdy_leaflet_set_child_transition_duration (HdyLeaflet *self,
                                                             guint       duration);


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