summaryrefslogtreecommitdiff
path: root/apps/gui/bitmap/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/bitmap/list.c')
-rw-r--r--apps/gui/bitmap/list.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 69cda9fa85..09a66f3386 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -102,13 +102,15 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
102 if (!list_display_title(list, screen)) 102 if (!list_display_title(list, screen))
103 return false; 103 return false;
104 *title_text_vp = *(list->parent[screen]); 104 *title_text_vp = *(list->parent[screen]);
105 title_text_vp->height = font_get(title_text_vp->font)->height; 105 title_text_vp->height = title_text_vp->line_height;
106 106
107 if (list->title_icon != Icon_NOICON && global_settings.show_icons) 107 if (list->title_icon != Icon_NOICON && global_settings.show_icons)
108 { 108 {
109 struct viewport title_icon = *title_text_vp; 109 struct viewport title_icon = *title_text_vp;
110 110
111 title_icon.width = get_icon_width(screen) + ICON_PADDING * 2; 111 title_icon.width = get_icon_width(screen) + ICON_PADDING * 2;
112 title_icon.y += (title_icon.height - get_icon_height(screen)) / 2;
113 title_icon.height = get_icon_height(screen);
112 if (VP_IS_RTL(&title_icon)) 114 if (VP_IS_RTL(&title_icon))
113 { 115 {
114 title_icon.x += title_text_vp->width - title_icon.width; 116 title_icon.x += title_text_vp->width - title_icon.width;
@@ -120,7 +122,7 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
120 title_text_vp->width -= title_icon.width; 122 title_text_vp->width -= title_icon.width;
121 123
122 display->set_viewport(&title_icon); 124 display->set_viewport(&title_icon);
123 screen_put_icon(display, 0, 0, list->title_icon); 125 screen_put_iconxy(display, 0, 0, list->title_icon);
124 } 126 }
125#ifdef HAVE_LCD_COLOR 127#ifdef HAVE_LCD_COLOR
126 if (list->title_color >= 0) 128 if (list->title_color >= 0)
@@ -136,7 +138,7 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
136void list_draw(struct screen *display, struct gui_synclist *list) 138void list_draw(struct screen *display, struct gui_synclist *list)
137{ 139{
138 struct viewport list_icons; 140 struct viewport list_icons;
139 int start, end, line_height, style, i; 141 int start, end, line_height, style, item_offset, i;
140 const int screen = display->screen_type; 142 const int screen = display->screen_type;
141 const int list_start_item = list->start_item[screen]; 143 const int list_start_item = list->start_item[screen];
142 const int icon_width = get_icon_width(screen) + ICON_PADDING; 144 const int icon_width = get_icon_width(screen) + ICON_PADDING;
@@ -147,19 +149,21 @@ void list_draw(struct screen *display, struct gui_synclist *list)
147#ifdef HAVE_LCD_COLOR 149#ifdef HAVE_LCD_COLOR
148 unsigned char cur_line = 0; 150 unsigned char cur_line = 0;
149#endif 151#endif
150 int item_offset; 152 int icon_yoffset = 0; /* to center the icon */
151 bool show_title; 153 bool show_title;
152 struct viewport *list_text_vp = &list_text[screen]; 154 struct viewport *list_text_vp = &list_text[screen];
153 155
154 line_height = font_get(parent->font)->height; 156 line_height = parent->line_height;
155 display->set_viewport(parent); 157 display->set_viewport(parent);
156 display->clear_viewport(); 158 display->clear_viewport();
157 display->scroll_stop(list_text_vp); 159 display->scroll_stop(list_text_vp);
158 *list_text_vp = *parent; 160 *list_text_vp = *parent;
161 list_text_vp->line_height = line_height;
159 if ((show_title = draw_title(display, list))) 162 if ((show_title = draw_title(display, list)))
160 { 163 {
161 list_text_vp->y += line_height; 164 int title_height = title_text[screen].height;
162 list_text_vp->height -= line_height; 165 list_text_vp->y += title_height;
166 list_text_vp->height -= title_height;
163 } 167 }
164 168
165 const int nb_lines = viewport_get_nb_lines(list_text_vp); 169 const int nb_lines = viewport_get_nb_lines(list_text_vp);
@@ -232,6 +236,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
232 list_icons.x += list_text_vp->width + ICON_PADDING; 236 list_icons.x += list_text_vp->width + ICON_PADDING;
233 else 237 else
234 list_text_vp->x += list_icons.width + ICON_PADDING; 238 list_text_vp->x += list_icons.width + ICON_PADDING;
239 icon_yoffset = (line_height - get_icon_height(screen)) / 2;
235 } 240 }
236 241
237 for (i=start; i<end && i<list->nb_items; i++) 242 for (i=start; i<end && i<list->nb_items; i++)
@@ -333,14 +338,18 @@ void list_draw(struct screen *display, struct gui_synclist *list)
333 display->set_viewport(&list_icons); 338 display->set_viewport(&list_icons);
334 if (list->callback_get_item_icon != NULL) 339 if (list->callback_get_item_icon != NULL)
335 { 340 {
336 screen_put_icon_with_offset(display, show_cursor?1:0, 341 int xoff = show_cursor ? get_icon_width(screen) + ICON_PADDING : 0;
337 (line),show_cursor?ICON_PADDING:0,draw_offset, 342 screen_put_iconxy(display, xoff,
338 list->callback_get_item_icon(i, list->data)); 343 line*line_height + draw_offset + icon_yoffset,
344 list->callback_get_item_icon(i, list->data));
339 } 345 }
346 /* do the cursor */
340 if (show_cursor && i >= list->selected_item && 347 if (show_cursor && i >= list->selected_item &&
341 i < list->selected_item + list->selected_size) 348 i < list->selected_item + list->selected_size)
342 { 349 {
343 screen_put_icon_with_offset(display, 0, line, 0, draw_offset, Icon_Cursor); 350 screen_put_iconxy(display, 0,
351 line*line_height + draw_offset + icon_yoffset,
352 Icon_Cursor);
344 } 353 }
345 } 354 }
346 display->set_viewport(parent); 355 display->set_viewport(parent);
@@ -369,8 +378,7 @@ static int scrollbar_scroll(struct gui_synclist * gui_list,
369 { 378 {
370 /* scrollbar scrolling is still line based */ 379 /* scrollbar scrolling is still line based */
371 y_offset = 0; 380 y_offset = 0;
372 int scrollbar_size = nb_lines* 381 int scrollbar_size = nb_lines*gui_list->parent[screen]->line_height;
373 font_get(gui_list->parent[screen]->font)->height;
374 int actual_y = y - list_text[screen].y; 382 int actual_y = y - list_text[screen].y;
375 383
376 int new_selection = (actual_y * gui_list->nb_items) 384 int new_selection = (actual_y * gui_list->nb_items)
@@ -558,7 +566,7 @@ static int kinetic_callback(struct timeout *tmo)
558 return 0; 566 return 0;
559 567
560 struct cb_data *data = (struct cb_data*)tmo->data; 568 struct cb_data *data = (struct cb_data*)tmo->data;
561 int line_height = font_get(data->list->parent[0]->font)->height; 569 int line_height = data->list->parent[0]->line_height;
562 /* ds = v*dt */ 570 /* ds = v*dt */
563 int pixel_diff = data->velocity * RELOAD_INTERVAL / HZ; 571 int pixel_diff = data->velocity * RELOAD_INTERVAL / HZ;
564 /* remember signedness to detect stopping */ 572 /* remember signedness to detect stopping */
@@ -627,7 +635,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
627 struct viewport *parent = gui_list->parent[screen]; 635 struct viewport *parent = gui_list->parent[screen];
628 const int button = action_get_touchscreen_press_in_vp(&x, &y, parent); 636 const int button = action_get_touchscreen_press_in_vp(&x, &y, parent);
629 const int list_start_item = gui_list->start_item[screen]; 637 const int list_start_item = gui_list->start_item[screen];
630 const int line_height = font_get(gui_list->parent[screen]->font)->height; 638 const int line_height = gui_list->parent[screen]->line_height;
631 const struct viewport *list_text_vp = &list_text[screen]; 639 const struct viewport *list_text_vp = &list_text[screen];
632 const bool old_released = released; 640 const bool old_released = released;
633 const bool show_title = list_display_title(gui_list, screen); 641 const bool show_title = list_display_title(gui_list, screen);