From 08238178d3840b57e7a2e782fdf8182a2786870c Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 18 Jul 2012 23:19:11 +0200 Subject: 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 Tested-by: Jonathan Gordon --- apps/gui/bitmap/list.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index aad3eda98f..45e6c03dcf 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -154,6 +154,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) int icon_yoffset = 0; /* to center the icon */ bool show_title; struct viewport *list_text_vp = &list_text[screen]; + int indent = 0; line_height = parent->line_height; display->set_viewport(parent); @@ -249,9 +250,28 @@ void list_draw(struct screen *display, struct gui_synclist *list) unsigned char *entry_name; int text_pos = 0; int line = i - start; + indent = 0; s = list->callback_get_item_name(i, list->data, entry_buffer, sizeof(entry_buffer)); 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); style = STYLE_DEFAULT; /* 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, Icon_Cursor); } + if (indent) + { + list_icons.x -= indent; + list_text_vp->x -= indent; + list_text_vp->width += indent; + } } display->set_viewport(parent); display->update_viewport(); -- cgit v1.2.3