[layout] Update FixedLayout
The behaviour of ClutterGroup has been fixed with regards to the preferred size request; the fixed layout manager should use the same behaviour.
This commit is contained in:
parent
4663552a00
commit
62db72cf41
@ -54,15 +54,14 @@ clutter_fixed_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
gfloat *nat_width_p)
|
||||
{
|
||||
GList *children, *l;
|
||||
gdouble min_left, min_right;
|
||||
gdouble natural_left, natural_right;
|
||||
gdouble min_right;
|
||||
gdouble natural_right;
|
||||
|
||||
min_left = 0;
|
||||
min_right = 0;
|
||||
natural_left = 0;
|
||||
natural_right = 0;
|
||||
|
||||
children = clutter_container_get_children (container);
|
||||
|
||||
for (l = children; l != NULL; l = l->next)
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
@ -74,57 +73,20 @@ clutter_fixed_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
&child_min, NULL,
|
||||
&child_natural, NULL);
|
||||
|
||||
if (l == children)
|
||||
{
|
||||
/* First child */
|
||||
min_left = child_x;
|
||||
natural_left = child_x;
|
||||
min_right = min_left + child_min;
|
||||
natural_right = natural_left + child_natural;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Union of extents with previous children */
|
||||
if (child_x < min_left)
|
||||
min_left = child_x;
|
||||
if (child_x + child_min > min_right)
|
||||
min_right = child_x + child_min;
|
||||
|
||||
if (child_x < natural_left)
|
||||
natural_left = child_x;
|
||||
|
||||
if (child_x + child_min > min_right)
|
||||
min_right = child_x + child_min;
|
||||
|
||||
if (child_x + child_natural > natural_right)
|
||||
natural_right = child_x + child_natural;
|
||||
}
|
||||
if (child_x + child_natural > natural_right)
|
||||
natural_right = child_x + child_natural;
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
/* The preferred size is defined as the width and height we want starting
|
||||
* from our origin, since our allocation will set the origin; so we now
|
||||
* need to remove any part of the request that is to the left of the origin.
|
||||
*/
|
||||
if (min_left < 0)
|
||||
min_left = 0;
|
||||
|
||||
if (natural_left < 0)
|
||||
natural_left = 0;
|
||||
|
||||
if (min_right < 0)
|
||||
min_right = 0;
|
||||
|
||||
if (natural_right < 0)
|
||||
natural_right = 0;
|
||||
|
||||
g_assert (min_right >= min_left);
|
||||
g_assert (natural_right >= natural_left);
|
||||
|
||||
if (min_width_p)
|
||||
*min_width_p = min_right - min_left;
|
||||
*min_width_p = min_right;
|
||||
|
||||
if (nat_width_p)
|
||||
*nat_width_p = natural_right - min_left;
|
||||
*nat_width_p = natural_right;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -135,15 +97,14 @@ clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
gfloat *nat_height_p)
|
||||
{
|
||||
GList *children, *l;
|
||||
gdouble min_top, min_bottom;
|
||||
gdouble natural_top, natural_bottom;
|
||||
gdouble min_bottom;
|
||||
gdouble natural_bottom;
|
||||
|
||||
min_top = 0;
|
||||
min_bottom = 0;
|
||||
natural_top = 0;
|
||||
natural_bottom = 0;
|
||||
|
||||
children = clutter_container_get_children (container);
|
||||
|
||||
for (l = children; l != NULL; l = l->next)
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
@ -155,57 +116,20 @@ clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
NULL, &child_min,
|
||||
NULL, &child_natural);
|
||||
|
||||
if (l == children)
|
||||
{
|
||||
/* First child */
|
||||
min_top = child_y;
|
||||
natural_top = child_y;
|
||||
min_bottom = min_top + child_min;
|
||||
natural_bottom = natural_top + child_natural;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Union of extents with previous children */
|
||||
if (child_y < min_top)
|
||||
min_top = child_y;
|
||||
if (child_y + child_min > min_bottom)
|
||||
min_bottom = child_y + child_min;
|
||||
|
||||
if (child_y < natural_top)
|
||||
natural_top = child_y;
|
||||
|
||||
if (child_y + child_min > min_bottom)
|
||||
min_bottom = child_y + child_min;
|
||||
|
||||
if (child_y + child_natural > natural_bottom)
|
||||
natural_bottom = child_y + child_natural;
|
||||
}
|
||||
if (child_y + child_natural > natural_bottom)
|
||||
natural_bottom = child_y + child_natural;
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
/* The preferred size is defined as the width and height we want starting
|
||||
* from our origin, since our allocation will set the origin; so we now
|
||||
* need to remove any part of the request that is above the origin.
|
||||
*/
|
||||
if (min_top < 0)
|
||||
min_top = 0;
|
||||
|
||||
if (natural_top < 0)
|
||||
natural_top = 0;
|
||||
|
||||
if (min_bottom < 0)
|
||||
min_bottom = 0;
|
||||
|
||||
if (natural_bottom < 0)
|
||||
natural_bottom = 0;
|
||||
|
||||
g_assert (min_bottom >= min_top);
|
||||
g_assert (natural_bottom >= natural_top);
|
||||
|
||||
if (min_height_p)
|
||||
*min_height_p = min_bottom - min_top;
|
||||
*min_height_p = min_bottom;
|
||||
|
||||
if (nat_height_p)
|
||||
*nat_height_p = natural_bottom - min_top;
|
||||
*nat_height_p = natural_bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user