1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-03-10 17:06:37 -04:00

[scrollbar] Add theming for rounded corners (#2108)

* [scrollbar] Add theming for rounded corners

* rename "rounded-corners" to "handle-rounded-corners"
This commit is contained in:
J0hannes101 2025-03-08 18:34:39 +01:00 committed by GitHub
parent a993ceadf4
commit 56fd08ed58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View file

@ -1011,6 +1011,7 @@ The following properties are currently supported:
- **handle-width**: distance - **handle-width**: distance
- **handle-color**: color - **handle-color**: color
- **border-color**: color - **border-color**: color
- **handle-rounded-corners**: boolean for rounded scrollbar
### box ### box

View file

@ -175,8 +175,26 @@ static void scrollbar_draw(widget *wid, cairo_t *draw) {
// Cap length; // Cap length;
rofi_theme_get_color(WIDGET(sb), "handle-color", draw); rofi_theme_get_color(WIDGET(sb), "handle-color", draw);
cairo_rectangle(draw, widget_padding_get_left(wid), if (rofi_theme_get_boolean(WIDGET(sb), "handle-rounded-corners", FALSE)) {
widget_padding_get_top(wid) + y, float x = widget_padding_get_left(wid);
widget_padding_get_remaining_width(wid), height); float width = widget_padding_get_remaining_width(wid);
cairo_fill(draw);
float radius = ((width < height) ? width : height) / 2; // Limit radius to prevent overlap
// Draw rounded rectangle
cairo_new_sub_path(draw);
cairo_arc(draw, x + width - radius, y + radius, radius, -G_PI_2, 0);
cairo_arc(draw, x + width - radius, y + height - radius, radius, 0, G_PI_2);
cairo_arc(draw, x + radius, y + height - radius, radius, G_PI_2, G_PI);
cairo_arc(draw, x + radius, y + radius, radius, G_PI, 1.5 * G_PI);
cairo_close_path(draw);
cairo_fill(draw);
}
else {
cairo_rectangle(draw, widget_padding_get_left(wid),
widget_padding_get_top(wid) + y,
widget_padding_get_remaining_width(wid), height);
cairo_fill(draw);
}
} }