summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-06-07 12:14:31 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-06-07 12:14:31 +0000
commit3823486a5864796cd7fcba07521f4ca2ebab3885 (patch)
treeab1564f9f1e7af51f320a6a17766f57788f662c3
parenta1f0a83a012f01cdb39025519c95df664399deed (diff)
Add a mode the lists which doesnt show the selection marker.
Useful for the debug menus where users shouldn't think pressing select would do anything. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13588 a1c6a512-1295-4272-9138-f99709370657
-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 @@
#endif
#include "hwcompat.h"
+static char* dbg_menu_getname(int item, void * data, char *buffer);
static bool dbg_list(char *title, int count, int selection_size,
int (*action_callback)(int btn, struct gui_synclist *lists),
char* (*dbg_getname)(int item, void * data, char *buffer))
@@ -99,6 +100,8 @@ static bool dbg_list(char *title, int count, int selection_size,
gui_synclist_set_title(&lists, title, NOICON);
gui_synclist_set_icon_callback(&lists, NULL);
gui_synclist_set_nb_items(&lists, count*selection_size);
+ if (dbg_getname != dbg_menu_getname)
+ gui_synclist_hide_selection_marker(&lists, true);
action_signalscreenchange();
gui_synclist_draw(&lists);
while(1)
@@ -659,7 +662,7 @@ static char* dbg_partitions_getname(int selected_item, void * data, char *buffer
struct partinfo* p = disk_partinfo(partition);
if (selected_item%2)
{
- snprintf(buffer, MAX_PATH, "T:%x %ld MB", p->type, p->size / 2048);
+ snprintf(buffer, MAX_PATH, " T:%x %ld MB", p->type, p->size / 2048);
}
else
{
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,
gui_list->last_displayed_selected_item = -1 ;
gui_list->last_displayed_start_item = -1 ;
+ gui_list->show_selection_marker = true;
+}
+
+/* this toggles the selection bar or cursor */
+void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide)
+{
+ int i;
+ FOR_NB_SCREENS(i)
+ lists->gui_list[i].show_selection_marker = !hide;
}
/*
@@ -285,7 +294,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
draw_scrollbar = (global_settings.scrollbar &&
lines < gui_list->nb_items);
- draw_cursor = !global_settings.invert_cursor;
+ draw_cursor = !global_settings.invert_cursor &&
+ gui_list->show_selection_marker;
text_pos = 0; /* here it's in pixels */
if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's
a title */
@@ -340,7 +350,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos);
#endif
- if(current_item >= gui_list->selected_item &&
+ if(gui_list->show_selection_marker &&
+ current_item >= gui_list->selected_item &&
current_item < gui_list->selected_item + gui_list->selected_size)
{/* The selected item must be displayed scrolling */
#ifdef HAVE_LCD_BITMAP
@@ -470,10 +481,19 @@ static void gui_list_select_above(struct gui_list * gui_list, int items)
nb_lines--;
gui_list->selected_item -= items;
+
/* in bottom "3rd" of the screen, so dont move the start item.
by 3rd I mean above SCROLL_LIMIT lines above the end of the screen */
if (items && gui_list->start_item + SCROLL_LIMIT < gui_list->selected_item)
+ {
+ if (gui_list->show_selection_marker == false)
+ {
+ gui_list->start_item -= items;
+ if (gui_list->start_item < 0)
+ gui_list->start_item = 0;
+ }
return;
+ }
if (gui_list->selected_item < 0)
{
if(gui_list->limit_scroll)
@@ -515,15 +535,36 @@ static void gui_list_select_above(struct gui_list * gui_list, int items)
static void gui_list_select_below(struct gui_list * gui_list, int items)
{
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;
+
+ /* always move the screen if selection isnt "visible" */
+ if (items && gui_list->show_selection_marker == false)
+ {
+ if (bottom < 0)
+ bottom = 0;
+ gui_list->start_item = MIN(bottom, gui_list->start_item +
+ items);
+ return;
+ }
/* in top "3rd" of the screen, so dont move the start item */
if (items &&
(gui_list->start_item + nb_lines - SCROLL_LIMIT > gui_list->selected_item)
&& (gui_list->selected_item < gui_list->nb_items))
+ {
+ if (gui_list->show_selection_marker == false)
+ {
+ if (bottom < 0)
+ bottom = 0;
+ gui_list->start_item = MIN(bottom,
+ gui_list->start_item + items);
+ }
return;
+ }
if (gui_list->selected_item >= gui_list->nb_items)
{
@@ -539,7 +580,7 @@ static void gui_list_select_below(struct gui_list * gui_list, int items)
}
return;
}
- int bottom = gui_list->nb_items - nb_lines;
+
if (gui_list->nb_items > nb_lines)
{
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
char * title;
/* Optional title icon */
enum themable_icons title_icon;
+ bool show_selection_marker; /* set to true by default */
};
/*
@@ -189,7 +190,8 @@ extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
extern void gui_synclist_flash(struct gui_synclist * lists);
extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
int icon);
-
+extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
+ bool hide);
/*
* Do the action implied by the given button,
* returns the action taken if any, 0 else