[gtk+] GtkGrid: Tweak size allocation



commit 5e1a06d1b124f09a1a54d5ae0f38905dbdc2cc81
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Mar 15 23:10:39 2013 -0400

    GtkGrid: Tweak size allocation
    
    If there are rows that contain only spanning children,
    our algorithm was unnecessarily distributing extra space
    to the other rows, even if they contain only non-expanding
    children.
    
    We improve the behaviour by treating rows containing only
    spanning children as expanding.

 gtk/gtkgrid.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index 571f826..e1df436 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -562,6 +562,7 @@ gtk_grid_request_init (GtkGridRequest *request,
       lines->lines[i].minimum = 0;
       lines->lines[i].natural = 0;
       lines->lines[i].expand = FALSE;
+      lines->lines[i].empty = TRUE;
     }
 
   for (list = priv->children; list; list = list->next)
@@ -569,8 +570,18 @@ gtk_grid_request_init (GtkGridRequest *request,
       child = list->data;
 
       attach = &child->attach[orientation];
-      if (attach->span == 1 && gtk_widget_compute_expand (child->widget, orientation))
+      if (attach->span != 1)
+        continue;
+      if (gtk_widget_compute_expand (child->widget, orientation))
         lines->lines[attach->pos - lines->min].expand = TRUE;
+
+      lines->lines[attach->pos - lines->min].empty = FALSE;
+    }
+
+  for (i = 0; i < lines->max - lines->min; i++)
+    {
+      if (lines->lines[i].empty)
+        lines->lines[i].expand = TRUE;
     }
 }
 
@@ -903,6 +914,8 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
       for (i = 0; i < attach->span; i++)
         {
           line = &lines->lines[attach->pos - lines->min + i];
+          if (line->empty)
+            line->expand = TRUE;
           line->empty = FALSE;
           if (line->expand)
             has_expand = TRUE;


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