1
0
Fork 0
mirror of https://github.com/Cloudef/bemenu synced 2024-06-03 05:16:23 +02:00

Change default scrollbar style and make colors configurable

This commit is contained in:
Jari Vetoniemi 2015-01-18 01:38:25 +02:00
parent 9c541d0b42
commit f2eaf599f6
5 changed files with 21 additions and 7 deletions

View File

@ -95,7 +95,9 @@ usage(FILE *out, const char *name)
" --hb defines the highlighted background color. (wx)\n"
" --hf defines the highlighted foreground color. (wx)\n"
" --sb defines the selected background color. (wx)\n"
" --sf defines the selected foreground color. (wx)\n", out);
" --sf defines the selected foreground color. (wx)\n"
" --scb defines the scrollbar background color. (wx)\n"
" --scf defines the scrollbar foreground color. (wx)\n", out);
exit((out == stderr ? EXIT_FAILURE : EXIT_SUCCESS));
}
@ -132,6 +134,8 @@ parse_args(struct client *client, int *argc, char **argv[])
{ "hf", required_argument, 0, 0x109 },
{ "sb", required_argument, 0, 0x110 },
{ "sf", required_argument, 0, 0x111 },
{ "scb", required_argument, 0, 0x114 },
{ "scf", required_argument, 0, 0x115 },
{ "disco", no_argument, 0, 0x112 },
{ 0, 0, 0, 0 }
@ -222,6 +226,12 @@ parse_args(struct client *client, int *argc, char **argv[])
case 0x111:
client->colors[BM_COLOR_SELECTED_FG] = optarg;
break;
case 0x114:
client->colors[BM_COLOR_SCROLLBAR_BG] = optarg;
break;
case 0x115:
client->colors[BM_COLOR_SCROLLBAR_FG] = optarg;
break;
case 0x112:
disco();

View File

@ -196,6 +196,8 @@ enum bm_color {
BM_COLOR_HIGHLIGHTED_FG,
BM_COLOR_SELECTED_BG,
BM_COLOR_SELECTED_FG,
BM_COLOR_SCROLLBAR_BG,
BM_COLOR_SCROLLBAR_FG,
BM_COLOR_LAST
};

View File

@ -25,7 +25,9 @@ static const char *default_colors[BM_COLOR_LAST] = {
"#121212", // BM_COLOR_HIGHLIGHTED_BG
"#D81860", // BM_COLOR_HIGHLIGHTED_FG
"#121212", // BM_COLOR_SELECTED_BG
"#D81860" // BM_COLOR_SELECTED_FG
"#D81860", // BM_COLOR_SELECTED_FG
"#121212", // BM_COLOR_SCROLLBAR_BG
"#D81860", // BM_COLOR_SCROLLBAR_FG
};
/**

View File

@ -252,16 +252,17 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t height, uint32_t ma
}
if (menu->scrollbar && count > 0) {
bm_cairo_color_from_menu_color(menu, BM_COLOR_SCROLLBAR_BG, &paint.bg);
bm_cairo_color_from_menu_color(menu, BM_COLOR_SCROLLBAR_FG, &paint.fg);
uint32_t sheight = out_result->height - titleh;
bm_cairo_color_from_menu_color(menu, BM_COLOR_TITLE_FG, &paint.bg);
cairo_set_source_rgba(cairo->cr, paint.bg.r, paint.bg.b, paint.bg.g, paint.bg.a);
cairo_rectangle(cairo->cr, 0, titleh, 2, sheight);
cairo_fill(cairo->cr);
uint32_t size = sheight / lines;
uint32_t percent = (menu->index / (float)(count - 1)) * (sheight - size);
bm_cairo_color_from_menu_color(menu, BM_COLOR_BG, &paint.bg);
cairo_set_source_rgba(cairo->cr, paint.bg.r, paint.bg.b, paint.bg.g, paint.bg.a);
cairo_set_source_rgba(cairo->cr, paint.fg.r, paint.fg.b, paint.fg.g, paint.fg.a);
cairo_rectangle(cairo->cr, 0, titleh + percent, 2, size);
cairo_fill(cairo->cr);
}

View File

@ -207,8 +207,7 @@ render(const struct bm_menu *menu)
if (menu->scrollbar) {
attron(COLOR_PAIR(1));
uint32_t percent = (menu->index / (float)(count - 1)) * (displayed - 1);
for (uint32_t i = 0; i < displayed; ++i)
mvprintw(1 + i, 0, (i == percent ? "" : ""));
mvprintw(1 + percent, 0, "");
attroff(COLOR_PAIR(1));
}
}