From db3ef971705485b1000def688635daaac99f79cd Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 6 Oct 2009 17:30:49 +0100 Subject: [PATCH] [layout] Snap children of FlowLayout to column/row Use the column and row size to align each child; with :homogeneous set to TRUE, or with children with the same size, the FlowLayout will behave like a reflowing grid. --- clutter/clutter-flow-layout.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/clutter/clutter-flow-layout.c b/clutter/clutter-flow-layout.c index d6d92b9fd..3a70669e5 100644 --- a/clutter/clutter-flow-layout.c +++ b/clutter/clutter-flow-layout.c @@ -216,9 +216,15 @@ compute_lines (ClutterFlowLayout *self, gint items_per_line; if (priv->orientation == CLUTTER_FLOW_HORIZONTAL) - items_per_line = avail_width / (priv->col_width + priv->col_spacing); + { + items_per_line = (avail_width - priv->col_spacing) + / (priv->col_width + priv->col_spacing); + } else - items_per_line = avail_height / (priv->row_height + priv->row_spacing); + { + items_per_line = (avail_height - priv->row_spacing) + / (priv->row_height + priv->row_spacing); + } return items_per_line; } @@ -305,9 +311,9 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager, clutter_actor_allocate (child, &child_alloc, flags); if (priv->orientation == CLUTTER_FLOW_HORIZONTAL) - item_x += (item_width + priv->col_spacing); + item_x += (priv->col_width + priv->col_spacing); else - item_y += (item_height + priv->row_spacing); + item_y += (priv->row_height + priv->row_spacing); line_items_count += 1; }