summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2021-11-29 20:08:07 +0100
committerDave Davenport <qball@blame.services>2021-11-29 20:08:07 +0100
commitb0cfe29df160798154268a7349a4becc222baac3 (patch)
tree52114b2929ba7391f09ea44c0f9226eddfccd5c3
parentf72d6135bd8c4903adb233457b2ca1b0ca4b2705 (diff)
Make the scrollbar handlebar a widget, so it support rounded borders.scrollbar-handle-widget
-rw-r--r--include/widgets/scrollbar.h2
-rw-r--r--source/widgets/scrollbar.c13
2 files changed, 11 insertions, 4 deletions
diff --git a/include/widgets/scrollbar.h b/include/widgets/scrollbar.h
index ce3d8d7d..8b340954 100644
--- a/include/widgets/scrollbar.h
+++ b/include/widgets/scrollbar.h
@@ -27,6 +27,7 @@
#ifndef ROFI_SCROLLBAR_H
#define ROFI_SCROLLBAR_H
+#include "widgets/container.h"
#include "widgets/widget-internal.h"
#include "widgets/widget.h"
#include <cairo.h>
@@ -42,6 +43,7 @@
*/
typedef struct _scrollbar {
widget widget;
+ container *handle;
unsigned int length;
unsigned int pos;
unsigned int pos_length;
diff --git a/source/widgets/scrollbar.c b/source/widgets/scrollbar.c
index 73740588..d5983296 100644
--- a/source/widgets/scrollbar.c
+++ b/source/widgets/scrollbar.c
@@ -103,6 +103,7 @@ static gboolean scrollbar_motion_notify(widget *wid, G_GNUC_UNUSED gint x,
scrollbar *scrollbar_create(widget *parent, const char *name) {
scrollbar *sb = g_malloc0(sizeof(scrollbar));
widget_init(WIDGET(sb), parent, WIDGET_TYPE_SCROLLBAR, name);
+
sb->widget.x = 0;
sb->widget.y = 0;
sb->width = rofi_theme_get_distance(WIDGET(sb), "handle-width",
@@ -121,11 +122,13 @@ scrollbar *scrollbar_create(widget *parent, const char *name) {
sb->pos = 0;
sb->pos_length = 4;
+ sb->handle = container_create(WIDGET(sb), "scrollbar-handle");
return sb;
}
static void scrollbar_free(widget *wid) {
scrollbar *sb = (scrollbar *)wid;
+ widget_free(WIDGET(sb->handle));
g_free(sb);
}
@@ -171,12 +174,14 @@ static void scrollbar_draw(widget *wid, cairo_t *draw) {
// Set max pos.
y = MIN(y, wh - handle);
// Never go out of bar.
- height = MAX(2, height);
+ height = MAX(3, height);
// Cap length;
rofi_theme_get_color(WIDGET(sb), "handle-color", draw);
+ WIDGET(sb->handle)->x = widget_padding_get_left(wid);
+ WIDGET(sb->handle)->y = widget_padding_get_top(wid) + y;
+ WIDGET(sb->handle)->h = height;
+ WIDGET(sb->handle)->w = widget_padding_get_remaining_width(wid);
+ widget_draw(WIDGET(sb->handle), draw);
- cairo_rectangle(draw, widget_padding_get_left(wid),
- widget_padding_get_top(wid) + y,
- widget_padding_get_remaining_width(wid), height);
cairo_fill(draw);
}