diff options
author | Lionel Landwerlin <llandwerlin@gmail.com> | 2012-11-26 10:30:47 +0000 |
---|---|---|
committer | Lionel Landwerlin <llandwerlin@gmail.com> | 2012-11-26 11:06:48 +0000 |
commit | cae20c93cdc02e5dfaf667b4ede143a807099fee (patch) | |
tree | c5d7bed97fd5a79202806d41d472d04812ea6808 | |
parent | 9c123ff4676b329920638ca7a2175f97cd61ab5a (diff) | |
download | clutter-cae20c93cdc02e5dfaf667b4ede143a807099fee.tar.gz |
actor: fix allocate_align_fill() to maintain the child preferred size
When trying to clamp to pixel a box that is exactly in between 2
pixels, the clutter_actor_box_clamp_to_pixel() function changes the
size of the box.
Here is an example :
ClutterActorBox box = { 10.5, 10, 20.5, 20};
g_message ("%fx%f -> %fx%f", box.x1, box.y1, box.x2, box.y2);
clutter_actor_box_clamp_to_pixel (&box);
g_message ("%fx%f -> %fx%f", box.x1, box.y1, box.x2, box.y2);
Here is what you get :
** Message: 10.500000x10.000000 -> 20.500000x20.000000
** Message: 10.000000x10.000000 -> 21.000000x20.000000
That is because of the properties of the ceilf and floorf function
used to do the clamping.
For example, ceil(0.5) is 1.0, and ceil(-0.5) is 0.0.
And, floor(0.5) is 0.0, and floor(-0.5) is -1.0.
To work around that problem this patch retains the distance between x
and y coordinates and apply that difference before calling ceilf() on
x2 and y2.
https://bugzilla.gnome.org/show_bug.cgi?id=689073
-rw-r--r-- | clutter/clutter-actor.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 088045b21..66585480d 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -15251,7 +15251,15 @@ clutter_actor_allocate_align_fill (ClutterActor *self, } out: - clutter_actor_box_clamp_to_pixel (&allocation); + + child_width = allocation.x2 - allocation.x1; + child_height = allocation.y2 - allocation.y1; + + allocation.x1 = floorf (allocation.x1); + allocation.y1 = floorf (allocation.y1); + allocation.x2 = ceilf (allocation.x1 + child_width); + allocation.y2 = ceilf (allocation.y1 + child_height); + clutter_actor_allocate (self, &allocation, flags); } |