1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Add scrollbar 'handle-width' and 'handle-color' remove old syntax

This commit is contained in:
Dave Davenport 2017-01-06 15:36:06 +01:00
parent 52f4f32d89
commit 5078034672
4 changed files with 12 additions and 29 deletions

View file

@ -139,7 +139,8 @@ The following properties are currently supports:
* scrollbar
* foreground: color
* scrollbar handle
* handle-width: distance
* handle-color: color
* foreground: color
* box

View file

@ -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

View file

@ -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 )
{

View file

@ -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;
}