From 5031cdd228df3e6db1c38b1c3db0dbb563b8381d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 4 Sep 2015 14:52:57 +0200 Subject: [PATCH] Calculate size of handle for scrollbar better. --- include/textbox.h | 14 +++++++------- source/rofi.c | 9 ++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/textbox.h b/include/textbox.h index 11d1df65..9c9827e1 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -24,13 +24,13 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, } TextboxFlags; diff --git a/source/rofi.c b/source/rofi.c index 56cf8bf8..ee767218 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -367,9 +367,6 @@ static void menu_calculate_rows_columns ( MenuState *state ) ) ); // Always have at least one row. state->max_rows = MAX ( 1, state->max_rows ); - if ( state->scrollbar ) { - scrollbar_set_handle_length ( state->scrollbar, state->max_rows ); - } if ( config.fixed_num_lines == TRUE ) { state->max_elements = state->menu_lines * state->columns; @@ -766,7 +763,8 @@ static void menu_draw ( MenuState *state ) state->cur_page = page; state->rchanged = TRUE; } - scrollbar_set_handle ( state->scrollbar, page * state->max_rows ); + // Set the position. + scrollbar_set_handle ( state->scrollbar, page * state->max_elements ); } scrollbar_draw ( state->scrollbar ); // Re calculate the boxes and sizes, see if we can move this in the menu_calc*rowscolumns @@ -778,6 +776,8 @@ static void menu_draw ( MenuState *state ) state->max_rows ) / state->max_rows; columns = MIN ( columns, state->columns ); + // Update the handle length. + scrollbar_set_handle_length ( state->scrollbar, columns * state->max_rows ); // Element width. unsigned int element_width = state->w - ( 2 * ( config.padding ) ); if ( columns > 0 ) { @@ -1027,7 +1027,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom scrollbar_set_max_value ( state.scrollbar, state.num_lines ); - scrollbar_set_handle_length ( state.scrollbar, state.max_rows ); // filtered list state.line_map = g_malloc0_n ( state.num_lines, sizeof ( int ) ); if ( config.levenshtein_sort ) {