mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
layout, bin: Use ceilf() instead of casting to int
Casting a float to int to truncate it before assigning the value to a float again is wrong. We should use ceilf() instead which does what we want to achieve (rounding up the size to avoid sub-pixel positioning of children).
This commit is contained in:
parent
308c930f37
commit
852abbb138
@ -81,6 +81,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-animatable.h"
|
||||
#include "clutter-bin-layout.h"
|
||||
@ -427,14 +429,14 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
|
||||
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL)
|
||||
{
|
||||
child_alloc.x1 = (int) 0;
|
||||
child_alloc.x2 = (int) available_w;
|
||||
child_alloc.x1 = 0;
|
||||
child_alloc.x2 = ceilf (available_w);
|
||||
}
|
||||
|
||||
if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL)
|
||||
{
|
||||
child_alloc.y1 = (int) 0;
|
||||
child_alloc.y2 = (int) available_h;
|
||||
child_alloc.y1 = 0;
|
||||
child_alloc.y2 = ceilf (available_h);
|
||||
}
|
||||
|
||||
/* if we are filling horizontally and vertically then we
|
||||
@ -481,8 +483,8 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
|
||||
if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
|
||||
{
|
||||
child_alloc.x1 = (int) clutter_actor_get_x (child);
|
||||
child_alloc.x2 = (int) child_alloc.x1 + child_width;
|
||||
child_alloc.x1 = ceilf (clutter_actor_get_x (child));
|
||||
child_alloc.x2 = ceilf (child_alloc.x1 + child_width);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -490,15 +492,15 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
|
||||
if (layer->x_align != CLUTTER_BIN_ALIGNMENT_FILL)
|
||||
{
|
||||
child_alloc.x1 = (int) ((available_w - child_width) * x_align);
|
||||
child_alloc.x2 = (int) child_alloc.x1 + child_width;
|
||||
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)
|
||||
{
|
||||
child_alloc.y1 = (int) clutter_actor_get_y (child);
|
||||
child_alloc.y2 = (int) child_alloc.y1 + child_height;
|
||||
child_alloc.y1 = ceilf (clutter_actor_get_y (child));
|
||||
child_alloc.y2 = ceilf (child_alloc.y1 + child_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -506,8 +508,8 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
||||
|
||||
if (layer->y_align != CLUTTER_BIN_ALIGNMENT_FILL)
|
||||
{
|
||||
child_alloc.y1 = (int) ((available_h - child_height) * y_align);
|
||||
child_alloc.y2 = (int) child_alloc.y1 + child_height;
|
||||
child_alloc.y1 = ceilf ((available_h - child_height) * y_align);
|
||||
child_alloc.y2 = ceilf (child_alloc.y1 + child_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user