Check width in ClutterLabel::request_coords

If we get a size requisition, and we have ellipsization active,
check if we are getting less space than what the layout needs
and recompute the width.
This commit is contained in:
Emmanuele Bassi 2007-10-22 15:47:07 +00:00
parent 509799fa0c
commit eec01b6e73
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2007-10-22 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-label.c (clutter_label_request_coords): If
we get a size requisition, and we have ellipsization active,
check if we are getting less space than what the layout needs
and recompute the width.
2007-10-22 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-color.c (clutter_color_to_string): Change

View File

@ -84,6 +84,7 @@ struct _ClutterLabelPrivate
ClutterColor fgcol;
ClutterLayoutFlags layout_flags;
ClutterActorBox allocation;
gchar *text;
gchar *font_name;
@ -275,6 +276,9 @@ clutter_label_paint (ClutterActor *self)
return;
}
CLUTTER_NOTE (PAINT, "painting label (text:`%s')",
priv->text);
clutter_label_ensure_layout (label, clutter_actor_get_width (self));
priv->fgcol.alpha = clutter_actor_get_opacity(self);
@ -306,8 +310,27 @@ static void
clutter_label_request_coords (ClutterActor *self,
ClutterActorBox *box)
{
/* do we need to do anything ? */
clutter_label_clear_layout (CLUTTER_LABEL (self));
ClutterLabel *label = CLUTTER_LABEL (self);
ClutterLabelPrivate *priv = label->priv;
if (priv->ellipsize)
{
if (priv->layout)
{
gint width;
PangoRectangle logical;
width = CLUTTER_UNITS_TO_INT (box->x2 - box->x1) * PANGO_SCALE;
pango_layout_set_width (priv->layout, -1);
pango_layout_get_extents (priv->layout, NULL, &logical);
if (logical.width > width)
pango_layout_set_width (priv->layout, width);
}
}
else
clutter_label_clear_layout (label);
}
static void