Skip to content

Commit

Permalink
Add progress_bar_corners and icon_corners settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bynect committed Oct 22, 2023
1 parent 3d3fb65 commit 009a23e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
14 changes: 14 additions & 0 deletions docs/dunst.5.pod
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,25 @@ than half of the progress bar height.
The corner radius of the progress bar in pixels. Gives the progress bar
rounded corners. Set to 0 to disable.

=item B<progress_bar_corners> (default: all)

Define which corners to round when drawing the progress bar. If progress_bar_corner_radius
is set to 0 this option will be ignored.

See the B<corners> setting for the value format.

=item B<icon_corner_radius> (default: 0)

The corner radius of the icon image in pixels. Gives the icon
rounded corners. Set to 0 to disable.

=item B<icon_corners> (default: all)

Define which corners to round when drawing the icon image. If icon_corner_radius
is set to 0 this option will be ignored.

See the B<corners> setting for the value format.

=item B<indicate_hidden> (values: [true/false], default: true)

If this is set to true, a notification indicating how many notifications are
Expand Down
8 changes: 8 additions & 0 deletions dunstrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@
# Corner radius for the progress bar. 0 disables rounded corners.
progress_bar_corner_radius = 0

# Define which corners to round when drawing the progress bar. If progress_bar_corner_radius
# is set to 0 this option will be ignored.
progress_bar_corners = all

# Corner radius for the icon image.
icon_corner_radius = 0

# Define which corners to round when drawing the icon image. If icon_corner_radius
# is set to 0 this option will be ignored.
icon_corners = all

# Show how many messages are currently hidden (because of
# notification_limit).
indicate_hidden = yes
Expand Down
10 changes: 4 additions & 6 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,7 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, dou
} // else ICON_RIGHT

cairo_set_source_surface(c, cl->icon, round(image_x * scale), round(image_y * scale));
// icon_corners
draw_rounded_rect(c, image_x, image_y, image_width, image_height, settings.icon_corner_radius, scale, settings.corners);
draw_rounded_rect(c, image_x, image_y, image_width, image_height, settings.icon_corner_radius, scale, settings.icon_corners);
cairo_fill(c);
}

Expand Down Expand Up @@ -849,17 +848,16 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, dou
* this solution is not particularly solid (basically subracting a pixel or two)
*/

// progress_bar_corners
// back layer (background)
cairo_set_source_rgba(c, cl->bg.r, cl->bg.g, cl->bg.b, cl->bg.a);
draw_rounded_rect(c, x_bar_2, frame_y, progress_width_2, progress_height,
settings.progress_bar_corner_radius, scale, settings.corners);
settings.progress_bar_corner_radius, scale, settings.progress_bar_corners);
cairo_fill(c);

// top layer (fill)
cairo_set_source_rgba(c, cl->highlight.r, cl->highlight.g, cl->highlight.b, cl->highlight.a);
draw_rounded_rect(c, x_bar_1, frame_y, progress_width_1, progress_height,
settings.progress_bar_corner_radius, scale, settings.corners);
settings.progress_bar_corner_radius, scale, settings.progress_bar_corners);
cairo_fill(c);

// border
Expand All @@ -871,7 +869,7 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, dou
progress_width - frame_width - 2,
progress_height,
settings.progress_bar_corner_radius,
scale, settings.corners);
scale, settings.progress_bar_corners);
cairo_stroke(c);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ struct settings {
int progress_bar_corner_radius;
int icon_corner_radius;
enum corner_pos corners;
enum corner_pos progress_bar_corners;
enum corner_pos icon_corners;
bool progress_bar;
enum zwlr_layer_shell_v1_layer layer;
enum origin_values origin;
Expand Down
20 changes: 20 additions & 0 deletions src/settings_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,26 @@ static const struct setting allowed_settings[] = {
.parser = string_parse_corners,
.parser_data = corners_enum_data,
},
{
.name = "progress_bar_corners",
.section = "global",
.description = "Select the corners to round for the progress bar",
.type = TYPE_CUSTOM,
.default_value = "all",
.value = &settings.progress_bar_corners,
.parser = string_parse_corners,
.parser_data = corners_enum_data,
},
{
.name = "icon_corners",
.section = "global",
.description = "Select the corners to round for the icon image",
.type = TYPE_CUSTOM,
.default_value = "all",
.value = &settings.icon_corners,
.parser = string_parse_corners,
.parser_data = corners_enum_data,
},
{
.name = "progress_bar_height",
.section = "global",
Expand Down

0 comments on commit 009a23e

Please sign in to comment.