Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spacing in single-line mode #113

Closed
siiptuo opened this issue Apr 20, 2020 · 5 comments · Fixed by #266
Closed

Spacing in single-line mode #113

siiptuo opened this issue Apr 20, 2020 · 5 comments · Fixed by #266

Comments

@siiptuo
Copy link
Contributor

siiptuo commented Apr 20, 2020

I think that spacing between items in single-line mode is too small. For example, using text "hello world" the space between "o" and "w" is larger than the space between items:

image

This makes it hard to see where the item starts and stops. I suggest that either:

  • make the padding bigger like in dmenu, or
  • make the padding configurable like bemenu -H.

Also, the text not centered horizontally (apparent when using a background color):

image

Here's a quick fix for these issues:

diff --git a/lib/renderers/cairo.h b/lib/renderers/cairo.h
index 07eaa55..b9b3032 100644
--- a/lib/renderers/cairo.h
+++ b/lib/renderers/cairo.h
@@ -361,10 +361,11 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t max_height, const s
                 bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_BG, &paint.bg);
             }

+            int32_t hpadding = 4;
             paint.pos = (struct pos){ cl, vpadding };
-            paint.box = (struct box){ 2, 4, vpadding, vpadding, 0, ascii_height };
+            paint.box = (struct box){ hpadding / 2, 1.5 * hpadding, vpadding, vpadding, 0, ascii_height };
             bm_cairo_draw_line(cairo, &paint, &result, "%s", (items[i]->text ? items[i]->text : ""));
-            cl += result.x_advance + 2;
+            cl += result.x_advance + 0.5 * hpadding;
             out_result->displayed += (cl < width);
             out_result->height = fmax(out_result->height, result.height);
         }

It seems that box.lx is applied both in the rectangle and text positions. Is this a bug?

@Cloudef
Copy link
Owner

Cloudef commented Apr 20, 2020

IIRC when drawing boxes there is also "margin" supplied in, so the box.lx should be fine.
Bemenu is supposed to look and behave identical to dmenu as possible by default, so patch to make the spacing more like in dmenu is welcome.

Do you want me to apply the above diff manually? Or will you do a PR?

@siiptuo
Copy link
Contributor Author

siiptuo commented Apr 21, 2020

IIRC when drawing boxes there is also "margin" supplied in, so the box.lx should be fine.

I was just wondering because the above patch seems more complicated than necessary. I would expect hpadding, hpadding, vpadding, vpadding (or original hpadding, 2*hpadding, vpadding, vpadding) to center the text.

Do you want me to apply the above diff manually? Or will you do a PR?

Currently the arrows are not taken into account. I can make a PR later.

@Cloudef
Copy link
Owner

Cloudef commented Apr 22, 2020 via email

@notramo
Copy link

notramo commented Feb 1, 2021

Is there any progress on this?

@lokesh-krishna
Copy link

If the patch works as it is then can I make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants