forked from len0rd/rockbox
show/hide icons now works properly in playlist viewer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7911 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2a7546ab75
commit
15046f99b3
5 changed files with 38 additions and 15 deletions
|
@ -40,12 +40,11 @@
|
|||
|
||||
|
||||
void gui_list_init(struct gui_list * gui_list,
|
||||
list_get_icon callback_get_item_icon,
|
||||
list_get_name callback_get_item_name,
|
||||
void * data
|
||||
)
|
||||
{
|
||||
gui_list->callback_get_item_icon = callback_get_item_icon;
|
||||
gui_list->callback_get_item_icon = NULL;
|
||||
gui_list->callback_get_item_name = callback_get_item_name;
|
||||
gui_list->display = NULL;
|
||||
gui_list_set_nb_items(gui_list, 0);
|
||||
|
@ -126,8 +125,7 @@ void gui_list_draw(struct gui_list * gui_list)
|
|||
int cursor_pos = 0;
|
||||
int icon_pos = 1;
|
||||
int text_pos;
|
||||
bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
|
||||
global_settings.show_icons) ;
|
||||
bool draw_icons = (gui_list->callback_get_item_icon != NULL ) ;
|
||||
bool draw_cursor;
|
||||
int i;
|
||||
|
||||
|
@ -363,7 +361,6 @@ void gui_list_del_item(struct gui_list * gui_list)
|
|||
*/
|
||||
void gui_synclist_init(
|
||||
struct gui_synclist * lists,
|
||||
list_get_icon callback_get_item_icon,
|
||||
list_get_name callback_get_item_name,
|
||||
void * data
|
||||
)
|
||||
|
@ -372,7 +369,6 @@ void gui_synclist_init(
|
|||
FOR_NB_SCREENS(i)
|
||||
{
|
||||
gui_list_init(&(lists->gui_list[i]),
|
||||
callback_get_item_icon,
|
||||
callback_get_item_name,
|
||||
data);
|
||||
gui_list_set_display(&(lists->gui_list[i]), &(screens[i]));
|
||||
|
@ -387,6 +383,14 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
|
|||
gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
|
||||
}
|
||||
}
|
||||
void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
|
||||
{
|
||||
int i;
|
||||
FOR_NB_SCREENS(i)
|
||||
{
|
||||
gui_list_set_icon_callback(&(lists->gui_list[i]), icon_callback);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_synclist_draw(struct gui_synclist * lists)
|
||||
{
|
||||
|
|
|
@ -136,9 +136,9 @@ struct gui_list
|
|||
* to a given item number
|
||||
* - callback_get_item_name : pointer to a function that associates a label
|
||||
* to a given item number
|
||||
* - data : extra data passed to the list callback
|
||||
*/
|
||||
extern void gui_list_init(struct gui_list * gui_list,
|
||||
list_get_icon callback_get_item_icon,
|
||||
list_get_name callback_get_item_name,
|
||||
void * data
|
||||
);
|
||||
|
@ -146,7 +146,7 @@ extern void gui_list_init(struct gui_list * gui_list,
|
|||
/*
|
||||
* Sets the numbers of items the list can currently display
|
||||
* note that the list's context like the currently pointed item is resetted
|
||||
* - gui_list : the list structure to initialize
|
||||
* - gui_list : the list structure
|
||||
* - nb_items : the numbers of items you want
|
||||
*/
|
||||
#define gui_list_set_nb_items(gui_list, nb) \
|
||||
|
@ -154,7 +154,7 @@ extern void gui_list_init(struct gui_list * gui_list,
|
|||
|
||||
/*
|
||||
* Returns the numbers of items currently in the list
|
||||
* - gui_list : the list structure to initialize
|
||||
* - gui_list : the list structure
|
||||
*/
|
||||
#define gui_list_get_nb_items(gui_list) \
|
||||
(gui_list)->nb_items
|
||||
|
@ -169,6 +169,14 @@ extern void gui_list_init(struct gui_list * gui_list,
|
|||
extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
|
||||
bool put_from_end);
|
||||
|
||||
/*
|
||||
* Sets the icon callback function
|
||||
* - gui_list : the list structure
|
||||
* - _callback : the callback function
|
||||
*/
|
||||
#define gui_list_set_icon_callback(gui_list, _callback) \
|
||||
(gui_list)->callback_get_item_icon=_callback
|
||||
|
||||
/*
|
||||
* Attach the scrolling list to a screen
|
||||
* (The previous screen attachement is lost)
|
||||
|
@ -277,14 +285,14 @@ struct gui_synclist
|
|||
|
||||
extern void gui_synclist_init(
|
||||
struct gui_synclist * lists,
|
||||
list_get_icon callback_get_item_icon,
|
||||
list_get_name callback_get_item_name,
|
||||
void * data
|
||||
);
|
||||
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
|
||||
|
||||
extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
|
||||
#define gui_synclist_get_nb_items(lists) \
|
||||
gui_list_get_nb_items(&((lists)->gui_list[0]))
|
||||
|
||||
extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
|
||||
|
||||
#define gui_synclist_get_sel_pos(lists) \
|
||||
|
|
|
@ -96,7 +96,8 @@ int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, in
|
|||
return -1;
|
||||
menus[menu].items = (struct menu_item*)mitems; /* de-const */
|
||||
gui_synclist_init(&(menus[menu].synclist),
|
||||
NULL, &menu_get_itemname, &menus[menu]);
|
||||
&menu_get_itemname, &menus[menu]);
|
||||
gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL);
|
||||
gui_synclist_set_nb_items(&(menus[menu].synclist), count);
|
||||
menus[menu].callback = callback;
|
||||
#ifdef HAS_BUTTONBAR
|
||||
|
|
|
@ -618,8 +618,9 @@ bool playlist_viewer_ex(char* filename)
|
|||
if (!playlist_viewer_init(&viewer, filename, false))
|
||||
goto exit;
|
||||
|
||||
gui_synclist_init(&playlist_lists, playlist_callback_icons,
|
||||
playlist_callback_name, &viewer);
|
||||
gui_synclist_init(&playlist_lists, playlist_callback_name, &viewer);
|
||||
gui_synclist_set_icon_callback(&playlist_lists,
|
||||
global_settings.playlist_viewer_icons?&playlist_callback_icons:NULL);
|
||||
gui_synclist_set_nb_items(&playlist_lists, viewer.num_tracks);
|
||||
gui_synclist_select_item(&playlist_lists, viewer.selected_track);
|
||||
gui_synclist_draw(&playlist_lists);
|
||||
|
@ -773,6 +774,11 @@ bool playlist_viewer_ex(char* filename)
|
|||
ret = true;
|
||||
goto exit;
|
||||
}
|
||||
gui_synclist_set_icon_callback(
|
||||
&playlist_lists,
|
||||
global_settings.playlist_viewer_icons?
|
||||
&playlist_callback_icons:NULL
|
||||
);
|
||||
gui_synclist_draw(&playlist_lists);
|
||||
break;
|
||||
|
||||
|
|
|
@ -229,7 +229,9 @@ void browse_root(void)
|
|||
gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) );
|
||||
#endif
|
||||
gui_syncstatusbar_init(&statusbars);
|
||||
gui_synclist_init(&tree_lists, &tree_get_fileicon, &tree_get_filename, &tc);
|
||||
gui_synclist_init(&tree_lists, &tree_get_filename, &tc);
|
||||
gui_synclist_set_icon_callback(&tree_lists,
|
||||
global_settings.show_icons?&tree_get_fileicon:NULL);
|
||||
#ifndef SIMULATOR
|
||||
dirbrowse();
|
||||
#else
|
||||
|
@ -338,6 +340,8 @@ static int update_dir(void)
|
|||
}
|
||||
}
|
||||
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
|
||||
gui_synclist_set_icon_callback(&tree_lists,
|
||||
global_settings.show_icons?&tree_get_fileicon:NULL);
|
||||
if( tc.selected_item >= tc.filesindir)
|
||||
tc.selected_item=tc.filesindir-1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue