[gtk/wip/otte/for-main: 2/2] listview: Fix clipping for horizontal listviews




commit ab1ae59c704559e8aab15228dce69bc6f6c12137
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jun 7 19:12:17 2022 +0200

    listview: Fix clipping for horizontal listviews
    
    Fixes a bug introduced with
    commit 39645d32582892bc4fd3bb55ea5d11af860f0efd

 gtk/gtklistbase.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index 81c95d1a4d..50975e0ff0 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -1363,20 +1363,20 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
   self_width = gtk_widget_get_width (GTK_WIDGET (self));
   self_height = gtk_widget_get_height (GTK_WIDGET (self));
 
-  if (y + height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
-      y - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_height ||
-      x + width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
-      x - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_width)
+  if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
     {
-      /* child is fully outside the viewport, hide it and don't allocate it */
-      gtk_widget_set_child_visible (child, FALSE);
-      return;
-    }
+      if (y + height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+          y - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_height ||
+          x + width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+          x - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_width)
+        {
+          /* child is fully outside the viewport, hide it and don't allocate it */
+          gtk_widget_set_child_visible (child, FALSE);
+          return;
+        }
 
-  gtk_widget_set_child_visible (child, TRUE);
+      gtk_widget_set_child_visible (child, TRUE);
 
-  if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
-    {
       if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
         {
           child_allocation.x = x;
@@ -1394,6 +1394,18 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
     }
   else
     {
+      if (y + height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+          y - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_width ||
+          x + width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+          x - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_height)
+        {
+          /* child is fully outside the viewport, hide it and don't allocate it */
+          gtk_widget_set_child_visible (child, FALSE);
+          return;
+        }
+
+      gtk_widget_set_child_visible (child, TRUE);
+
       if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
         {
           child_allocation.x = y;


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