diff options
author | Neil Roberts <neil@linux.intel.com> | 2009-09-29 12:11:55 +0100 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2009-10-27 14:13:16 +0000 |
commit | db27f74285cd6ff33f8cee029f77bad602c60b33 (patch) | |
tree | fb0a718785deefe44093d257a591b8cd19c715e6 | |
parent | 47c52b883aa5fc913f3818f56fd9f3a93714bcd8 (diff) | |
download | clutter-db27f74285cd6ff33f8cee029f77bad602c60b33.tar.gz |
[ClutterGroup] Don't take into account the left edges when calculating the size
ClutterGroup previously calculated the size as the distance from the
left edge of the leftmost child to the right edge of the rightmost
child except if there were any chidren left of the origin then the
left edge would be zero.
However the group is always allocated its size relative to its
origin so if all of the children are to the right of the origin then
the preferred size would not be large enough to reach the rightmost
child.
origin
┼──────────┐
│Group │
│ ┌────────┼─┐
│ │Child │ │
│ │ │ │
└─┼────────┘ │
│ │
└──────────┘
group size
╟──────────╢
This patch makes it so the size is always just the rightmost edge.
origin
┼────────────┐
│Group │
│ ┌──────────┤
│ │Child │
│ │ │
│ │ │
│ │ │
└─┴──────────┘
group size
╟────────────╢
Fixes bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1825
(cherry picked from commit 40222e891bec62e4e7187a3e66bdf7866a60bd38)
-rw-r--r-- | clutter/clutter-group.c | 122 |
1 files changed, 26 insertions, 96 deletions
diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c index 36d4fbbf5..918aa5ecd 100644 --- a/clutter/clutter-group.c +++ b/clutter/clutter-group.c @@ -132,12 +132,11 @@ clutter_fixed_layout_get_preferred_width (GList *children, gfloat *natural_width_p) { GList *l; - gdouble min_left, min_right; - gdouble natural_left, natural_right; + gdouble min_right, natural_right; - min_left = 0; + /* We will always be at least 0 sized (ie, if all of the actors are + to the left of the origin we won't return a negative size) */ min_right = 0; - natural_left = 0; natural_right = 0; for (l = children; l != NULL; l = l->next) @@ -151,55 +150,21 @@ clutter_fixed_layout_get_preferred_width (GList *children, &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 < 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; - } - } - - /* 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; + /* Track the rightmost edge */ + if (child_x + child_min > min_right) + min_right = child_x + child_min; - 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 (child_x + child_natural > natural_right) + natural_right = child_x + child_natural; + } + /* The size is defined as the distance from the origin to the + right-hand edge of the rightmost actor */ if (min_width_p) - *min_width_p = min_right - min_left; + *min_width_p = min_right; if (natural_width_p) - *natural_width_p = natural_right - min_left; + *natural_width_p = natural_right; } static void @@ -208,12 +173,11 @@ clutter_fixed_layout_get_preferred_height (GList *children, gfloat *natural_height_p) { GList *l; - gdouble min_top, min_bottom; - gdouble natural_top, natural_bottom; + gdouble min_bottom, natural_bottom; - min_top = 0; + /* We will always be at least 0 sized (ie, if all of the actors are + above the origin we won't return a negative size) */ min_bottom = 0; - natural_top = 0; natural_bottom = 0; for (l = children; l != NULL; l = l->next) @@ -227,55 +191,21 @@ clutter_fixed_layout_get_preferred_height (GList *children, 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 < 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; - } - } - - /* 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; + /* Track the bottommost edge */ + if (child_y + child_min > min_bottom) + min_bottom = child_y + child_min; - 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 (child_y + child_natural > natural_bottom) + natural_bottom = child_y + child_natural; + } + /* The size is defined as the distance from the origin to the bottom + edge of the bottommost actor */ if (min_height_p) - *min_height_p = min_bottom - min_top; + *min_height_p = min_bottom; if (natural_height_p) - *natural_height_p = natural_bottom - min_top; + *natural_height_p = natural_bottom; } static void |