diff options
Diffstat (limited to 'apps/gui/charcell/list.c')
-rw-r--r-- | apps/gui/charcell/list.c | 67 |
1 files changed, 25 insertions, 42 deletions
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) | |||
49 | 49 | ||
50 | void list_draw(struct screen *display, struct gui_synclist *gui_list) | 50 | void list_draw(struct screen *display, struct gui_synclist *gui_list) |
51 | { | 51 | { |
52 | int text_pos; | ||
53 | bool draw_icons = (gui_list->callback_get_item_icon != NULL); | 52 | bool draw_icons = (gui_list->callback_get_item_icon != NULL); |
54 | bool draw_cursor; | 53 | bool selected; |
55 | int i; | 54 | int i; |
56 | int start, end; | 55 | int start, end; |
57 | 56 | ||
@@ -61,12 +60,13 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list) | |||
61 | start = 0; | 60 | start = 0; |
62 | end = display->getnblines(); | 61 | end = display->getnblines(); |
63 | 62 | ||
64 | /* Adjust the position of icon, cursor, text for the list */ | 63 | struct line_desc desc = { |
65 | draw_cursor = true; | 64 | .height = -1, |
66 | if(draw_icons) | 65 | .text_color = 1, |
67 | text_pos = 2; /* here it's in chars */ | 66 | .line_color = 1, |
68 | else | 67 | .line_end_color = 1, |
69 | text_pos = 1; | 68 | .style = STYLE_DEFAULT |
69 | }; | ||
70 | 70 | ||
71 | for (i = start; i < end; i++) | 71 | for (i = start; i < end; i++) |
72 | { | 72 | { |
@@ -85,43 +85,26 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list) | |||
85 | sizeof(entry_buffer)); | 85 | sizeof(entry_buffer)); |
86 | entry_name = P2STR(s); | 86 | entry_name = P2STR(s); |
87 | 87 | ||
88 | if (gui_list->show_selection_marker && | ||
89 | current_item >= gui_list->selected_item && | ||
90 | current_item < gui_list->selected_item + gui_list->selected_size) | ||
91 | selected = true; /* The selected item must be displayed scrolling */ | ||
92 | else | ||
93 | selected = false; | ||
88 | 94 | ||
89 | if(gui_list->show_selection_marker && | 95 | desc.nlines = gui_list->selected_size, |
90 | current_item >= gui_list->selected_item && | 96 | desc.line = gui_list->selected_size > 1 ? i : 0, |
91 | current_item < gui_list->selected_item + gui_list->selected_size) | 97 | desc.scroll = selected ? true : gui_list->scroll_all; |
92 | {/* The selected item must be displayed scrolling */ | ||
93 | display->puts_scroll(text_pos, i, entry_name); | ||
94 | 98 | ||
95 | if (draw_cursor) | 99 | if (draw_icons) |
96 | { | 100 | put_line(display, 0, i, &desc, "$i$i$t", |
97 | screen_put_icon_with_offset(display, 0, i, | 101 | selected ? Icon_Cursor : Icon_NOICON, |
98 | (draw_scrollbar || SHOW_LIST_TITLE)? | 102 | gui_list->callback_get_item_icon(current_item, gui_list->data), |
99 | SCROLLBAR_WIDTH: 0, | 103 | entry_name); |
100 | 0, Icon_Cursor); | ||
101 | } | ||
102 | } | ||
103 | else | 104 | else |
104 | {/* normal item */ | 105 | put_line(display, 0, i, &desc, "$i$t", |
105 | if(gui_list->scroll_all) | 106 | selected ? Icon_Cursor : Icon_NOICON, |
106 | { | 107 | entry_name); |
107 | display->puts_scroll(text_pos, i, entry_name); | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | display->puts(text_pos, i, entry_name); | ||
112 | } | ||
113 | } | ||
114 | /* Icons display */ | ||
115 | if(draw_icons) | ||
116 | { | ||
117 | enum themable_icons icon; | ||
118 | icon = gui_list->callback_get_item_icon(current_item, | ||
119 | gui_list->data); | ||
120 | if(icon > Icon_NOICON) | ||
121 | { | ||
122 | screen_put_icon(display, 1, i, icon); | ||
123 | } | ||
124 | } | ||
125 | } | 108 | } |
126 | 109 | ||
127 | display->update_viewport(); | 110 | display->update_viewport(); |