[clutter] table-layout: Honor actors expand and alignment settings



commit 8e24de86b6f88f3bfd1e65cdfd845f330212d1c6
Author: Bastian Winkler <buz netbuz org>
Date:   Fri Jun 1 16:49:51 2012 +0200

    table-layout: Honor actors expand and alignment settings
    
    Check if the actor has needs to expand and use Actor.allocate() instead
    of Actor.allocate_align_fill in that case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677284

 clutter/clutter-table-layout.c |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/clutter/clutter-table-layout.c b/clutter/clutter-table-layout.c
index 518a903..a49c842 100644
--- a/clutter/clutter-table-layout.c
+++ b/clutter/clutter-table-layout.c
@@ -700,6 +700,7 @@ calculate_col_widths (ClutterTableLayout *self,
   ClutterActor *actor, *child;
   gint i;
   DimensionData *columns;
+  ClutterOrientation orientation = CLUTTER_ORIENTATION_HORIZONTAL;
 
   update_row_col (self, container);
   g_array_set_size (priv->columns, 0);
@@ -750,7 +751,10 @@ calculate_col_widths (ClutterTableLayout *self,
       col->pref_size = MAX (col->pref_size, c_pref);
 
       if (!col->expand)
-        col->expand = meta->x_expand;
+        {
+          col->expand = clutter_actor_needs_expand (child, orientation) ||
+            meta->x_expand;
+        }
     }
 
   /* STAGE TWO: take spanning children into account */
@@ -799,7 +803,11 @@ calculate_col_widths (ClutterTableLayout *self,
             }
 
           if (!columns[i].expand)
-            columns[i].expand = meta->x_expand;
+            {
+              columns[i].expand = clutter_actor_needs_expand (child,
+                                                              orientation) ||
+                meta->x_expand;
+            }
         }
       min_width += priv->col_spacing * (meta->col_span - 1);
       pref_width += priv->col_spacing * (meta->col_span - 1);
@@ -967,6 +975,7 @@ calculate_row_heights (ClutterTableLayout *self,
   ClutterActor *actor, *child;
   gint i;
   DimensionData *rows, *columns;
+  ClutterOrientation orientation = CLUTTER_ORIENTATION_VERTICAL;
 
   update_row_col (self, container);
   g_array_set_size (priv->rows, 0);
@@ -1020,7 +1029,10 @@ calculate_row_heights (ClutterTableLayout *self,
       row->pref_size = MAX (row->pref_size, c_pref);
 
       if (!row->expand)
-        row->expand = meta->y_expand;
+        {
+          row->expand = clutter_actor_needs_expand (child, orientation) ||
+            meta->y_expand;
+        }
     }
 
   /* STAGE TWO: take spanning children into account */
@@ -1071,7 +1083,11 @@ calculate_row_heights (ClutterTableLayout *self,
             }
 
           if (!rows[i].expand)
-            rows[i].expand = meta->y_expand;
+            {
+              rows[i].expand = clutter_actor_needs_expand (child,
+                                                           orientation) ||
+                meta->y_expand;
+            }
         }
 
       min_height += priv->row_spacing * (meta->row_span - 1);
@@ -1492,10 +1508,14 @@ clutter_table_layout_allocate (ClutterLayoutManager   *layout,
           clutter_actor_set_easing_delay (child, easing_delay);
         }
 
-      clutter_actor_allocate_align_fill (child, &childbox,
-                                         x_align, y_align,
-                                         x_fill, y_fill,
-                                         flags);
+      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL) ||
+          clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
+        clutter_actor_allocate (child, &childbox, flags);
+      else
+        clutter_actor_allocate_align_fill (child, &childbox,
+                                           x_align, y_align,
+                                           x_fill, y_fill,
+                                           flags);
 
       if (use_animations)
         clutter_actor_restore_easing_state (child);



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