[clutter] actor: fix allocate_align_fill() to maintain the child preferred size
- From: Lionel Landwerlin <llandwerlin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] actor: fix allocate_align_fill() to maintain the child preferred size
- Date: Mon, 26 Nov 2012 11:29:55 +0000 (UTC)
commit da498fdb9a0b9769ee0180a84aac431025692f80
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Mon Nov 26 10:30:47 2012 +0000
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
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 90bf56e..2f24de0 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]