[gtk+: 52/54] popover: Update child visibility when scrolling happens



commit eb2c1242fee99f68ada7940428f0c2426110cef0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jan 22 16:45:01 2014 +0100

    popover: Update child visibility when scrolling happens
    
    If pointing_to starts falling outside of the parent scrollable allocation,
    the popover will be automatically hidden, and shown back again when
    pointing_to scrolls back to visibility.

 gtk/gtkpopover.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 5d25b4f..f055dcd 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -600,6 +600,37 @@ gtk_popover_update_shape (GtkPopover *popover)
 }
 
 static void
+_gtk_popover_update_child_visible (GtkPopover *popover)
+{
+  cairo_rectangle_int_t rect;
+  GtkAllocation allocation;
+  GtkPopoverPrivate *priv;
+  GtkWidget *parent;
+
+  priv = popover->priv;
+
+  if (!priv->parent_scrollable)
+    {
+      gtk_widget_set_child_visible (GTK_WIDGET (popover), TRUE);
+      return;
+    }
+
+  parent = gtk_widget_get_parent (GTK_WIDGET (priv->parent_scrollable));
+  rect = priv->pointing_to;
+
+  gtk_widget_translate_coordinates (priv->widget, parent,
+                                    rect.x, rect.y, &rect.x, &rect.y);
+
+  gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation);
+
+  if (rect.x < 0 || rect.x + rect.width > allocation.width ||
+      rect.y < 0 || rect.y + rect.height > allocation.height)
+    gtk_widget_set_child_visible (GTK_WIDGET (popover), FALSE);
+  else
+    gtk_widget_set_child_visible (GTK_WIDGET (popover), TRUE);
+}
+
+static void
 gtk_popover_update_position (GtkPopover *popover)
 {
   GtkAllocation window_alloc;
@@ -642,6 +673,8 @@ gtk_popover_update_position (GtkPopover *popover)
 
       priv->current_position = priv->final_position;
     }
+
+  _gtk_popover_update_child_visible (popover);
 }
 
 static gboolean


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