diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-01-06 15:36:06 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-01-06 15:36:06 +0100 |
commit | 50780346729d2e9f4feb2725824c8df173b0df5b (patch) | |
tree | ee4f3023dac63294aab19e9e265f717892bee24d /source | |
parent | 52f4f32d89396e29890acaa50cc87dbd79ffae42 (diff) |
Add scrollbar 'handle-width' and 'handle-color' remove old syntax
Diffstat (limited to 'source')
-rw-r--r-- | source/widgets/listview.c | 10 | ||||
-rw-r--r-- | source/widgets/scrollbar.c | 17 |
2 files changed, 8 insertions, 19 deletions
diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 1c4365dc..031b2cb2 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -351,7 +351,7 @@ listview *listview_create ( const char *name, listview_update_callback cb, void lv->eh = eh; char *n = g_strjoin(".", lv->widget.name,"scrollbar", NULL); - lv->scrollbar = scrollbar_create ( n, 4); + lv->scrollbar = scrollbar_create ( n ); g_free(n); widget_set_clicked_handler ( WIDGET ( lv->scrollbar ), listview_scrollbar_clicked, lv ); lv->scrollbar->widget.parent = WIDGET ( lv ); @@ -372,8 +372,6 @@ listview *listview_create ( const char *name, listview_update_callback cb, void lv->dynamic = rofi_theme_get_boolean ( WIDGET ( lv ), "dynamic", TRUE ); lv->reverse = rofi_theme_get_boolean ( WIDGET ( lv ), "reverse", reverse ); listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( WIDGET ( lv ), "scrollbar", !config.hide_scrollbar )); - Distance d = rofi_theme_get_distance ( WIDGET ( lv ), "scrollbar-width", config.scrollbar_width ); - listview_set_scrollbar_width ( lv, distance_get_pixel ( d, ORIENTATION_HORIZONTAL ) ); lv->cycle = rofi_theme_get_boolean ( WIDGET ( lv ), "cycle", config.cycle ); @@ -546,12 +544,6 @@ void listview_set_show_scrollbar ( listview *lv, gboolean enabled ) listview_recompute_elements ( lv ); } } -void listview_set_scrollbar_width ( listview *lv, unsigned int width ) -{ - if ( lv ) { - scrollbar_set_width ( lv->scrollbar, width ); - } -} void listview_set_scroll_type ( listview *lv, ScrollType type ) { diff --git a/source/widgets/scrollbar.c b/source/widgets/scrollbar.c index e58cf5f8..c395b7ea 100644 --- a/source/widgets/scrollbar.c +++ b/source/widgets/scrollbar.c @@ -30,6 +30,8 @@ #include "theme.h" +#define DEFAULT_SCROLLBAR_WIDTH 8 + static void scrollbar_draw ( widget *, cairo_t * ); static void scrollbar_free ( widget * ); static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme ); @@ -41,13 +43,15 @@ static int scrollbar_get_desired_height ( widget *wid ) return wid->h; } -scrollbar *scrollbar_create ( const char *name, int width ) +scrollbar *scrollbar_create ( const char *name ) { scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) ); widget_init ( WIDGET (sb), name ); sb->widget.x = 0; sb->widget.y = 0; - sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb) ) +width; + sb->width = rofi_theme_get_distance ( WIDGET (sb), "handle-width", DEFAULT_SCROLLBAR_WIDTH ); + int width = distance_get_pixel (sb->width, ORIENTATION_HORIZONTAL); + sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb)) + width; sb->widget.h = widget_padding_get_padding_height ( WIDGET ( sb ) ); sb->widget.draw = scrollbar_draw; @@ -118,10 +122,8 @@ static void scrollbar_draw ( widget *wid, cairo_t *draw ) // Never go out of bar. height = MAX ( 2, height ); // Cap length; - // @TODO hack. - wid->state = "handle"; rofi_theme_get_color ( WIDGET (sb ), "foreground", draw ); - wid->state = NULL; + rofi_theme_get_color ( WIDGET (sb ), "handle-color", draw ); cairo_rectangle ( draw, widget_padding_get_left ( wid ), @@ -158,8 +160,3 @@ unsigned int scrollbar_clicked ( const scrollbar *sb, int y ) return 0; } -void scrollbar_set_width ( scrollbar *sb, int width ) -{ - width += widget_padding_get_padding_width ( WIDGET ( sb ) ); - sb->widget.w = width; -} |