summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/list.c27
1 files 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)
474} 474}
475 475
476/* select an item above the current one */ 476/* select an item above the current one */
477static void gui_list_select_above(struct gui_list * gui_list, int items) 477static void gui_list_select_above(struct gui_list * gui_list,
478 int items, int nb_lines)
478{ 479{
479 int nb_lines = gui_list->display->nb_lines;
480 if (SHOW_LIST_TITLE)
481 nb_lines--;
482
483 gui_list->selected_item -= items; 480 gui_list->selected_item -= items;
484 481
485 /* in bottom "3rd" of the screen, so dont move the start item. 482 /* 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)
532 } 529 }
533} 530}
534/* select an item below the current one */ 531/* select an item below the current one */
535static void gui_list_select_below(struct gui_list * gui_list, int items) 532static void gui_list_select_below(struct gui_list * gui_list,
533 int items, int nb_lines)
536{ 534{
537 int nb_lines = gui_list->display->nb_lines;
538 int bottom; 535 int bottom;
539 if (SHOW_LIST_TITLE)
540 nb_lines--;
541 536
542 gui_list->selected_item += items; 537 gui_list->selected_item += items;
543 bottom = gui_list->nb_items - nb_lines; 538 bottom = gui_list->nb_items - nb_lines;
@@ -600,6 +595,11 @@ static void gui_list_select_below(struct gui_list * gui_list, int items)
600 595
601static void gui_list_select_at_offset(struct gui_list * gui_list, int offset) 596static void gui_list_select_at_offset(struct gui_list * gui_list, int offset)
602{ 597{
598 /* do this here instead of in both select_above and select_below */
599 int nb_lines = gui_list->display->nb_lines;
600 if (SHOW_LIST_TITLE)
601 nb_lines--;
602
603 if (gui_list->selected_size > 1) 603 if (gui_list->selected_size > 1)
604 { 604 {
605 offset *= gui_list->selected_size; 605 offset *= gui_list->selected_size;
@@ -607,14 +607,15 @@ static void gui_list_select_at_offset(struct gui_list * gui_list, int offset)
607 offset -= offset%gui_list->selected_size; 607 offset -= offset%gui_list->selected_size;
608 } 608 }
609 if (offset == 0 && global_settings.scroll_paginated && 609 if (offset == 0 && global_settings.scroll_paginated &&
610 (gui_list->nb_items > gui_list->display->nb_lines - SHOW_LIST_TITLE)) 610 (gui_list->nb_items > nb_lines))
611 { 611 {
612 gui_list->start_item = gui_list->selected_item; 612 int bottom = gui_list->nb_items - nb_lines;
613 gui_list->start_item = MIN(gui_list->selected_item, bottom);
613 } 614 }
614 else if (offset < 0) 615 else if (offset < 0)
615 gui_list_select_above(gui_list, -offset); 616 gui_list_select_above(gui_list, -offset, nb_lines);
616 else 617 else
617 gui_list_select_below(gui_list, offset); 618 gui_list_select_below(gui_list, offset, nb_lines);
618} 619}
619 620
620/* 621/*