[libhandy/wip/haecker-felix/flap-widget: 110/138] Implement get_*_size() funcs




commit 7fe7d4ca5338dc9b6e95108f62996b7984859271
Author: Felix Häcker <haeckerfelix gnome org>
Date:   Mon Jul 27 15:49:57 2020 +0200

    Implement get_*_size() funcs

 src/hdy-flap.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 80 insertions(+), 16 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index e67e0df5..9bdd27b9 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -169,6 +169,86 @@ hdy_flap_measure (GtkWidget      *widget,
   gint child_size;
 }
 
+static gint
+adjust_for_overlay (HdyFlap *self,
+                    gint     value)
+{
+  gdouble progress = MIN (1 - self->overlay_progress, self->reveal_progress);
+  return (gint) round (value * progress);
+}
+
+static gint
+get_flap_size (HdyFlap        *self,
+               GtkAllocation  *widget_alloc,
+               GtkOrientation  widget_orientation)
+{
+  GtkWidget* flap;
+  GtkRequisition flap_min_size, flap_nat_size;
+
+  if (flap == NULL)
+    return 0;
+
+  flap = hdy_flap_get_flap (self);
+  gtk_widget_get_preferred_size (flap, &flap_min_size, &flap_nat_size);
+
+  if (widget_orientation == GTK_ORIENTATION_HORIZONTAL) {
+    if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+      return flap_min_size.width;
+    return widget_alloc->width;
+  } else {
+    if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+      return widget_alloc->height;
+    return flap_min_size.height;
+  }
+}
+
+static gint
+get_content_size (HdyFlap        *self,
+                  GtkAllocation  *widget_alloc,
+                  GtkOrientation  widget_orientation)
+{
+  if (widget_orientation == GTK_ORIENTATION_HORIZONTAL) {
+    int offset = 0;
+    if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+      offset = adjust_for_overlay(self, get_flap_size(self, widget_alloc, GTK_ORIENTATION_HORIZONTAL));
+    return widget_alloc->width - offset;
+  } else {
+    if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+      return widget_alloc->height;
+    return widget_alloc->height - adjust_for_overlay(self, get_flap_size(self, widget_alloc, 
GTK_ORIENTATION_HORIZONTAL));
+  }
+}
+
+static void
+allocate_flap (HdyFlap       *self,
+               GtkAllocation *widget_allocation)
+{
+
+}
+
+static void
+allocate_content (HdyFlap       *self,
+                  GtkAllocation *widget_allocation)
+{
+
+}
+
+static void
+hdy_flap_size_allocate (GtkWidget     *widget,
+                        GtkAllocation *allocation)
+{
+  HdyFlap *self = HDY_FLAP (widget);
+  GtkBin *bin = GTK_BIN (widget);
+  GtkAllocation child_allocation;
+  gint baseline;
+  GtkWidget *child;
+  GtkStyleContext *context = gtk_widget_get_style_context (widget);
+  gint child_maximum = 0, lower_threshold = 0;
+  gint child_flaped_size;
+
+  gtk_widget_set_allocation (widget, allocation);
+}
+
 static void
 hdy_flap_get_preferred_width_for_height (GtkWidget *widget,
                                          gint       height,
@@ -208,22 +288,6 @@ hdy_flap_get_preferred_height (GtkWidget *widget,
                      minimum, natural, NULL, NULL);
 }
 
-static void
-hdy_flap_size_allocate (GtkWidget     *widget,
-                        GtkAllocation *allocation)
-{
-  HdyFlap *self = HDY_FLAP (widget);
-  GtkBin *bin = GTK_BIN (widget);
-  GtkAllocation child_allocation;
-  gint baseline;
-  GtkWidget *child;
-  GtkStyleContext *context = gtk_widget_get_style_context (widget);
-  gint child_maximum = 0, lower_threshold = 0;
-  gint child_flaped_size;
-
-  gtk_widget_set_allocation (widget, allocation);
-}
-
 static void
 hdy_flap_class_init (HdyFlapClass *klass)
 {


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