mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add scrollbar 'handle-width' and 'handle-color' remove old syntax
This commit is contained in:
parent
52f4f32d89
commit
5078034672
4 changed files with 12 additions and 29 deletions
|
@ -139,7 +139,8 @@ The following properties are currently supports:
|
||||||
|
|
||||||
* scrollbar
|
* scrollbar
|
||||||
* foreground: color
|
* foreground: color
|
||||||
* scrollbar handle
|
* handle-width: distance
|
||||||
|
* handle-color: color
|
||||||
* foreground: color
|
* foreground: color
|
||||||
|
|
||||||
* box
|
* box
|
||||||
|
|
|
@ -19,17 +19,17 @@ typedef struct _scrollbar
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
unsigned int pos;
|
unsigned int pos;
|
||||||
unsigned int pos_length;
|
unsigned int pos_length;
|
||||||
|
Distance width;
|
||||||
} scrollbar;
|
} scrollbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name of the widget.
|
* @param name The name of the widget.
|
||||||
* @param width The width of the scrollbar
|
|
||||||
*
|
*
|
||||||
* Create a new scrollbar
|
* Create a new scrollbar
|
||||||
*
|
*
|
||||||
* @returns the scrollbar object.
|
* @returns the scrollbar object.
|
||||||
*/
|
*/
|
||||||
scrollbar *scrollbar_create ( const char *name, int width );
|
scrollbar *scrollbar_create ( const char *name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sb scrollbar object
|
* @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 );
|
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
|
#endif // ROFI_SCROLLBAR_H
|
||||||
|
|
|
@ -351,7 +351,7 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
||||||
lv->eh = eh;
|
lv->eh = eh;
|
||||||
|
|
||||||
char *n = g_strjoin(".", lv->widget.name,"scrollbar", NULL);
|
char *n = g_strjoin(".", lv->widget.name,"scrollbar", NULL);
|
||||||
lv->scrollbar = scrollbar_create ( n, 4);
|
lv->scrollbar = scrollbar_create ( n );
|
||||||
g_free(n);
|
g_free(n);
|
||||||
widget_set_clicked_handler ( WIDGET ( lv->scrollbar ), listview_scrollbar_clicked, lv );
|
widget_set_clicked_handler ( WIDGET ( lv->scrollbar ), listview_scrollbar_clicked, lv );
|
||||||
lv->scrollbar->widget.parent = WIDGET ( 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->dynamic = rofi_theme_get_boolean ( WIDGET ( lv ), "dynamic", TRUE );
|
||||||
lv->reverse = rofi_theme_get_boolean ( WIDGET ( lv ), "reverse", reverse );
|
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 ));
|
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 );
|
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 );
|
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 )
|
void listview_set_scroll_type ( listview *lv, ScrollType type )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
|
#define DEFAULT_SCROLLBAR_WIDTH 8
|
||||||
|
|
||||||
static void scrollbar_draw ( widget *, cairo_t * );
|
static void scrollbar_draw ( widget *, cairo_t * );
|
||||||
static void scrollbar_free ( widget * );
|
static void scrollbar_free ( widget * );
|
||||||
static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
|
static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
|
||||||
|
@ -41,12 +43,14 @@ static int scrollbar_get_desired_height ( widget *wid )
|
||||||
return wid->h;
|
return wid->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollbar *scrollbar_create ( const char *name, int width )
|
scrollbar *scrollbar_create ( const char *name )
|
||||||
{
|
{
|
||||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||||
widget_init ( WIDGET (sb), name );
|
widget_init ( WIDGET (sb), name );
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
sb->widget.y = 0;
|
sb->widget.y = 0;
|
||||||
|
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.w = widget_padding_get_padding_width ( WIDGET (sb)) + width;
|
||||||
sb->widget.h = widget_padding_get_padding_height ( WIDGET ( sb ) );
|
sb->widget.h = widget_padding_get_padding_height ( WIDGET ( sb ) );
|
||||||
|
|
||||||
|
@ -118,10 +122,8 @@ static void scrollbar_draw ( widget *wid, cairo_t *draw )
|
||||||
// Never go out of bar.
|
// Never go out of bar.
|
||||||
height = MAX ( 2, height );
|
height = MAX ( 2, height );
|
||||||
// Cap length;
|
// Cap length;
|
||||||
// @TODO hack.
|
|
||||||
wid->state = "handle";
|
|
||||||
rofi_theme_get_color ( WIDGET (sb ), "foreground", draw );
|
rofi_theme_get_color ( WIDGET (sb ), "foreground", draw );
|
||||||
wid->state = NULL;
|
rofi_theme_get_color ( WIDGET (sb ), "handle-color", draw );
|
||||||
|
|
||||||
cairo_rectangle ( draw,
|
cairo_rectangle ( draw,
|
||||||
widget_padding_get_left ( wid ),
|
widget_padding_get_left ( wid ),
|
||||||
|
@ -158,8 +160,3 @@ unsigned int scrollbar_clicked ( const scrollbar *sb, int y )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollbar_set_width ( scrollbar *sb, int width )
|
|
||||||
{
|
|
||||||
width += widget_padding_get_padding_width ( WIDGET ( sb ) );
|
|
||||||
sb->widget.w = width;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue