text: Make sure that the selection box is big enough

Do not use integers to store the result of the PANGO_UNITS scaling to
avoid rounding issues with the default C rules. We should use cielf()
instead.
This commit is contained in:
Emmanuele Bassi 2011-07-10 10:24:40 +01:00
parent f6cdeb9858
commit 5d10a7141c

View File

@ -1487,8 +1487,8 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
for (i = 0; i < n_ranges; i++) for (i = 0; i < n_ranges; i++)
{ {
gint range_x; gfloat range_x;
gint range_width; gfloat range_width;
range_x = ranges[i * 2] / PANGO_SCALE; range_x = ranges[i * 2] / PANGO_SCALE;
@ -1497,11 +1497,11 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
range_x += priv->text_x; range_x += priv->text_x;
range_width = (ranges[i * 2 + 1] - ranges[i * 2]) range_width = ((gfloat) ranges[i * 2 + 1] - (gfloat) ranges[i * 2])
/ PANGO_SCALE; / PANGO_SCALE;
box.x1 = range_x; box.x1 = range_x;
box.x2 = range_x + range_width; box.x2 = ceilf (range_x + range_width + .5f);
func (self, &box, user_data); func (self, &box, user_data);
} }
@ -1513,9 +1513,9 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
} }
static void static void
clutter_text_add_selection_rectangle_to_path (ClutterText *text, add_selection_rectangle_to_path (ClutterText *text,
const ClutterActorBox *box, const ClutterActorBox *box,
gpointer user_data) gpointer user_data)
{ {
cogl_path_rectangle (user_data, box->x1, box->y1, box->x2, box->y2); cogl_path_rectangle (user_data, box->x1, box->y1, box->x2, box->y2);
} }
@ -1578,10 +1578,9 @@ selection_paint (ClutterText *self)
color->blue, color->blue,
paint_opacity * color->alpha / 255); paint_opacity * color->alpha / 255);
clutter_text_foreach_selection_rectangle clutter_text_foreach_selection_rectangle (self,
(self, add_selection_rectangle_to_path,
clutter_text_add_selection_rectangle_to_path, selection_path);
selection_path);
cogl_path_fill (selection_path); cogl_path_fill (selection_path);
@ -2051,9 +2050,9 @@ clutter_text_paint (ClutterActor *self)
} }
static void static void
clutter_text_add_selection_to_paint_volume_cb (ClutterText *text, add_selection_to_paint_volume (ClutterText *text,
const ClutterActorBox *box, const ClutterActorBox *box,
gpointer user_data) gpointer user_data)
{ {
ClutterPaintVolume *total_volume = user_data; ClutterPaintVolume *total_volume = user_data;
ClutterPaintVolume rect_volume; ClutterPaintVolume rect_volume;
@ -2093,8 +2092,9 @@ clutter_text_get_paint_volume_for_cursor (ClutterText *text,
} }
else else
{ {
clutter_text_foreach_selection_rectangle clutter_text_foreach_selection_rectangle (text,
(text, clutter_text_add_selection_to_paint_volume_cb, volume); add_selection_to_paint_volume,
volume);
} }
} }