configurable total height of separator

This commit is contained in:
Sascha Kruse 2012-09-09 08:55:41 +02:00
parent 43a37ead0f
commit 9534cd4d46
3 changed files with 28 additions and 18 deletions

View File

@ -23,6 +23,7 @@ int word_wrap = False;
int line_height = 0; /* if line height < font height, it will be raised to font height */ int line_height = 0; /* if line height < font height, it will be raised to font height */
int separator_enabled = False; int separator_enabled = False;
float separator_total_height = 1; /* height of the complete separator */
float separator_width = 0.7; /* width in relation to window width */ float separator_width = 0.7; /* width in relation to window width */
float separator_height = 0.1; /* height in relation to line_height */ float separator_height = 0.1; /* height in relation to line_height */
enum separator_color sep_color = AUTO; /* AUTO or FOREGROUND */ enum separator_color sep_color = AUTO; /* AUTO or FOREGROUND */

32
dunst.c
View File

@ -573,12 +573,6 @@ void draw_win(void)
line_cnt += n->draw_txt_buf.line_count; line_cnt += n->draw_txt_buf.line_count;
} }
if (separator_enabled) {
line_cnt += l_length(displayed_notifications) - 1;
if (indicate_hidden && !l_is_empty(notification_queue))
line_cnt++;
}
/* if we have a dynamic width, calculate the actual width */ /* if we have a dynamic width, calculate the actual width */
if (width == 0) { if (width == 0) {
for (l_node * iter = displayed_notifications->head; iter; for (l_node * iter = displayed_notifications->head; iter;
@ -601,6 +595,10 @@ void draw_win(void)
height = MAX(geometry.h, (line_cnt * line_height)); height = MAX(geometry.h, (line_cnt * line_height));
} }
int separator_total_pix_height = separator_total_height * line_height;
if (separator_enabled)
height += (line_cnt - 1) * separator_total_pix_height;
/* add "(x more)" */ /* add "(x more)" */
draw_txt x_more; draw_txt x_more;
x_more.txt = NULL; x_more.txt = NULL;
@ -666,7 +664,7 @@ void draw_win(void)
/* draw separator */ /* draw separator */
if (separator_enabled && line_cnt > 1) { if (separator_enabled && line_cnt > 1) {
dc->x = 0; dc->x = 0;
drawrect(dc, 0, 0, width, line_height, True, n->colors->BG); drawrect(dc, 0, 0, width, separator_total_pix_height, True, n->colors->BG);
double color; double color;
if (sep_color == AUTO) if (sep_color == AUTO)
@ -674,13 +672,17 @@ void draw_win(void)
else else
color = n->colors->FG; color = n->colors->FG;
int new_y = dc->y + line_height; int new_y = dc->y + separator_total_pix_height;
int sep_height = line_height * separator_height; int sep_pix_height = line_height * separator_height;
sep_height = sep_height < 1 ? 1 : sep_height;
int sep_width = width * separator_width; sep_pix_height = sep_pix_height < 1 ? 1 : sep_pix_height;
dc->y = dc->y + (line_height - sep_height) / 2; if (sep_pix_height > separator_total_pix_height)
dc->x = (width - sep_width) / 2; sep_pix_height = separator_total_pix_height;
drawrect(dc, 0, 0, sep_width, sep_height, True, color);
int sep_pix_width = width * separator_width;
dc->y = dc->y + (separator_total_pix_height - sep_pix_height) / 2;
dc->x = (width - sep_pix_width) / 2;
drawrect(dc, 0, 0, sep_pix_width, sep_pix_height, True, color);
dc->y = new_y; dc->y = new_y;
} }
} }
@ -1580,6 +1582,8 @@ dunst_ini_handle(void *user_data, const char *section,
separator_width = strtod(value, NULL); separator_width = strtod(value, NULL);
if (strcmp(name, "height") == 0) if (strcmp(name, "height") == 0)
separator_height = strtod(value, NULL); separator_height = strtod(value, NULL);
if (strcmp(name, "total_height") == 0)
separator_total_height = strtod(value, NULL);
if (strcmp(name, "color") == 0) { if (strcmp(name, "color") == 0) {
char *str = dunst_ini_get_string(value); char *str = dunst_ini_get_string(value);
if (strcmp(str, "auto") == 0) if (strcmp(str, "auto") == 0)

13
dunstrc
View File

@ -68,13 +68,18 @@
[separator] [separator]
#enable drawing of separator line # Draw a separator between notifications?
enable = no enable = no
#width of separator line in relation to window width # total height of the separator in relation to line height
total_height = 0.3
# width of the separator decoration
width = 0.8 width = 0.8
#height of separator line in relation to line height
height = 0.3 # height of the separator decoration
height = 0.8
# color can either be "foreground" to use the foreground color or # color can either be "foreground" to use the foreground color or
# "auto" to generate a fitting color depending on the background color # "auto" to generate a fitting color depending on the background color