summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 8a65d3f298..3627f12221 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -55,29 +55,37 @@ static int offset_step = 16; /* pixels per screen scroll step */
55/* should lines scroll out of the screen */ 55/* should lines scroll out of the screen */
56static bool offset_out_of_view = false; 56static bool offset_out_of_view = false;
57#endif 57#endif
58static int force_list_reinit = false;
59 58
60static void gui_list_select_at_offset(struct gui_synclist * gui_list, 59static void gui_list_select_at_offset(struct gui_synclist * gui_list,
61 int offset); 60 int offset);
62void list_draw(struct screen *display, struct gui_synclist *list); 61void list_draw(struct screen *display, struct gui_synclist *list);
63 62
64#ifdef HAVE_LCD_BITMAP 63#ifdef HAVE_LCD_BITMAP
65static struct viewport parent[NB_SCREENS]; 64static void list_init_viewports(struct gui_synclist *list)
66void list_init_viewports(struct gui_synclist *list)
67{ 65{
66 struct viewport* vp;
68 int i; 67 int i;
69 struct viewport *vp; 68 bool parent_used = (*list->parent != NULL);
70 FOR_NB_SCREENS(i) 69 if (!parent_used)
71 { 70 {
72 vp = &parent[i]; 71 vp = viewport_get_current_vp();
73 if (!list || list->parent[i] == vp) 72 FOR_NB_SCREENS(i)
74 viewport_set_defaults(vp, i); 73 list->parent[i] = &vp[i];
75 } 74 }
76#ifdef HAVE_BUTTONBAR 75#ifdef HAVE_BUTTONBAR
77 if (list && (list->parent[0] == &parent[0]) && global_settings.buttonbar) 76 if (list && !parent_used[SCREEN_MAIN] && global_settings.buttonbar)
78 list->parent[0]->height -= BUTTONBAR_HEIGHT; 77 list->parent[0]->height -= BUTTONBAR_HEIGHT;
79#endif 78#endif
80 force_list_reinit = false; 79}
80#else
81#define list_init_viewports(a)
82#endif
83
84#ifdef HAVE_LCD_BITMAP
85bool list_display_title(struct gui_synclist *list, enum screen_type screen)
86{
87 return list->title != NULL &&
88 viewport_get_nb_lines(list->parent[screen])>2;
81} 89}
82#else 90#else
83static struct viewport parent[NB_SCREENS] = 91static struct viewport parent[NB_SCREENS] =
@@ -90,20 +98,6 @@ static struct viewport parent[NB_SCREENS] =
90 .height = LCD_HEIGHT 98 .height = LCD_HEIGHT
91 }, 99 },
92}; 100};
93void list_init_viewports(struct gui_synclist *list)
94{
95 (void)list;
96 force_list_reinit = false;
97}
98#endif
99
100#ifdef HAVE_LCD_BITMAP
101bool list_display_title(struct gui_synclist *list, enum screen_type screen)
102{
103 return list->title != NULL &&
104 viewport_get_nb_lines(list->parent[screen])>2;
105}
106#else
107#define list_display_title(l, i) false 101#define list_display_title(l, i) false
108#endif 102#endif
109 103
@@ -141,9 +135,12 @@ void gui_synclist_init(struct gui_synclist * gui_list,
141 if (list_parent) 135 if (list_parent)
142 gui_list->parent[i] = &list_parent[i]; 136 gui_list->parent[i] = &list_parent[i];
143 else 137 else
144 { 138 gui_list->parent[i] =
145 gui_list->parent[i] = &parent[i]; 139#ifdef HAVE_LCD_BITMAP
146 } 140 NULL;
141#else
142 &parent[i];
143#endif
147 } 144 }
148 list_init_viewports(gui_list); 145 list_init_viewports(gui_list);
149 gui_list->limit_scroll = false; 146 gui_list->limit_scroll = false;
@@ -162,7 +159,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
162 gui_list->title_color = -1; 159 gui_list->title_color = -1;
163 gui_list->callback_get_item_color = NULL; 160 gui_list->callback_get_item_color = NULL;
164#endif 161#endif
165 force_list_reinit = true;
166} 162}
167 163
168/* this toggles the selection bar or cursor */ 164/* this toggles the selection bar or cursor */
@@ -218,7 +214,7 @@ void gui_synclist_draw(struct gui_synclist *gui_list)
218#ifdef HAVE_BUTTONBAR 214#ifdef HAVE_BUTTONBAR
219 static bool last_buttonbar = false; 215 static bool last_buttonbar = false;
220#endif 216#endif
221 if (force_list_reinit || 217 if (
222#ifdef HAVE_BUTTONBAR 218#ifdef HAVE_BUTTONBAR
223 last_buttonbar != screens[SCREEN_MAIN].has_buttonbar || 219 last_buttonbar != screens[SCREEN_MAIN].has_buttonbar ||
224#endif 220#endif
@@ -436,7 +432,6 @@ void gui_synclist_set_title(struct gui_synclist * gui_list,
436 } else { 432 } else {
437 gui_list->title_width = 0; 433 gui_list->title_width = 0;
438 } 434 }
439 force_list_reinit = true;
440} 435}
441 436
442 437