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 | |
parent | 52f4f32d89396e29890acaa50cc87dbd79ffae42 (diff) |
Add scrollbar 'handle-width' and 'handle-color' remove old syntax
-rw-r--r-- | doc/themer.md | 3 | ||||
-rw-r--r-- | include/widgets/scrollbar.h | 11 | ||||
-rw-r--r-- | source/widgets/listview.c | 10 | ||||
-rw-r--r-- | source/widgets/scrollbar.c | 17 |
4 files changed, 12 insertions, 29 deletions
diff --git a/doc/themer.md b/doc/themer.md index f695e3d5..9526dc70 100644 --- a/doc/themer.md +++ b/doc/themer.md @@ -139,7 +139,8 @@ The following properties are currently supports: * scrollbar * foreground: color - * scrollbar handle + * handle-width: distance + * handle-color: color * foreground: color * box diff --git a/include/widgets/scrollbar.h b/include/widgets/scrollbar.h index 4efbaaa5..80cfceb6 100644 --- a/include/widgets/scrollbar.h +++ b/include/widgets/scrollbar.h @@ -19,17 +19,17 @@ typedef struct _scrollbar unsigned int length; unsigned int pos; unsigned int pos_length; + Distance width; } scrollbar; /** * @param name The name of the widget. - * @param width The width of the scrollbar * * Create a new scrollbar * * @returns the scrollbar object. */ -scrollbar *scrollbar_create ( const char *name, int width ); +scrollbar *scrollbar_create ( const char *name ); /** * @param sb scrollbar object @@ -63,12 +63,5 @@ void scrollbar_set_max_value ( scrollbar *sb, unsigned int max ); */ unsigned int scrollbar_clicked ( const scrollbar *sb, int y ); -/** - * @param sb scrollbar object - * @param width width of the scrollbar - * - * Set the width of the scrollbar handle. - */ -void scrollbar_set_width ( scrollbar *sb, int width ); /*@}*/ #endif // ROFI_SCROLLBAR_H 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; -} |