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



commit 5c29d79e782f8982ad1e92815f766c2ad7604d3c
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 ac403713..5deb92ea 100644
--- a/src/hdy-stackable-box-private.h
+++ b/src/hdy-stackable-box-private.h
@@ -51,10 +51,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 78f24070..54b4017b 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -63,6 +63,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,
@@ -686,6 +687,8 @@ hdy_stackable_box_set_position (HdyStackableBox *self,
     gtk_widget_queue_resize (GTK_WIDGET (self->container));
   /* } */
 
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MODE_TRANSITION_PROGRESS]);
+
   /* if (self->mode_transition.current_pos == self->mode_transition.target_pos) */
   /*   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CHILD_REVEALED]); */
 }
@@ -967,6 +970,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
@@ -2420,6 +2442,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;
@@ -2996,6 +3021,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]