1
0
mirror of https://github.com/Cloudef/bemenu synced 2024-09-23 20:41:19 +02:00

cairo: don't draw left scroll indicator if empty

If there are no matches the left indicator would be still drawn as black
box. If filter string is long enough, this black box would cover part of
the filter string.
This commit is contained in:
Jari Vetoniemi 2020-05-08 12:20:35 +03:00
parent 116cb5479f
commit d9f4d1bb12

View File

@ -339,10 +339,13 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t max_height, const s
/* single-line mode */
bm_pango_get_text_extents(cairo, &paint, &result, "lorem ipsum lorem ipsum lorem ipsum lorem");
uint32_t cl = fmin(title_x + result.x_advance, width / 4);
paint.pos = (struct pos){ cl, vpadding };
paint.box = (struct box){ 1, 2, vpadding, vpadding, 0, ascii_height };
bm_cairo_draw_line(cairo, &paint, &result, (count > 0 && (menu->wrap || menu->index > 0) ? "<" : " "));
cl += result.x_advance + 1;
if (count > 0) {
paint.pos = (struct pos){ cl, vpadding };
paint.box = (struct box){ 1, 2, vpadding, vpadding, 0, ascii_height };
bm_cairo_draw_line(cairo, &paint, &result, (count > 0 && (menu->wrap || menu->index > 0) ? "<" : " "));
cl += result.x_advance + 1;
}
for (uint32_t i = menu->index; i < count && cl < (width/cairo->scale); ++i) {
bool highlighted = (items[i] == bm_menu_get_highlighted_item(menu));