[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.
This commit is contained in:
parent
e5a074fd9e
commit
db3ef97170
@ -216,9 +216,15 @@ compute_lines (ClutterFlowLayout *self,
|
|||||||
gint items_per_line;
|
gint items_per_line;
|
||||||
|
|
||||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
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
|
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;
|
return items_per_line;
|
||||||
}
|
}
|
||||||
@ -305,9 +311,9 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
|||||||
clutter_actor_allocate (child, &child_alloc, flags);
|
clutter_actor_allocate (child, &child_alloc, flags);
|
||||||
|
|
||||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||||
item_x += (item_width + priv->col_spacing);
|
item_x += (priv->col_width + priv->col_spacing);
|
||||||
else
|
else
|
||||||
item_y += (item_height + priv->row_spacing);
|
item_y += (priv->row_height + priv->row_spacing);
|
||||||
|
|
||||||
line_items_count += 1;
|
line_items_count += 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user