[libhandy/wip/exalm/leaflet-transltions: 30/31] stackable-box: Add mode-transition-progress property



commit 687edacfd7a439fff68186aaef13f7f736b27499
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri May 29 17:30:30 2020 +0500

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

 src/hdy-stackable-box-private.h |  3 +++
 src/hdy-stackable-box.c         | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
---
diff --git a/src/hdy-stackable-box-private.h b/src/hdy-stackable-box-private.h
index 30ef1be9..cf8c5567 100644
--- a/src/hdy-stackable-box-private.h
+++ b/src/hdy-stackable-box-private.h
@@ -50,10 +50,13 @@ guint            hdy_stackable_box_get_mode_transition_duration (HdyStackableBox
 void             hdy_stackable_box_set_mode_transition_duration (HdyStackableBox *self,
                                                                  guint            duration);
 
+gdouble          hdy_stackable_box_get_mode_transition_progress (HdyStackableBox *self);
+
 guint            hdy_stackable_box_get_child_transition_duration (HdyStackableBox *self);
 void             hdy_stackable_box_set_child_transition_duration (HdyStackableBox *self,
                                                                   guint            duration);
 gboolean         hdy_stackable_box_get_child_transition_running (HdyStackableBox *self);
+
 gboolean         hdy_stackable_box_get_interpolate_size (HdyStackableBox *self);
 void             hdy_stackable_box_set_interpolate_size (HdyStackableBox *self,
                                                          gboolean         interpolate_size);
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 39bfd12c..51e5b6bf 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -62,6 +62,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,
@@ -646,6 +647,8 @@ hdy_stackable_box_set_position (HdyStackableBox *self,
   self->mode_transition.current_pos = pos;
 
   gtk_widget_queue_allocate (GTK_WIDGET (self->container));
+
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MODE_TRANSITION_PROGRESS]);
 }
 
 static void
@@ -924,6 +927,25 @@ hdy_stackable_box_set_mode_transition_duration (HdyStackableBox *self,
                             props[PROP_MODE_TRANSITION_DURATION]);
 }
 
+/**
+ * hdy_stackable_box_get_mode_transition_progress:
+ * @self: a #HdyStackableBox
+ *
+ * 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_stackable_box_get_mode_transition_progress (HdyStackableBox *self)
+{
+  g_return_val_if_fail (HDY_IS_STACKABLE_BOX (self), 0);
+
+  return self->mode_transition.current_pos;
+}
+
 /**
  * hdy_stackable_box_get_child_transition_duration:
  * @self: a #HdyStackableBox
@@ -2407,6 +2429,9 @@ hdy_stackable_box_get_property (GObject    *object,
   case PROP_MODE_TRANSITION_DURATION:
     g_value_set_uint (value, hdy_stackable_box_get_mode_transition_duration (self));
     break;
+  case PROP_MODE_TRANSITION_PROGRESS:
+    g_value_set_double (value, hdy_stackable_box_get_mode_transition_progress (self));
+    break;
   case PROP_CHILD_TRANSITION_DURATION:
     g_value_set_uint (value, hdy_stackable_box_get_child_transition_duration (self));
     break;
@@ -2974,6 +2999,21 @@ hdy_stackable_box_class_init (HdyStackableBoxClass *klass)
                        0, G_MAXUINT, 250,
                        G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
 
+  /**
+   * HdyStackableBox: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"),


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