[clutter] layout-managers: Take into account the allocations's origin
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] layout-managers: Take into account the allocations's origin
- Date: Mon, 29 Aug 2011 22:29:30 +0000 (UTC)
commit 368c916c7fc954e37c264f375a3a95f496777fa4
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Wed Aug 24 18:38:17 2011 +0100
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
clutter/clutter-bin-layout.c | 9 +++++----
clutter/clutter-flow-layout.c | 9 ++++++---
clutter/clutter-table-layout.c | 8 +++++---
3 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/clutter/clutter-bin-layout.c b/clutter/clutter-bin-layout.c
index acf097b..6f2709d 100644
--- a/clutter/clutter-bin-layout.c
+++ b/clutter/clutter-bin-layout.c
@@ -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;
diff --git a/clutter/clutter-flow-layout.c b/clutter/clutter-flow-layout.c
index 0a890e9..765c22d 100644
--- a/clutter/clutter-flow-layout.c
+++ b/clutter/clutter-flow-layout.c
@@ -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))
diff --git a/clutter/clutter-table-layout.c b/clutter/clutter-table-layout.c
index 4a39103..ef5120c 100644
--- a/clutter/clutter-table-layout.c
+++ b/clutter/clutter-table-layout.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]