summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-12-31 05:59:26 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-12-31 05:59:26 +0000
commite385ee18ce501e26189d5a2a68d092104720df30 (patch)
tree5219051887835d9750d80f71d9849ceb3aa65d82 /apps/gui/list.c
parent54919ae9176bd9cbffc8412f0c831f471b8ac4d5 (diff)
downloadrockbox-e385ee18ce501e26189d5a2a68d092104720df30.tar.gz
rockbox-e385ee18ce501e26189d5a2a68d092104720df30.zip
Decouple the statusbar drawing from the rest of the screen drawing. it is not drawn roughly 4x per second automatically.
viewport_Set_defaults() will setup the given viewport with the correct "full screen" dimensions (so start at 0,0 if statusbars are disabled or 0,8 if they are enabled.) All screens should keep the statusbar enabled, but if you really want to ignore the user setting you can disbaled it with viewportmanager_set_statusbar(false). This commit also includes some menu/list viewport cleanups from kugel in FS#9603 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19622 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 00d84cb446..b70cf424ee 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -61,7 +61,7 @@ static int force_list_reinit = false;
61 61
62static void gui_list_select_at_offset(struct gui_synclist * gui_list, 62static void gui_list_select_at_offset(struct gui_synclist * gui_list,
63 int offset); 63 int offset);
64void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list); 64void list_draw(struct screen *display, struct gui_synclist *list);
65 65
66#ifdef HAVE_LCD_BITMAP 66#ifdef HAVE_LCD_BITMAP
67static struct viewport parent[NB_SCREENS]; 67static struct viewport parent[NB_SCREENS];
@@ -106,12 +106,13 @@ void list_init_viewports(struct gui_synclist *list)
106#endif 106#endif
107 107
108#ifdef HAVE_LCD_BITMAP 108#ifdef HAVE_LCD_BITMAP
109bool list_display_title(struct gui_synclist *list, struct viewport *vp) 109bool list_display_title(struct gui_synclist *list, enum screen_type screen)
110{ 110{
111 return list->title != NULL && viewport_get_nb_lines(vp)>2; 111 return list->title != NULL &&
112 viewport_get_nb_lines(list->parent[screen])>2;
112} 113}
113#else 114#else
114#define list_display_title(l,v) false 115#define list_display_title(l, i) false
115#endif 116#endif
116 117
117/* 118/*
@@ -180,10 +181,11 @@ void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide)
180 181
181 182
182#ifdef HAVE_LCD_BITMAP 183#ifdef HAVE_LCD_BITMAP
183int list_title_height(struct gui_synclist *list, struct viewport *vp); 184int gui_list_get_item_offset(struct gui_synclist * gui_list,
184 185 int item_width,
185int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, 186 int text_pos,
186 int text_pos, struct screen * display, struct viewport *vp) 187 struct screen * display,
188 struct viewport *vp)
187{ 189{
188 int item_offset; 190 int item_offset;
189 191
@@ -241,7 +243,7 @@ void gui_synclist_draw(struct gui_synclist *gui_list)
241 last_list = gui_list; 243 last_list = gui_list;
242 FOR_NB_SCREENS(i) 244 FOR_NB_SCREENS(i)
243 { 245 {
244 list_draw(&screens[i], gui_list->parent[i], gui_list); 246 list_draw(&screens[i], gui_list);
245 } 247 }
246} 248}
247 249
@@ -253,8 +255,8 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
253 int difference = gui_list->selected_item - gui_list->start_item[screen]; 255 int difference = gui_list->selected_item - gui_list->start_item[screen];
254 struct viewport vp = *gui_list->parent[screen]; 256 struct viewport vp = *gui_list->parent[screen];
255#ifdef HAVE_LCD_BITMAP 257#ifdef HAVE_LCD_BITMAP
256 if (list_display_title(gui_list, gui_list->parent[screen])) 258 if (list_display_title(gui_list, screen))
257 vp.height -= list_title_height(gui_list,gui_list->parent[screen]); 259 vp.height -= font_get(gui_list->parent[screen]->font)->height;
258#endif 260#endif
259 nb_lines = viewport_get_nb_lines(&vp); 261 nb_lines = viewport_get_nb_lines(&vp);
260 262
@@ -273,7 +275,10 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
273 if (global_settings.scroll_paginated) 275 if (global_settings.scroll_paginated)
274 { 276 {
275 if (gui_list->start_item[screen] > gui_list->selected_item) 277 if (gui_list->start_item[screen] > gui_list->selected_item)
276 gui_list->start_item[screen] = (gui_list->selected_item/nb_lines)*nb_lines; 278 {
279 gui_list->start_item[screen] = (gui_list->selected_item/nb_lines)
280 *nb_lines;
281 }
277 if (gui_list->nb_items <= nb_lines) 282 if (gui_list->nb_items <= nb_lines)
278 gui_list->start_item[screen] = 0; 283 gui_list->start_item[screen] = 0;
279 } 284 }
@@ -293,7 +298,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
293 if (bottom < 0) 298 if (bottom < 0)
294 bottom = 0; 299 bottom = 0;
295 gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] + 300 gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] +
296 2*gui_list->selected_size); 301 2*gui_list->selected_size);
297 } 302 }
298 else if (global_settings.scroll_paginated) 303 else if (global_settings.scroll_paginated)
299 { 304 {
@@ -351,8 +356,8 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list,
351 { 356 {
352 struct viewport vp = *gui_list->parent[i]; 357 struct viewport vp = *gui_list->parent[i];
353#ifdef HAVE_LCD_BITMAP 358#ifdef HAVE_LCD_BITMAP
354 if (list_display_title(gui_list, gui_list->parent[i])) 359 if (list_display_title(gui_list, i))
355 vp.height -= list_title_height(gui_list,gui_list->parent[i]); 360 vp.height -= font_get(gui_list->parent[i]->font)->height;
356#endif 361#endif
357 nb_lines = viewport_get_nb_lines(&vp); 362 nb_lines = viewport_get_nb_lines(&vp);
358 if (offset > 0) 363 if (offset > 0)
@@ -578,11 +583,11 @@ void gui_synclist_speak_item(struct gui_synclist * lists)
578extern intptr_t get_action_data(void); 583extern intptr_t get_action_data(void);
579#if defined(HAVE_TOUCHSCREEN) 584#if defined(HAVE_TOUCHSCREEN)
580/* this needs to be fixed if we ever get more than 1 touchscreen on a target */ 585/* this needs to be fixed if we ever get more than 1 touchscreen on a target */
581unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct viewport *parent); 586unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list);
582#endif 587#endif
583 588
584bool gui_synclist_do_button(struct gui_synclist * lists, 589bool gui_synclist_do_button(struct gui_synclist * lists,
585 unsigned *actionptr, enum list_wrap wrap) 590 int *actionptr, enum list_wrap wrap)
586{ 591{
587 int action = *actionptr; 592 int action = *actionptr;
588#ifdef HAVE_LCD_BITMAP 593#ifdef HAVE_LCD_BITMAP
@@ -621,7 +626,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
621 626
622#if defined(HAVE_TOUCHSCREEN) 627#if defined(HAVE_TOUCHSCREEN)
623 if (action == ACTION_TOUCHSCREEN) 628 if (action == ACTION_TOUCHSCREEN)
624 action = *actionptr = gui_synclist_do_touchscreen(lists, &parent[SCREEN_MAIN]); 629 action = *actionptr = gui_synclist_do_touchscreen(lists);
625#endif 630#endif
626 631
627 switch (wrap) 632 switch (wrap)
@@ -791,8 +796,8 @@ bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
791{ 796{
792 struct viewport vp = *lists->parent[screen]; 797 struct viewport vp = *lists->parent[screen];
793#ifdef HAVE_LCD_BITMAP 798#ifdef HAVE_LCD_BITMAP
794 if (list_display_title(lists, lists->parent[screen])) 799 if (list_display_title(lists, screen))
795 vp.height -= list_title_height(lists, lists->parent[screen]); 800 vp.height -= font_get(lists->parent[screen]->font)->height;
796#endif 801#endif
797 return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp)); 802 return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp));
798} 803}
@@ -888,7 +893,6 @@ bool simplelist_show_list(struct simplelist_info *info)
888 893
889 while(1) 894 while(1)
890 { 895 {
891 gui_syncstatusbar_draw(&statusbars, true);
892 list_do_action(CONTEXT_STD, info->timeout, 896 list_do_action(CONTEXT_STD, info->timeout,
893 &lists, &action, wrap); 897 &lists, &action, wrap);
894 898
@@ -900,14 +904,16 @@ bool simplelist_show_list(struct simplelist_info *info)
900 { 904 {
901 bool stdok = action==ACTION_STD_OK; 905 bool stdok = action==ACTION_STD_OK;
902 action = info->action_callback(action, &lists); 906 action = info->action_callback(action, &lists);
903 if (stdok && action == ACTION_STD_CANCEL) /* callback asked us to exit */ 907 if (stdok && action == ACTION_STD_CANCEL)
904 { 908 {
909 /* callback asked us to exit */
905 info->selection = gui_synclist_get_sel_pos(&lists); 910 info->selection = gui_synclist_get_sel_pos(&lists);
906 break; 911 break;
907 } 912 }
908 913
909 if (info->get_name == NULL) 914 if (info->get_name == NULL)
910 gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); 915 gui_synclist_set_nb_items(&lists,
916 simplelist_line_count*info->selection_size);
911 } 917 }
912 if (action == ACTION_STD_CANCEL) 918 if (action == ACTION_STD_CANCEL)
913 { 919 {
@@ -918,7 +924,10 @@ bool simplelist_show_list(struct simplelist_info *info)
918 (old_line_count != simplelist_line_count)) 924 (old_line_count != simplelist_line_count))
919 { 925 {
920 if (info->get_name == NULL) 926 if (info->get_name == NULL)
921 gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); 927 {
928 gui_synclist_set_nb_items(&lists,
929 simplelist_line_count*info->selection_size);
930 }
922 gui_synclist_draw(&lists); 931 gui_synclist_draw(&lists);
923 old_line_count = simplelist_line_count; 932 old_line_count = simplelist_line_count;
924 } 933 }