allow users of obrender to change the ellipsize mode of text textures

This commit is contained in:
Mikael Magnusson 2007-06-04 23:51:48 +00:00
parent f5e08ae50f
commit b265acbd45
2 changed files with 26 additions and 1 deletions

View file

@ -109,7 +109,6 @@ RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size,
/* setup the layout */ /* setup the layout */
pango_layout_set_font_description(out->layout, out->font_desc); pango_layout_set_font_description(out->layout, out->font_desc);
pango_layout_set_single_paragraph_mode(out->layout, TRUE); pango_layout_set_single_paragraph_mode(out->layout, TRUE);
pango_layout_set_ellipsize(out->layout, PANGO_ELLIPSIZE_MIDDLE);
/* get the ascent and descent */ /* get the ascent and descent */
measure_font(inst, out); measure_font(inst, out);
@ -207,6 +206,7 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
gint mw; gint mw;
PangoRectangle rect; PangoRectangle rect;
PangoAttrList *attrlist; PangoAttrList *attrlist;
PangoEllipsizeMode ell;
/* center the text vertically /* center the text vertically
We do this centering based on the 'baseline' since different fonts have We do this centering based on the 'baseline' since different fonts have
@ -220,8 +220,24 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
w = area->width - 4; w = area->width - 4;
h = area->height; h = area->height;
switch (t->ellipsize) {
case RR_ELLIPSIZE_NONE:
ell = PANGO_ELLIPSIZE_NONE;
break;
case RR_ELLIPSIZE_START:
ell = PANGO_ELLIPSIZE_START;
break;
case RR_ELLIPSIZE_MIDDLE:
ell = PANGO_ELLIPSIZE_MIDDLE;
break;
case RR_ELLIPSIZE_END:
ell = PANGO_ELLIPSIZE_END;
break;
}
pango_layout_set_text(t->font->layout, t->string, -1); pango_layout_set_text(t->font->layout, t->string, -1);
pango_layout_set_width(t->font->layout, w * PANGO_SCALE); pango_layout_set_width(t->font->layout, w * PANGO_SCALE);
pango_layout_set_ellipsize(t->font->layout, ell);
/* * * end of setting up the layout * * */ /* * * end of setting up the layout * * */

View file

@ -85,6 +85,14 @@ typedef enum {
RR_JUSTIFY_RIGHT RR_JUSTIFY_RIGHT
} RrJustify; } RrJustify;
/* Put middle first so it's the default */
typedef enum {
RR_ELLIPSIZE_MIDDLE,
RR_ELLIPSIZE_NONE,
RR_ELLIPSIZE_START,
RR_ELLIPSIZE_END
} RrEllipsizeMode;
typedef enum { typedef enum {
RR_FONTWEIGHT_LIGHT, RR_FONTWEIGHT_LIGHT,
RR_FONTWEIGHT_NORMAL, RR_FONTWEIGHT_NORMAL,
@ -128,6 +136,7 @@ struct _RrTextureText {
guchar shadow_alpha; guchar shadow_alpha;
gboolean shortcut; /*!< Underline a character */ gboolean shortcut; /*!< Underline a character */
guint shortcut_pos; /*!< Position in bytes of the character to underline */ guint shortcut_pos; /*!< Position in bytes of the character to underline */
RrEllipsizeMode ellipsize;
}; };
struct _RrPixmapMask { struct _RrPixmapMask {