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:
parent
a993ceadf4
commit
56fd08ed58
2 changed files with 23 additions and 4 deletions
|
@ -1011,6 +1011,7 @@ The following properties are currently supported:
|
|||
- **handle-width**: distance
|
||||
- **handle-color**: color
|
||||
- **border-color**: color
|
||||
- **handle-rounded-corners**: boolean for rounded scrollbar
|
||||
|
||||
### box
|
||||
|
||||
|
|
|
@ -175,8 +175,26 @@ static void scrollbar_draw(widget *wid, cairo_t *draw) {
|
|||
// Cap length;
|
||||
rofi_theme_get_color(WIDGET(sb), "handle-color", draw);
|
||||
|
||||
if (rofi_theme_get_boolean(WIDGET(sb), "handle-rounded-corners", FALSE)) {
|
||||
float x = widget_padding_get_left(wid);
|
||||
float width = widget_padding_get_remaining_width(wid);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue