layout-managers: Take into account the allocations's origin

If an actor using a LayoutManager has attributes like margin or padding
then it'll have to shave them from the available allocation before
passing it to the LayoutManager::allocate() implementation. Layout
managers should, thus, not assume that the origin of the allocation is
in (0, 0), but take into account that the passed ActorBox might have a
different origin.

https://bugzilla.gnome.org/show_bug.cgi?id=649631
This commit is contained in:
Emmanuele Bassi
2011-08-24 18:38:17 +01:00
parent 3314385119
commit 368c916c7f
3 changed files with 16 additions and 10 deletions

View File

@ -556,6 +556,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
{
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
GList *l, *children = clutter_container_get_children (container);
gfloat x_off, y_off;
gfloat avail_width, avail_height;
gfloat item_x, item_y;
gint line_item_count;
@ -565,6 +566,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
if (children == NULL)
return;
clutter_actor_box_get_origin (allocation, &x_off, &y_off);
clutter_actor_box_get_size (allocation, &avail_width, &avail_height);
/* blow the cached preferred size and re-compute with the given
@ -585,7 +587,8 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
items_per_line = compute_lines (CLUTTER_FLOW_LAYOUT (manager),
avail_width, avail_height);
item_x = item_y = 0;
item_x = x_off;
item_y = y_off;
line_item_count = 0;
line_index = 0;
@ -616,7 +619,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
line_item_count = 0;
line_index += 1;
item_x = 0;
item_x = x_off;
}
new_x = ((line_item_count + 1) * (avail_width + priv->col_spacing))
@ -655,7 +658,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
line_item_count = 0;
line_index += 1;
item_y = 0;
item_y = y_off;
}
new_y = ((line_item_count + 1) * (avail_height + priv->row_spacing))