Calculate size of handle for scrollbar better.

This commit is contained in:
Dave Davenport 2015-09-04 14:52:57 +02:00
parent 72ef9c014f
commit 5031cdd228
2 changed files with 11 additions and 12 deletions

View File

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

View File

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