Add active/urgent color.

This commit is contained in:
QC 2015-04-03 18:40:07 +02:00
parent 957ffe5fcf
commit f2c4aff37c
5 changed files with 27 additions and 20 deletions

View File

@ -47,7 +47,9 @@ Settings config = {
/** Font */
.menu_font = "mono 12",
/** Foreground color */
.menu_fg = "#222222",
.menu_fg = "#222222",
.menu_fg_urgent = "#aa0000",
.menu_fg_active = "#00aaff",
/** Background color */
.menu_bg = "#f2f1f0",
/** Background color alternate row */

View File

@ -154,6 +154,8 @@ typedef struct _Settings
char * menu_font;
/** Foreground color */
char * menu_fg;
char * menu_fg_urgent;
char * menu_fg_active;
/** Background color */
char * menu_bg;
/** Background color alt */

View File

@ -43,10 +43,10 @@ typedef enum
STATE_MASK = ( NORMAL | ALT | HIGHLIGHT ),
BOLD = 8,
ITALIC = 16,
ACTIVE = 8,
URGENT = 16,
FMOD_MASK = ( BOLD | ITALIC )
FMOD_MASK = ( ACTIVE | URGENT )
} TextBoxFontType;
textbox* textbox_create ( Window parent,

View File

@ -523,10 +523,10 @@ static const char *mgrv ( unsigned int selected_line, void *sw, G_GNUC_UNUSED in
{
SwitcherModePrivateData *rmpd = ( (Switcher *) sw )->private_data;
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
*state |= ITALIC;
*state |= URGENT;
}
if ( window_client ( display, rmpd->ids->array[selected_line] )->active ) {
*state |= BOLD;
*state |= ACTIVE;
}
return rmpd->cmd_list[selected_line];
}

View File

@ -47,6 +47,8 @@ extern Display *display;
* Font + font color cache.
* Avoid re-loading font on every change on every textbox.
*/
XftColor color_fg_urgent;
XftColor color_fg_active;
XftColor color_fg;
XftColor color_bg;
XftColor color_hlfg;
@ -99,9 +101,9 @@ textbox* textbox_create ( Window parent,
tb->window = XCreateWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, vinfo->depth,
InputOutput, vinfo->visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
// need to preload the font to calc line height
// Force update of font descriptor.
tb->tbft = ~tbft;
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
pango_layout_set_font_description ( tb->layout, pfd );
pango_font_description_free ( pfd );
textbox_font ( tb, tbft );
textbox_text ( tb, text ? text : "" );
@ -127,17 +129,6 @@ textbox* textbox_create ( Window parent,
// set an Xft font by name
void textbox_font ( textbox *tb, TextBoxFontType tbft )
{
if ( ( tbft & FMOD_MASK ) != ( tb->tbft & FMOD_MASK ) ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
if ( ( tbft & BOLD ) == BOLD ) {
pango_font_description_set_weight ( pfd, PANGO_WEIGHT_BOLD );
}
if ( ( tbft & ITALIC ) == ITALIC ) {
pango_font_description_set_style ( pfd, PANGO_STYLE_ITALIC );
}
pango_layout_set_font_description ( tb->layout, pfd );
pango_font_description_free ( pfd );
}
switch ( ( tbft & STATE_MASK ) )
{
case HIGHLIGHT:
@ -154,6 +145,14 @@ void textbox_font ( textbox *tb, TextBoxFontType tbft )
tb->color_fg = color_fg;
break;
}
if ( ( tbft & FMOD_MASK ) ) {
if ( ( tbft & ACTIVE ) ) {
tb->color_fg = color_fg_active;
}
else if ( ( tbft & URGENT ) ) {
tb->color_fg = color_fg_urgent;
}
}
tb->tbft = tbft;
}
@ -628,6 +627,8 @@ void textbox_setup ( XVisualInfo *visual, Colormap colormap,
parse_color ( visual_info->visual, target_colormap, bg, &color_bg );
parse_color ( visual_info->visual, target_colormap, fg, &color_fg );
parse_color ( visual_info->visual, target_colormap, config.menu_fg_active, &color_fg_active );
parse_color ( visual_info->visual, target_colormap, config.menu_fg_urgent, &color_fg_urgent );
parse_color ( visual_info->visual, target_colormap, bg_alt, &color_bg_alt );
parse_color ( visual_info->visual, target_colormap, hlfg, &color_hlfg );
parse_color ( visual_info->visual, target_colormap, hlbg, &color_hlbg );
@ -641,6 +642,8 @@ void textbox_cleanup ( void )
{
if ( p_context ) {
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg );
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg_urgent );
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg_active );
XftColorFree ( display, visual_info->visual, target_colormap, &color_bg );
XftColorFree ( display, visual_info->visual, target_colormap, &color_bg_alt );
XftColorFree ( display, visual_info->visual, target_colormap, &color_hlfg );