lists: Support '\t' in list item text to indent the line containing it.

Change-Id: I1583371228ed477b504c135f81cb59a0c3c931e6
Reviewed-on: http://gerrit.rockbox.org/296
Reviewed-by: Jonathan Gordon <rockbox@jdgordon.info>
Tested-by: Jonathan Gordon <rockbox@jdgordon.info>
This commit is contained in:
Jonathan Gordon 2012-07-18 23:19:11 +02:00
parent 323282f22d
commit 08238178d3

View file

@ -154,6 +154,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
int icon_yoffset = 0; /* to center the icon */ int icon_yoffset = 0; /* to center the icon */
bool show_title; bool show_title;
struct viewport *list_text_vp = &list_text[screen]; struct viewport *list_text_vp = &list_text[screen];
int indent = 0;
line_height = parent->line_height; line_height = parent->line_height;
display->set_viewport(parent); display->set_viewport(parent);
@ -249,9 +250,28 @@ void list_draw(struct screen *display, struct gui_synclist *list)
unsigned char *entry_name; unsigned char *entry_name;
int text_pos = 0; int text_pos = 0;
int line = i - start; int line = i - start;
indent = 0;
s = list->callback_get_item_name(i, list->data, entry_buffer, s = list->callback_get_item_name(i, list->data, entry_buffer,
sizeof(entry_buffer)); sizeof(entry_buffer));
entry_name = P2STR(s); entry_name = P2STR(s);
while (*entry_name == '\t')
{
indent++;
entry_name++;
}
if (indent)
{
if (icon_width)
indent *= icon_width;
else
indent *= display->getcharwidth();
list_icons.x += indent;
list_text_vp->x += indent;
list_text_vp->width -= indent;
}
display->set_viewport(list_text_vp); display->set_viewport(list_text_vp);
style = STYLE_DEFAULT; style = STYLE_DEFAULT;
/* position the string at the correct offset place */ /* position the string at the correct offset place */
@ -353,6 +373,12 @@ void list_draw(struct screen *display, struct gui_synclist *list)
line*line_height + draw_offset + icon_yoffset, line*line_height + draw_offset + icon_yoffset,
Icon_Cursor); Icon_Cursor);
} }
if (indent)
{
list_icons.x -= indent;
list_text_vp->x -= indent;
list_text_vp->width += indent;
}
} }
display->set_viewport(parent); display->set_viewport(parent);
display->update_viewport(); display->update_viewport();