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:
parent
3314385119
commit
368c916c7f
@ -428,10 +428,11 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
{
|
||||
GList *children = clutter_container_get_children (container);
|
||||
GList *l;
|
||||
gfloat allocation_x, allocation_y;
|
||||
gfloat available_w, available_h;
|
||||
|
||||
available_w = clutter_actor_box_get_width (allocation);
|
||||
available_h = clutter_actor_box_get_height (allocation);
|
||||
clutter_actor_box_get_origin (allocation, &allocation_x, &allocation_y);
|
||||
clutter_actor_box_get_size (allocation, &available_w, &available_h);
|
||||
|
||||
for (l = children; l != NULL; l = l->next)
|
||||
{
|
||||
@ -450,12 +451,12 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
|
||||
child_alloc.x1 = clutter_actor_get_x (child);
|
||||
else
|
||||
child_alloc.x1 = 0.0f;
|
||||
child_alloc.x1 = allocation_x;
|
||||
|
||||
if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
|
||||
child_alloc.y1 = clutter_actor_get_y (child);
|
||||
else
|
||||
child_alloc.y1 = 0.0f;
|
||||
child_alloc.y1 = allocation_y;
|
||||
|
||||
child_alloc.x2 = available_w;
|
||||
child_alloc.y2 = available_h;
|
||||
|
@ -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))
|
||||
|
@ -1403,7 +1403,9 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
col_spacing = (priv->col_spacing);
|
||||
row_spacing = (priv->row_spacing);
|
||||
|
||||
calculate_table_dimensions (self, container, box->x2 - box->x1, box->y2 - box->y1);
|
||||
calculate_table_dimensions (self, container,
|
||||
box->x2 - box->x1,
|
||||
box->y2 - box->y1);
|
||||
|
||||
rows = (DimensionData *) priv->rows->data;
|
||||
columns = (DimensionData *) priv->columns->data;
|
||||
@ -1472,7 +1474,7 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
}
|
||||
|
||||
/* calculate child x */
|
||||
child_x = 0.0f;
|
||||
child_x = clutter_actor_box_get_x (box);
|
||||
for (i = 0; i < col; i++)
|
||||
{
|
||||
if (columns[i].visible)
|
||||
@ -1483,7 +1485,7 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
}
|
||||
|
||||
/* calculate child y */
|
||||
child_y = 0.0f;
|
||||
child_y = clutter_actor_box_get_y (box);
|
||||
for (i = 0; i < row; i++)
|
||||
{
|
||||
if (rows[i].visible)
|
||||
|
Loading…
Reference in New Issue
Block a user