summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c5
-rw-r--r--apps/gui/list.c47
-rw-r--r--apps/gui/list.h4
3 files changed, 51 insertions, 5 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 32ab46cbda..404d82c63e 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -88,6 +88,7 @@
88#endif 88#endif
89#include "hwcompat.h" 89#include "hwcompat.h"
90 90
91static char* dbg_menu_getname(int item, void * data, char *buffer);
91static bool dbg_list(char *title, int count, int selection_size, 92static bool dbg_list(char *title, int count, int selection_size,
92 int (*action_callback)(int btn, struct gui_synclist *lists), 93 int (*action_callback)(int btn, struct gui_synclist *lists),
93 char* (*dbg_getname)(int item, void * data, char *buffer)) 94 char* (*dbg_getname)(int item, void * data, char *buffer))
@@ -99,6 +100,8 @@ static bool dbg_list(char *title, int count, int selection_size,
99 gui_synclist_set_title(&lists, title, NOICON); 100 gui_synclist_set_title(&lists, title, NOICON);
100 gui_synclist_set_icon_callback(&lists, NULL); 101 gui_synclist_set_icon_callback(&lists, NULL);
101 gui_synclist_set_nb_items(&lists, count*selection_size); 102 gui_synclist_set_nb_items(&lists, count*selection_size);
103 if (dbg_getname != dbg_menu_getname)
104 gui_synclist_hide_selection_marker(&lists, true);
102 action_signalscreenchange(); 105 action_signalscreenchange();
103 gui_synclist_draw(&lists); 106 gui_synclist_draw(&lists);
104 while(1) 107 while(1)
@@ -659,7 +662,7 @@ static char* dbg_partitions_getname(int selected_item, void * data, char *buffer
659 struct partinfo* p = disk_partinfo(partition); 662 struct partinfo* p = disk_partinfo(partition);
660 if (selected_item%2) 663 if (selected_item%2)
661 { 664 {
662 snprintf(buffer, MAX_PATH, "T:%x %ld MB", p->type, p->size / 2048); 665 snprintf(buffer, MAX_PATH, " T:%x %ld MB", p->type, p->size / 2048);
663 } 666 }
664 else 667 else
665 { 668 {
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 43bbbe27cb..8fb99c1a66 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -96,6 +96,15 @@ static void gui_list_init(struct gui_list * gui_list,
96 96
97 gui_list->last_displayed_selected_item = -1 ; 97 gui_list->last_displayed_selected_item = -1 ;
98 gui_list->last_displayed_start_item = -1 ; 98 gui_list->last_displayed_start_item = -1 ;
99 gui_list->show_selection_marker = true;
100}
101
102/* this toggles the selection bar or cursor */
103void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide)
104{
105 int i;
106 FOR_NB_SCREENS(i)
107 lists->gui_list[i].show_selection_marker = !hide;
99} 108}
100 109
101/* 110/*
@@ -285,7 +294,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
285 draw_scrollbar = (global_settings.scrollbar && 294 draw_scrollbar = (global_settings.scrollbar &&
286 lines < gui_list->nb_items); 295 lines < gui_list->nb_items);
287 296
288 draw_cursor = !global_settings.invert_cursor; 297 draw_cursor = !global_settings.invert_cursor &&
298 gui_list->show_selection_marker;
289 text_pos = 0; /* here it's in pixels */ 299 text_pos = 0; /* here it's in pixels */
290 if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's 300 if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's
291 a title */ 301 a title */
@@ -340,7 +350,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
340 item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos); 350 item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos);
341#endif 351#endif
342 352
343 if(current_item >= gui_list->selected_item && 353 if(gui_list->show_selection_marker &&
354 current_item >= gui_list->selected_item &&
344 current_item < gui_list->selected_item + gui_list->selected_size) 355 current_item < gui_list->selected_item + gui_list->selected_size)
345 {/* The selected item must be displayed scrolling */ 356 {/* The selected item must be displayed scrolling */
346#ifdef HAVE_LCD_BITMAP 357#ifdef HAVE_LCD_BITMAP
@@ -470,10 +481,19 @@ static void gui_list_select_above(struct gui_list * gui_list, int items)
470 nb_lines--; 481 nb_lines--;
471 482
472 gui_list->selected_item -= items; 483 gui_list->selected_item -= items;
484
473 /* in bottom "3rd" of the screen, so dont move the start item. 485 /* in bottom "3rd" of the screen, so dont move the start item.
474 by 3rd I mean above SCROLL_LIMIT lines above the end of the screen */ 486 by 3rd I mean above SCROLL_LIMIT lines above the end of the screen */
475 if (items && gui_list->start_item + SCROLL_LIMIT < gui_list->selected_item) 487 if (items && gui_list->start_item + SCROLL_LIMIT < gui_list->selected_item)
488 {
489 if (gui_list->show_selection_marker == false)
490 {
491 gui_list->start_item -= items;
492 if (gui_list->start_item < 0)
493 gui_list->start_item = 0;
494 }
476 return; 495 return;
496 }
477 if (gui_list->selected_item < 0) 497 if (gui_list->selected_item < 0)
478 { 498 {
479 if(gui_list->limit_scroll) 499 if(gui_list->limit_scroll)
@@ -515,15 +535,36 @@ static void gui_list_select_above(struct gui_list * gui_list, int items)
515static void gui_list_select_below(struct gui_list * gui_list, int items) 535static void gui_list_select_below(struct gui_list * gui_list, int items)
516{ 536{
517 int nb_lines = gui_list->display->nb_lines; 537 int nb_lines = gui_list->display->nb_lines;
538 int bottom;
518 if (SHOW_LIST_TITLE) 539 if (SHOW_LIST_TITLE)
519 nb_lines--; 540 nb_lines--;
520 541
521 gui_list->selected_item += items; 542 gui_list->selected_item += items;
543 bottom = gui_list->nb_items - nb_lines;
544
545 /* always move the screen if selection isnt "visible" */
546 if (items && gui_list->show_selection_marker == false)
547 {
548 if (bottom < 0)
549 bottom = 0;
550 gui_list->start_item = MIN(bottom, gui_list->start_item +
551 items);
552 return;
553 }
522 /* in top "3rd" of the screen, so dont move the start item */ 554 /* in top "3rd" of the screen, so dont move the start item */
523 if (items && 555 if (items &&
524 (gui_list->start_item + nb_lines - SCROLL_LIMIT > gui_list->selected_item) 556 (gui_list->start_item + nb_lines - SCROLL_LIMIT > gui_list->selected_item)
525 && (gui_list->selected_item < gui_list->nb_items)) 557 && (gui_list->selected_item < gui_list->nb_items))
558 {
559 if (gui_list->show_selection_marker == false)
560 {
561 if (bottom < 0)
562 bottom = 0;
563 gui_list->start_item = MIN(bottom,
564 gui_list->start_item + items);
565 }
526 return; 566 return;
567 }
527 568
528 if (gui_list->selected_item >= gui_list->nb_items) 569 if (gui_list->selected_item >= gui_list->nb_items)
529 { 570 {
@@ -539,7 +580,7 @@ static void gui_list_select_below(struct gui_list * gui_list, int items)
539 } 580 }
540 return; 581 return;
541 } 582 }
542 int bottom = gui_list->nb_items - nb_lines; 583
543 if (gui_list->nb_items > nb_lines) 584 if (gui_list->nb_items > nb_lines)
544 { 585 {
545 if (global_settings.scroll_paginated) 586 if (global_settings.scroll_paginated)
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 283676d631..021f55ef94 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -100,6 +100,7 @@ struct gui_list
100 char * title; 100 char * title;
101 /* Optional title icon */ 101 /* Optional title icon */
102 enum themable_icons title_icon; 102 enum themable_icons title_icon;
103 bool show_selection_marker; /* set to true by default */
103}; 104};
104 105
105/* 106/*
@@ -189,7 +190,8 @@ extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
189extern void gui_synclist_flash(struct gui_synclist * lists); 190extern void gui_synclist_flash(struct gui_synclist * lists);
190extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, 191extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
191 int icon); 192 int icon);
192 193extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
194 bool hide);
193/* 195/*
194 * Do the action implied by the given button, 196 * Do the action implied by the given button,
195 * returns the action taken if any, 0 else 197 * returns the action taken if any, 0 else