1
0
Fork 0
forked from len0rd/rockbox

Add "%LN" tag to retrieve the list item number of the current item. This allows e.g. putting item numbers in skinned lists.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30568 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2011-09-18 12:35:32 +00:00
parent e12a832758
commit 28d5f2aa57
5 changed files with 14 additions and 0 deletions

View file

@ -82,6 +82,12 @@ static int offset_to_item(int offset, bool wrap)
item = item % current_list->nb_items; item = item % current_list->nb_items;
return item; return item;
} }
int skinlist_get_item_number()
{
return current_drawing_line;
}
const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size) const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size)
{ {
int item = offset_to_item(offset, wrap); int item = offset_to_item(offset, wrap);

View file

@ -190,6 +190,7 @@ bool skinlist_is_selected_item(void);
void skinlist_set_cfg(enum screen_type screen, void skinlist_set_cfg(enum screen_type screen,
struct listitem_viewport_cfg *cfg); struct listitem_viewport_cfg *cfg);
const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size); const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size);
int skinlist_get_item_number(void);
enum themable_icons skinlist_get_item_icon(int offset, bool wrap); enum themable_icons skinlist_get_item_icon(int offset, bool wrap);
bool skinlist_needs_scrollbar(enum screen_type screen); bool skinlist_needs_scrollbar(enum screen_type screen);
void skinlist_get_scrollbar(int* nb_item, int* first_shown, int* last_shown); void skinlist_get_scrollbar(int* nb_item, int* first_shown, int* last_shown);

View file

@ -932,6 +932,11 @@ const char *get_token_value(struct gui_wps *gwps,
struct listitem *li = (struct listitem *)token->value.data; struct listitem *li = (struct listitem *)token->value.data;
return skinlist_get_item_text(li->offset, li->wrap, buf, buf_size); return skinlist_get_item_text(li->offset, li->wrap, buf, buf_size);
} }
case SKIN_TOKEN_LIST_ITEM_NUMBER:
if (intval)
*intval = skinlist_get_item_number();
snprintf(buf, buf_size, "%d",skinlist_get_item_number());
return buf;
case SKIN_TOKEN_LIST_ITEM_IS_SELECTED: case SKIN_TOKEN_LIST_ITEM_IS_SELECTED:
return skinlist_is_selected_item()?"s":""; return skinlist_is_selected_item()?"s":"";
case SKIN_TOKEN_LIST_ITEM_ICON: case SKIN_TOKEN_LIST_ITEM_ICON:

View file

@ -189,6 +189,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_VIEWPORT_CUSTOMLIST, "Vp" , "IC", SKIN_REFRESH_DYNAMIC|NOBREAK }, { SKIN_TOKEN_VIEWPORT_CUSTOMLIST, "Vp" , "IC", SKIN_REFRESH_DYNAMIC|NOBREAK },
{ SKIN_TOKEN_LIST_TITLE_TEXT, "Lt" , "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_LIST_TITLE_TEXT, "Lt" , "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_LIST_ITEM_TEXT, "LT", "|IS", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_LIST_ITEM_TEXT, "LT", "|IS", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_LIST_ITEM_NUMBER, "LN", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_LIST_TITLE_ICON, "Li" , "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_LIST_TITLE_ICON, "Li" , "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_LIST_ITEM_ICON, "LI", "|IS", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_LIST_ITEM_ICON, "LI", "|IS", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_LIST_ITEM_CFG, "Lb" , "Sii|S", SKIN_REFRESH_STATIC }, { SKIN_TOKEN_LIST_ITEM_CFG, "Lb" , "Sii|S", SKIN_REFRESH_STATIC },

View file

@ -216,6 +216,7 @@ enum skin_token_type {
SKIN_TOKEN_LIST_SELECTED_ITEM_CFG, SKIN_TOKEN_LIST_SELECTED_ITEM_CFG,
SKIN_TOKEN_LIST_ITEM_IS_SELECTED, SKIN_TOKEN_LIST_ITEM_IS_SELECTED,
SKIN_TOKEN_LIST_ITEM_TEXT, SKIN_TOKEN_LIST_ITEM_TEXT,
SKIN_TOKEN_LIST_ITEM_NUMBER,
SKIN_TOKEN_LIST_ITEM_ICON, SKIN_TOKEN_LIST_ITEM_ICON,
SKIN_TOKEN_LIST_NEEDS_SCROLLBAR, SKIN_TOKEN_LIST_NEEDS_SCROLLBAR,
SKIN_TOKEN_LIST_SCROLLBAR, SKIN_TOKEN_LIST_SCROLLBAR,