[libhandy/wip/haecker-felix/flap-widget: 78/98] Implement reveal_tick_cb() and few other fixes.




commit 1d9308812f3716005124f9e2c9258944f237644f
Author: Felix Häcker <haeckerfelix gnome org>
Date:   Mon Jul 27 20:19:49 2020 +0200

    Implement reveal_tick_cb() and few other fixes.

 src/hdy-flap.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 8acdde33..2d8f5629 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -150,6 +150,33 @@ hdy_flap_set_property (GObject      *object,
   }
 }
 
+static gboolean
+reveal_tick_cb (HdyFlap       *self,
+                GdkFrameClock *frame_clock,
+                gpointer       user_data)
+{
+  guint64 frame_time = gdk_frame_clock_get_frame_time (frame_clock) / 1000;
+  gdouble t = (gdouble) (frame_time - self->reveal_start_time) / self->reveal_duration;
+
+  if (t >= 1) {
+    self->reveal_progress = self->reveal_flap ? 1 : 0;
+    self->reveal_tick_cb_id = 0;
+
+    gtk_widget_queue_resize (GTK_WIDGET (self));
+
+    return FALSE;
+  }
+
+  self->reveal_progress = hdy_ease_out_cubic (t);
+
+  if (!self->reveal_flap)
+    self->reveal_progress = 1 - self->reveal_progress;
+
+  gtk_widget_queue_resize (GTK_WIDGET (self));
+
+  return TRUE;
+}
+
 static gint
 adjust_for_overlay (HdyFlap *self,
                     gint     value)
@@ -190,6 +217,15 @@ hdy_flap_measure (GtkWidget      *widget,
   gint content_min = 0, content_nat = 0;
   gint flap_min = 0, flap_nat = 0;
 
+  if (minimum)
+    *minimum = 0;
+  if (natural)
+    *natural = 0;
+  if (minimum_baseline)
+    *minimum_baseline = -1;
+  if (natural_baseline)
+    *natural_baseline = -1;
+
   if (orientation == GTK_ORIENTATION_VERTICAL){
       if (content != NULL) gtk_widget_get_preferred_height (content, &content_min, &content_nat);
       if (self->flap != NULL) gtk_widget_get_preferred_height (self->flap, &flap_min, &flap_nat);
@@ -376,7 +412,7 @@ hdy_flap_get_preferred_width_for_height (GtkWidget *widget,
                                          gint      *natural)
 {
   hdy_flap_measure (widget, GTK_ORIENTATION_HORIZONTAL, height,
-                    minimum, natural, -1, -1);
+                    minimum, natural, NULL, NULL);
 }
 
 static void
@@ -385,7 +421,7 @@ hdy_flap_get_preferred_width (GtkWidget *widget,
                               gint      *natural)
 {
   hdy_flap_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
-                     minimum, natural, -1, -1);
+                     minimum, natural, NULL, NULL);
 }
 
 
@@ -396,7 +432,7 @@ hdy_flap_get_preferred_height_for_width (GtkWidget *widget,
                                          gint      *natural)
 {
   hdy_flap_measure (widget, GTK_ORIENTATION_VERTICAL, width,
-                     minimum, natural, -1, -1);
+                     minimum, natural, NULL, NULL);
 }
 
 static void
@@ -405,7 +441,7 @@ hdy_flap_get_preferred_height (GtkWidget *widget,
                                gint      *natural)
 {
   hdy_flap_measure (widget, GTK_ORIENTATION_VERTICAL, -1,
-                     minimum, natural, -1, -1);
+                     minimum, natural, NULL, NULL);
 }
 
 static void


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