diff --git a/config/config.c b/config/config.c index b7b76f31..4e7dfb74 100644 --- a/config/config.c +++ b/config/config.c @@ -114,7 +114,8 @@ Settings config = { /** Monitor */ .monitor = "-5", /** set line margin */ - .line_margin = 2, + .line_margin = 2, + .line_padding = 1, /** Set filter */ .filter = NULL, /** Separator style: dash/solid */ diff --git a/doc/test_xr.txt b/doc/test_xr.txt index 2f5664e9..dc125dcd 100644 --- a/doc/test_xr.txt +++ b/doc/test_xr.txt @@ -72,6 +72,8 @@ rofi.tokenize: true rofi.m: -1 ! "Margin between rows" Set from: File rofi.line-margin: 3 +! "Padding within rows" Set from: Default +! rofi.line-padding: 1 ! "Pre-set filter" Set from: Default ! rofi.filter: ! "Separator style (none, dash, solid)" Set from: File diff --git a/include/settings.h b/include/settings.h index e61c5276..12fdb5fa 100644 --- a/include/settings.h +++ b/include/settings.h @@ -125,6 +125,7 @@ typedef struct char *monitor; /** Line margin */ unsigned int line_margin; + unsigned int line_padding; /** filter */ char *filter; /** style */ diff --git a/source/textbox.c b/source/textbox.c index ee2898c4..b1ccf87d 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -36,9 +36,7 @@ #include "mode.h" #include "view.h" -#define SIDE_MARGIN 1 - -#define DOT_OFFSET 15 +#define DOT_OFFSET 15 /** * Font + font color cache. @@ -225,7 +223,7 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) if ( tb->flags & TB_AUTOHEIGHT ) { // Width determines height! int tw = MAX ( 1, w ); - pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tw - 2 * SIDE_MARGIN - offset ) ); + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tw - 2 * config.line_padding - offset ) ); h = textbox_get_height ( tb ); } @@ -237,7 +235,7 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) } // We always want to update this - pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - 2 * SIDE_MARGIN - offset ) ); + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - 2 * config.line_padding - offset ) ); tb->update = TRUE; } @@ -306,20 +304,20 @@ static void texbox_update ( textbox *tb ) } // Skip the side MARGIN on the X axis. - int x = SIDE_MARGIN + offset; + int x = config.line_padding + offset; int y = 0; if ( tb->flags & TB_RIGHT ) { int line_width = 0; // Get actual width. pango_layout_get_pixel_size ( tb->layout, &line_width, NULL ); - x = ( tb->widget.w - line_width - SIDE_MARGIN - offset ); + x = ( tb->widget.w - line_width - config.line_padding - offset ); } else if ( tb->flags & TB_CENTER ) { int tw = textbox_get_font_width ( tb ); - x = ( ( tb->widget.w - tw - 2 * SIDE_MARGIN - offset ) ) / 2; + x = ( ( tb->widget.w - tw - 2 * config.line_padding - offset ) ) / 2; } - y = SIDE_MARGIN + ( pango_font_metrics_get_ascent ( p_metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; + y = config.line_padding + ( pango_font_metrics_get_ascent ( p_metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; // Set ARGB Color col = tb->color_bg; @@ -715,12 +713,12 @@ void textbox_cleanup ( void ) int textbox_get_width ( const textbox *tb ) { unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0; - return textbox_get_font_width ( tb ) + 2 * SIDE_MARGIN + offset; + return textbox_get_font_width ( tb ) + 2 * config.line_padding + offset; } int textbox_get_height ( const textbox *tb ) { - return textbox_get_font_height ( tb ) + 2 * SIDE_MARGIN; + return textbox_get_font_height ( tb ) + 2 * config.line_padding; } int textbox_get_font_height ( const textbox *tb ) @@ -746,5 +744,5 @@ double textbox_get_estimated_char_width ( void ) int textbox_get_estimated_char_height ( void ) { int height = pango_font_metrics_get_ascent ( p_metrics ) + pango_font_metrics_get_descent ( p_metrics ); - return ( height ) / PANGO_SCALE + 2 * SIDE_MARGIN; + return ( height ) / PANGO_SCALE + 2 * config.line_padding; } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index f30721b7..b55bffc8 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -166,6 +166,8 @@ static XrmOption xrmOptions[] = { "Monitor id to show on", CONFIG_DEFAULT }, { xrm_Number, "line-margin", { .num = &config.line_margin }, NULL, "Margin between rows", CONFIG_DEFAULT }, + { xrm_Number, "line-padding", { .num = &config.line_padding }, NULL, + "Padding within rows", CONFIG_DEFAULT }, { xrm_String, "filter", { .str = &config.filter }, NULL, "Pre-set filter", CONFIG_DEFAULT }, { xrm_String, "separator-style", { .str = &config.separator_style }, NULL,