bin-layout: Migrate to allocate_align_fill()

Now that we have the code in ClutterActor itself.
This commit is contained in:
Emmanuele Bassi 2010-08-10 17:43:26 +01:00
parent 07b01888ba
commit 6ad4126e17

View File

@ -429,102 +429,36 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
ClutterLayoutMeta *meta; ClutterLayoutMeta *meta;
ClutterBinLayer *layer; ClutterBinLayer *layer;
ClutterActorBox child_alloc = { 0, }; ClutterActorBox child_alloc = { 0, };
gfloat child_width, child_height; gdouble x_align, y_align;
ClutterRequestMode request; gboolean x_fill, y_fill;
meta = clutter_layout_manager_get_child_meta (manager, meta = clutter_layout_manager_get_child_meta (manager,
container, container,
child); child);
layer = CLUTTER_BIN_LAYER (meta); layer = CLUTTER_BIN_LAYER (meta);
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL)
{
child_alloc.x1 = 0;
child_alloc.x2 = ceilf (available_w);
}
if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL)
{
child_alloc.y1 = 0;
child_alloc.y2 = ceilf (available_h);
}
/* if we are filling horizontally and vertically then we
* can break here because we already have a full allocation
*/
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL &&
layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL)
{
clutter_actor_allocate (child, &child_alloc, flags);
continue;
}
child_width = child_height = 0;
request = clutter_actor_get_request_mode (child);
if (request == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH)
{
gfloat min_width, nat_width;
gfloat min_height, nat_height;
clutter_actor_get_preferred_width (child, available_h,
&min_width,
&nat_width);
child_width = CLAMP (nat_width, min_width, available_w);
clutter_actor_get_preferred_height (child, child_width,
&min_height,
&nat_height);
child_height = CLAMP (nat_height, min_height, available_h);
}
else if (request == CLUTTER_REQUEST_WIDTH_FOR_HEIGHT)
{
gfloat min_width, nat_width;
gfloat min_height, nat_height;
clutter_actor_get_preferred_height (child, available_w,
&min_height,
&nat_height);
child_height = CLAMP (nat_height, min_height, available_h);
clutter_actor_get_preferred_width (child, child_height,
&min_width,
&nat_width);
child_width = CLAMP (nat_width, min_width, available_w);
}
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED) if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
{ child_alloc.x1 = clutter_actor_get_x (child);
child_alloc.x1 = ceilf (clutter_actor_get_x (child));
child_alloc.x2 = ceilf (child_alloc.x1 + child_width);
}
else else
{ child_alloc.x1 = 0.0f;
gdouble x_align = get_bin_alignment_factor (layer->x_align);
if (layer->x_align != CLUTTER_BIN_ALIGNMENT_FILL)
{
child_alloc.x1 = ceilf ((available_w - child_width) * x_align);
child_alloc.x2 = ceilf (child_alloc.x1 + child_width);
}
}
if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED) if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
{ child_alloc.y1 = clutter_actor_get_y (child);
child_alloc.y1 = ceilf (clutter_actor_get_y (child));
child_alloc.y2 = ceilf (child_alloc.y1 + child_height);
}
else else
{ child_alloc.y1 = 0.0f;
gdouble y_align = get_bin_alignment_factor (layer->y_align);
if (layer->y_align != CLUTTER_BIN_ALIGNMENT_FILL) child_alloc.x2 = available_w;
{ child_alloc.y2 = available_h;
child_alloc.y1 = ceilf ((available_h - child_height) * y_align);
child_alloc.y2 = ceilf (child_alloc.y1 + child_height);
}
}
clutter_actor_allocate (child, &child_alloc, flags); x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);
y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL);
x_align = get_bin_alignment_factor (layer->x_align);
y_align = get_bin_alignment_factor (layer->y_align);
clutter_actor_allocate_align_fill (child, &child_alloc,
x_align, y_align,
x_fill, y_fill,
flags);
} }
g_list_free (children); g_list_free (children);