[gtk/wip/otte/bitset: 17/22] listbase: Allocate gridview items properly on RTL



commit 724c9361f38ccc8f318c77b1997952a0629e5445
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jun 24 05:42:38 2020 +0200

    listbase: Allocate gridview items properly on RTL
    
    We need to flip the items.

 gtk/gtklistbase.c | 49 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index 2568b0604e..05df60b30f 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -1334,7 +1334,7 @@ update_autoscroll (GtkListBase *self,
 /**
  * gtk_list_base_size_allocate_child:
  * @self: The listbase
- * @child: 
+ * @child: The child
  * @x: top left coordinate in the across direction
  * @y: top right coordinate in the along direction
  * @width: size in the across direction
@@ -1356,26 +1356,41 @@ gtk_list_base_size_allocate_child (GtkListBase *self,
 
   if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
     {
-      child_allocation.x = x;
-      child_allocation.y = y;
-      child_allocation.width = width;
-      child_allocation.height = height;
-    }
-  else if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
-    {
-      child_allocation.x = y;
-      child_allocation.y = x;
-      child_allocation.width = height;
-      child_allocation.height = width;
+      if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
+        {
+          child_allocation.x = x;
+          child_allocation.y = y;
+          child_allocation.width = width;
+          child_allocation.height = height;
+        }
+      else
+        {
+          int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
+
+          child_allocation.x = mirror_point - x - width;
+          child_allocation.y = y;
+          child_allocation.width = width;
+          child_allocation.height = height;
+        }
     }
   else
     {
-      int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
+      if (_gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
+        {
+          child_allocation.x = y;
+          child_allocation.y = x;
+          child_allocation.width = height;
+          child_allocation.height = width;
+        }
+      else
+        {
+          int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
 
-      child_allocation.x = mirror_point - y - height; 
-      child_allocation.y = x;
-      child_allocation.width = height;
-      child_allocation.height = width;
+          child_allocation.x = mirror_point - y - height;
+          child_allocation.y = x;
+          child_allocation.width = height;
+          child_allocation.height = width;
+        }
     }
 
   gtk_widget_size_allocate (child, &child_allocation, -1);


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