RrFont *out;
PangoWeight pweight;
PangoStyle pstyle;
- PangoAttrList *attrlist;
out = g_new(RrFont, 1);
out->inst = inst;
out->ref = 1;
out->font_desc = pango_font_description_new();
out->layout = pango_layout_new(inst->pango);
+
out->shortcut_underline = pango_attr_underline_new(PANGO_UNDERLINE_LOW);
out->shortcut_underline->start_index = 0;
out->shortcut_underline->end_index = 0;
- attrlist = pango_attr_list_new();
- /* shortcut_underline is owned by the attrlist */
- pango_attr_list_insert(attrlist, out->shortcut_underline);
- /* the attributes are owned by the layout */
- pango_layout_set_attributes(out->layout, attrlist);
- pango_attr_list_unref(attrlist);
+ out->underline_attrlist = pango_attr_list_new();
+ pango_attr_list_insert(out->underline_attrlist, out->shortcut_underline);
switch (weight) {
case RR_FONTWEIGHT_LIGHT: pweight = PANGO_WEIGHT_LIGHT; break;
{
if (f) {
if (--f->ref < 1) {
+ pango_attr_list_unref(f->underline_attrlist);
g_object_unref(f->layout);
pango_font_description_free(f->font_desc);
g_free(f);
XftColor c;
gint mw;
PangoRectangle rect;
- PangoAttrList *attrlist;
PangoEllipsizeMode ell;
/* center the text vertically
if (t->shortcut) {
const gchar *c = t->string + t->shortcut_pos;
+ PangoAttribute *pa;
+ PangoAttrList *al;
+
+ if (t->shortcut_color) {
+ pa = pango_attr_foreground_new
+ (t->shortcut_color->r + (t->shortcut_color->r << 8),
+ t->shortcut_color->g + (t->shortcut_color->g << 8),
+ t->shortcut_color->b + (t->shortcut_color->b << 8));
+ al = pango_attr_list_new();
+ pango_attr_list_insert(al, pa);
+ }
+ else {
+ pa = t->font->shortcut_underline;
+ al = t->font->underline_attrlist;
+ pango_attr_list_ref(al);
+ }
- t->font->shortcut_underline->start_index = t->shortcut_pos;
- t->font->shortcut_underline->end_index = t->shortcut_pos +
- (g_utf8_next_char(c) - c);
-
- /* the attributes are owned by the layout.
- re-add the attributes to the layout after changing the
- start and end index */
- attrlist = pango_layout_get_attributes(t->font->layout);
- pango_attr_list_ref(attrlist);
- pango_layout_set_attributes(t->font->layout, attrlist);
- pango_attr_list_unref(attrlist);
+ pa->start_index = t->shortcut_pos;
+ pa->end_index = t->shortcut_pos + (g_utf8_next_char(c) - c);
+
+ pango_layout_set_attributes(t->font->layout, al);
+ pango_attr_list_unref(al);
}
/* layout_line() uses y to specify the baseline
(d, &c, pango_layout_get_line(t->font->layout, 0),
x * PANGO_SCALE, y * PANGO_SCALE);
- if (t->shortcut) {
- t->font->shortcut_underline->start_index = 0;
- t->font->shortcut_underline->end_index = 0;
- /* the attributes are owned by the layout.
- re-add the attributes to the layout after changing the
- start and end index */
- attrlist = pango_layout_get_attributes(t->font->layout);
- pango_attr_list_ref(attrlist);
- pango_layout_set_attributes(t->font->layout, attrlist);
- pango_attr_list_unref(attrlist);
- }
+ if (t->shortcut)
+ pango_layout_set_attributes(t->font->layout, NULL);
}
gint ref;
PangoFontDescription *font_desc;
PangoLayout *layout; /*!< Used for measuring and rendering strings */
- PangoAttribute *shortcut_underline; /*< For underlining the shortcut key */
+ PangoAttribute *shortcut_underline; /*!< For underlining shortcuts */
+ PangoAttrList *underline_attrlist; /*!< For underlining shortcuts */
gint ascent; /*!< The font's ascent in pango-units */
gint descent; /*!< The font's descent in pango-units */
};
and then really close it */
void RrFontRef(RrFont *f);
+void RrFontSetShortcutNormalColor(RrFont *f, RrColor *c);
+void RrFontSetShortcutDisabledColor(RrFont *f, RrColor *c);
+void RrFontSetShortcutSelectedColor(RrFont *f, RrColor *c);
+void RrFontSetShortcutDisabledSelectedColor(RrFont *f, RrColor *c);
+
#endif /* __font_h */
#include "version.h"
#include <X11/Xlib.h> /* some platforms dont include this as needed for Xft */
+#include <pango/pango.h>
#include <pango/pangoxft.h>
#include <glib.h>
gint shadow_offset_y;
RrColor *shadow_color;
guchar shadow_alpha;
- gboolean shortcut; /*!< Underline a character */
- guint shortcut_pos; /*!< Position in bytes of the character to underline */
+ gboolean shortcut; /*!< Underline/hilight a character */
+ guint shortcut_pos; /*!< Position in bytes of the character to hilight */
+ RrColor *shortcut_color; /*!< Color for the hilighted character, or NULL */
RrEllipsizeMode ellipsize;
};
void RrAppearanceAddTextures(RrAppearance *a, gint numtex);
RrFont *RrFontOpen (const RrInstance *inst, const gchar *name,
- gint size, RrFontWeight weight, RrFontSlant slant);
+ gint size, RrFontWeight weight,
+ RrFontSlant slant);
RrFont *RrFontOpenDefault (const RrInstance *inst);
void RrFontClose (RrFont *f);
RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
"menu.items.active.text.color",
&theme->menu_selected_color))
theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
+ if (!read_color(db, inst,
+ "menu.items.text.shortcut.color",
+ &theme->menu_shortcut_color))
+ theme->menu_shortcut_color = NULL;
+ if (!read_color(db, inst,
+ "menu.items.disabled.text.shortcut.color",
+ &theme->menu_disabled_shortcut_color))
+ theme->menu_disabled_shortcut_color =
+ theme->menu_shortcut_color == NULL ? NULL :
+ RrColorNew(inst,
+ theme->menu_shortcut_color->r,
+ theme->menu_shortcut_color->g,
+ theme->menu_shortcut_color->b);
+ if (!read_color(db, inst,
+ "menu.items.disabled.text.shortcut.color",
+ &theme->menu_disabled_selected_shortcut_color))
+ theme->menu_disabled_selected_shortcut_color =
+ theme->menu_shortcut_color == NULL ? NULL :
+ RrColorNew(inst,
+ theme->menu_shortcut_color->r,
+ theme->menu_shortcut_color->g,
+ theme->menu_shortcut_color->b);
+ if (!read_color(db, inst,
+ "menu.items.active.text.shortcut.color",
+ &theme->menu_selected_shortcut_color))
+ theme->menu_selected_shortcut_color =
+ theme->menu_shortcut_color == NULL ? NULL :
+ RrColorNew(inst,
+ theme->menu_shortcut_color->r,
+ theme->menu_shortcut_color->g,
+ theme->menu_shortcut_color->b);
/* load the image masks */
theme->a_menu_text_disabled_selected->texture[0].data.text.font =
theme->menu_font;
theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
+ theme->a_menu_text_normal->texture[0].data.text.shortcut_color =
+ theme->menu_shortcut_color;
theme->a_menu_text_selected->texture[0].data.text.color =
theme->menu_selected_color;
+ theme->a_menu_text_selected->texture[0].data.text.shortcut_color =
+ theme->menu_selected_shortcut_color;
theme->a_menu_text_disabled->texture[0].data.text.color =
theme->menu_disabled_color;
+ theme->a_menu_text_disabled->texture[0].data.text.shortcut_color =
+ theme->menu_disabled_shortcut_color;
theme->a_menu_text_disabled_selected->texture[0].data.text.color =
theme->menu_disabled_selected_color;
+ theme->a_menu_text_disabled_selected->texture[0].data.text.shortcut_color =
+ theme->menu_disabled_selected_shortcut_color;
if (read_string(db, "menu.items.font", &str)) {
char *p;
RrColorFree(theme->menu_selected_color);
RrColorFree(theme->menu_disabled_color);
RrColorFree(theme->menu_disabled_selected_color);
+ RrColorFree(theme->menu_shortcut_color);
+ RrColorFree(theme->menu_selected_shortcut_color);
+ RrColorFree(theme->menu_disabled_shortcut_color);
+ RrColorFree(theme->menu_disabled_selected_shortcut_color);
RrColorFree(theme->title_focused_shadow_color);
RrColorFree(theme->title_unfocused_shadow_color);
RrColorFree(theme->osd_color);
RrColor *menu_selected_color;
RrColor *menu_disabled_color;
RrColor *menu_disabled_selected_color;
+ RrColor *menu_shortcut_color;
+ RrColor *menu_selected_shortcut_color;
+ RrColor *menu_disabled_shortcut_color;
+ RrColor *menu_disabled_selected_shortcut_color;
RrColor *title_focused_shadow_color;
gchar title_focused_shadow_alpha;
RrColor *title_unfocused_shadow_color;