From eec89a90ffdd077d687914fe18a9e48028f07fb4 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 20 Dec 2013 23:34:28 +0100 Subject: lists: Adapt put_line(). This enables removing large portions of code, simplifiyng the drawing routine. All of the removed code is functionaltiy now available through put_line(). Change-Id: Ib8e61772134189a8c3c6d22345c0b45e912bea76 --- apps/gui/charcell/list.c | 67 ++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 42 deletions(-) (limited to 'apps/gui/charcell') diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c index 753b8ff853..cbee8b0d9d 100644 --- a/apps/gui/charcell/list.c +++ b/apps/gui/charcell/list.c @@ -49,9 +49,8 @@ void gui_synclist_scroll_stop(struct gui_synclist *lists) void list_draw(struct screen *display, struct gui_synclist *gui_list) { - int text_pos; bool draw_icons = (gui_list->callback_get_item_icon != NULL); - bool draw_cursor; + bool selected; int i; int start, end; @@ -61,12 +60,13 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list) start = 0; end = display->getnblines(); - /* Adjust the position of icon, cursor, text for the list */ - draw_cursor = true; - if(draw_icons) - text_pos = 2; /* here it's in chars */ - else - text_pos = 1; + struct line_desc desc = { + .height = -1, + .text_color = 1, + .line_color = 1, + .line_end_color = 1, + .style = STYLE_DEFAULT + }; for (i = start; i < end; i++) { @@ -85,43 +85,26 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list) sizeof(entry_buffer)); entry_name = P2STR(s); + if (gui_list->show_selection_marker && + current_item >= gui_list->selected_item && + current_item < gui_list->selected_item + gui_list->selected_size) + selected = true; /* The selected item must be displayed scrolling */ + else + selected = false; - if(gui_list->show_selection_marker && - current_item >= gui_list->selected_item && - current_item < gui_list->selected_item + gui_list->selected_size) - {/* The selected item must be displayed scrolling */ - display->puts_scroll(text_pos, i, entry_name); + desc.nlines = gui_list->selected_size, + desc.line = gui_list->selected_size > 1 ? i : 0, + desc.scroll = selected ? true : gui_list->scroll_all; - if (draw_cursor) - { - screen_put_icon_with_offset(display, 0, i, - (draw_scrollbar || SHOW_LIST_TITLE)? - SCROLLBAR_WIDTH: 0, - 0, Icon_Cursor); - } - } + if (draw_icons) + put_line(display, 0, i, &desc, "$i$i$t", + selected ? Icon_Cursor : Icon_NOICON, + gui_list->callback_get_item_icon(current_item, gui_list->data), + entry_name); else - {/* normal item */ - if(gui_list->scroll_all) - { - display->puts_scroll(text_pos, i, entry_name); - } - else - { - display->puts(text_pos, i, entry_name); - } - } - /* Icons display */ - if(draw_icons) - { - enum themable_icons icon; - icon = gui_list->callback_get_item_icon(current_item, - gui_list->data); - if(icon > Icon_NOICON) - { - screen_put_icon(display, 1, i, icon); - } - } + put_line(display, 0, i, &desc, "$i$t", + selected ? Icon_Cursor : Icon_NOICON, + entry_name); } display->update_viewport(); -- cgit v1.2.3