From 57440d52920f5ad76063089edd73c09f35951a87 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 10 Jun 2007 08:18:19 +0000 Subject: Fix a minor annoyance with the last commit where selecting an item could result in having empty space under the list. Also very very minor code reduction. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13607 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/gui/list.c b/apps/gui/list.c index bcf4710c9e..1aa189d9bf 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -474,12 +474,9 @@ static void gui_list_select_item(struct gui_list * gui_list, int item_number) } /* select an item above the current one */ -static void gui_list_select_above(struct gui_list * gui_list, int items) +static void gui_list_select_above(struct gui_list * gui_list, + int items, int nb_lines) { - int nb_lines = gui_list->display->nb_lines; - if (SHOW_LIST_TITLE) - nb_lines--; - gui_list->selected_item -= items; /* in bottom "3rd" of the screen, so dont move the start item. @@ -532,12 +529,10 @@ static void gui_list_select_above(struct gui_list * gui_list, int items) } } /* select an item below the current one */ -static void gui_list_select_below(struct gui_list * gui_list, int items) +static void gui_list_select_below(struct gui_list * gui_list, + int items, int nb_lines) { - int nb_lines = gui_list->display->nb_lines; int bottom; - if (SHOW_LIST_TITLE) - nb_lines--; gui_list->selected_item += items; bottom = gui_list->nb_items - nb_lines; @@ -600,6 +595,11 @@ static void gui_list_select_below(struct gui_list * gui_list, int items) static void gui_list_select_at_offset(struct gui_list * gui_list, int offset) { + /* do this here instead of in both select_above and select_below */ + int nb_lines = gui_list->display->nb_lines; + if (SHOW_LIST_TITLE) + nb_lines--; + if (gui_list->selected_size > 1) { offset *= gui_list->selected_size; @@ -607,14 +607,15 @@ static void gui_list_select_at_offset(struct gui_list * gui_list, int offset) offset -= offset%gui_list->selected_size; } if (offset == 0 && global_settings.scroll_paginated && - (gui_list->nb_items > gui_list->display->nb_lines - SHOW_LIST_TITLE)) + (gui_list->nb_items > nb_lines)) { - gui_list->start_item = gui_list->selected_item; + int bottom = gui_list->nb_items - nb_lines; + gui_list->start_item = MIN(gui_list->selected_item, bottom); } else if (offset < 0) - gui_list_select_above(gui_list, -offset); + gui_list_select_above(gui_list, -offset, nb_lines); else - gui_list_select_below(gui_list, offset); + gui_list_select_below(gui_list, offset, nb_lines); } /* -- cgit v1.2.3