mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Add %LR and %LC to get at the current row and columm in skinned lists.
This allows list items to be rendered differently depending on their on-screen position, allowing things like gradients or nonlinear alignment Change-Id: I1d9c080f97e83707f0e80f57abc762cb2b94f6ed
This commit is contained in:
parent
7d599b4311
commit
b5cd5ce8a1
5 changed files with 36 additions and 5 deletions
|
@ -45,6 +45,9 @@
|
||||||
static struct listitem_viewport_cfg *listcfg[NB_SCREENS] = {NULL};
|
static struct listitem_viewport_cfg *listcfg[NB_SCREENS] = {NULL};
|
||||||
static struct gui_synclist *current_list;
|
static struct gui_synclist *current_list;
|
||||||
|
|
||||||
|
static int current_row;
|
||||||
|
static int current_column;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +91,17 @@ int skinlist_get_item_number()
|
||||||
return current_drawing_line;
|
return current_drawing_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int skinlist_get_item_row()
|
||||||
|
{
|
||||||
|
return current_row;
|
||||||
|
}
|
||||||
|
|
||||||
|
int skinlist_get_item_column()
|
||||||
|
{
|
||||||
|
return current_column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -181,7 +195,7 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
|
||||||
current_drawing_line = list_start_item+cur_line;
|
current_drawing_line = list_start_item+cur_line;
|
||||||
is_selected = list->show_selection_marker &&
|
is_selected = list->show_selection_marker &&
|
||||||
list_start_item+cur_line == list->selected_item;
|
list_start_item+cur_line == list->selected_item;
|
||||||
|
|
||||||
for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree);
|
for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree);
|
||||||
viewport;
|
viewport;
|
||||||
viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), viewport->next))
|
viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), viewport->next))
|
||||||
|
@ -206,14 +220,15 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
|
||||||
if (listcfg[screen]->tile)
|
if (listcfg[screen]->tile)
|
||||||
{
|
{
|
||||||
int cols = (parent->width / listcfg[screen]->width);
|
int cols = (parent->width / listcfg[screen]->width);
|
||||||
int col = (cur_line)%cols;
|
current_column = (cur_line)%cols;
|
||||||
int row = (cur_line)/cols;
|
current_row = (cur_line)/cols;
|
||||||
|
|
||||||
skin_viewport->vp.x = parent->x + listcfg[screen]->width*col + origional_x;
|
skin_viewport->vp.x = parent->x + listcfg[screen]->width*current_column + origional_x;
|
||||||
skin_viewport->vp.y = parent->y + listcfg[screen]->height*row + origional_y;
|
skin_viewport->vp.y = parent->y + listcfg[screen]->height*current_row + origional_y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
current_row = cur_line;
|
||||||
skin_viewport->vp.x = parent->x + origional_x;
|
skin_viewport->vp.x = parent->x + origional_x;
|
||||||
skin_viewport->vp.y = parent->y + origional_y +
|
skin_viewport->vp.y = parent->y + origional_y +
|
||||||
(listcfg[screen]->height*cur_line);
|
(listcfg[screen]->height*cur_line);
|
||||||
|
|
|
@ -194,6 +194,8 @@ 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);
|
int skinlist_get_item_number(void);
|
||||||
|
int skinlist_get_item_row(void);
|
||||||
|
int skinlist_get_item_column(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);
|
||||||
|
|
|
@ -981,6 +981,16 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
struct listitem *li = (struct listitem *)SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
|
struct listitem *li = (struct listitem *)SKINOFFSETTOPTR(get_skin_buffer(data), 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_ROW:
|
||||||
|
if (intval)
|
||||||
|
*intval = skinlist_get_item_row() + 1;
|
||||||
|
snprintf(buf, buf_size, "%d",skinlist_get_item_row() + 1);
|
||||||
|
return buf;
|
||||||
|
case SKIN_TOKEN_LIST_ITEM_COLUMN:
|
||||||
|
if (intval)
|
||||||
|
*intval = skinlist_get_item_column() + 1;
|
||||||
|
snprintf(buf, buf_size, "%d",skinlist_get_item_column() + 1);
|
||||||
|
return buf;
|
||||||
case SKIN_TOKEN_LIST_ITEM_NUMBER:
|
case SKIN_TOKEN_LIST_ITEM_NUMBER:
|
||||||
if (intval)
|
if (intval)
|
||||||
*intval = skinlist_get_item_number() + 1;
|
*intval = skinlist_get_item_number() + 1;
|
||||||
|
|
|
@ -191,6 +191,8 @@ 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_ROW, "LR", "", SKIN_REFRESH_DYNAMIC },
|
||||||
|
{ SKIN_TOKEN_LIST_ITEM_COLUMN, "LC", "", SKIN_REFRESH_DYNAMIC },
|
||||||
{ SKIN_TOKEN_LIST_ITEM_NUMBER, "LN", "", 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 },
|
||||||
|
|
|
@ -219,6 +219,8 @@ 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_ROW,
|
||||||
|
SKIN_TOKEN_LIST_ITEM_COLUMN,
|
||||||
SKIN_TOKEN_LIST_ITEM_NUMBER,
|
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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue