blob: 48f6fa3d0b282f48d56764ee85e556fe89971879 [file] [log] [blame]
Daniel Stenberg1c0c8612002-05-17 12:22:24 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Robert E. Hak
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Daniel Stenberg1c0c8612002-05-17 12:22:24 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Kevin Ferraredb8415c2005-10-30 22:34:51 +000021/*
222005 Kevin Ferrare :
23 - Multi screen support
24 - Rewrote/removed a lot of code now useless with the new gui API
25*/
Björn Stenberg2ac05722002-05-26 17:03:17 +000026#include <stdbool.h>
Linus Nielsen Feltzing10b92c42004-03-12 10:20:33 +000027#include <stdlib.h>
Jonathan Gordon91cb68a2007-03-01 11:14:46 +000028#include "config.h"
Linus Nielsen Feltzing34d08b22007-11-16 08:18:08 +000029#include "system.h"
Justin Heinerb5025a82002-08-31 04:58:35 +000030
Jonathan Gordon466e5d92010-02-26 03:45:41 +000031#include "appevents.h"
Daniel Stenberg1c0c8612002-05-17 12:22:24 +000032#include "lcd.h"
Daniel Stenberg93b231c2002-09-12 13:33:59 +000033#include "font.h"
Nils Wallménius47608e02009-08-19 22:15:45 +000034#include "file.h"
Daniel Stenberg1c0c8612002-05-17 12:22:24 +000035#include "menu.h"
Björn Stenbergb21a3bd2002-05-21 14:25:45 +000036#include "button.h"
37#include "kernel.h"
38#include "debug.h"
Justin Heiner26302452002-08-23 02:17:00 +000039#include "usb.h"
Björn Stenbergcd225732002-08-11 09:17:47 +000040#include "panic.h"
Markus Braun5e4c1d22002-08-20 19:37:00 +000041#include "settings.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000042#include "settings_list.h"
Jonathan Gordona5278fa2007-07-11 05:41:23 +000043#include "option_select.h"
Björn Stenberga4c3b032002-09-24 18:04:15 +000044#include "screens.h"
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +000045#include "talk.h"
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +000046#include "lang.h"
Linus Nielsen Feltzingade5d7b2004-07-26 16:06:59 +000047#include "misc.h"
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +000048#include "action.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000049#include "menus/exported_menus.h"
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000050#include "string.h"
Jonathan Gordon91cb68a2007-03-01 11:14:46 +000051#include "root_menu.h"
Jonathan Gordon91cb68a2007-03-01 11:14:46 +000052#include "audio.h"
Jonathan Gordon5ca15392008-03-26 03:35:24 +000053#include "viewport.h"
Jonathan Gordonea664e02008-05-03 12:30:40 +000054#include "quickscreen.h"
Jonathan Gordon101693f2011-11-15 13:22:02 +000055#include "shortcuts.h"
Markus Braun000c2db2002-08-30 13:49:32 +000056
Daniel Stenbergbf603f92002-06-14 08:47:44 +000057#ifdef HAVE_LCD_BITMAP
58#include "icons.h"
59#endif
Markus Braun000c2db2002-08-30 13:49:32 +000060
Kevin Ferraredb8415c2005-10-30 22:34:51 +000061/* gui api */
62#include "list.h"
Kevin Ferraredb8415c2005-10-30 22:34:51 +000063#include "buttonbar.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000064
Jonathan Gordon77a458a2007-05-08 11:55:43 +000065#define MAX_MENUS 8
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000066/* used to allow for dynamic menus */
67#define MAX_MENU_SUBITEMS 64
Jonathan Gordon208136d2007-03-17 14:10:51 +000068static struct menu_item_ex *current_submenus_menu;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000069static int current_subitems[MAX_MENU_SUBITEMS];
70static int current_subitems_count = 0;
Stéphane Doyon4e09b782007-10-21 00:23:23 +000071static int talk_menu_item(int selected_item, void *data);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000072
Nils Wallméniusf31e1232007-05-19 19:54:11 +000073static void get_menu_callback(const struct menu_item_ex *m,
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000074 menu_callback_type *menu_callback)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000075{
Jonathan Gordon2801a872007-02-19 02:14:51 +000076 if (m->flags&(MENU_HAS_DESC|MENU_DYNAMIC_DESC))
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000077 *menu_callback= m->callback_and_desc->menu_callback;
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +000078 else
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000079 *menu_callback = m->menu_callback;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000080}
81
82static int get_menu_selection(int selected_item, const struct menu_item_ex *menu)
83{
84 int type = (menu->flags&MENU_TYPE_MASK);
Johannes Schwarz73d25742009-06-26 17:59:33 +000085 if ((type == MT_MENU || type == MT_RETURN_ID)
86 && (selected_item<current_subitems_count))
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000087 return current_subitems[selected_item];
88 return selected_item;
89}
Jonathan Gordon91cb68a2007-03-01 11:14:46 +000090static int find_menu_selection(int selected)
91{
92 int i;
93 for (i=0; i< current_subitems_count; i++)
94 if (current_subitems[i] == selected)
95 return i;
96 return 0;
97}
Nils Wallménius3200d042009-08-20 16:47:44 +000098static const char* get_menu_item_name(int selected_item,
99 void * data,
100 char *buffer,
101 size_t buffer_len)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000102{
103 const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
104 int type = (menu->flags&MENU_TYPE_MASK);
105 selected_item = get_menu_selection(selected_item, menu);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000106
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000107 /* only MT_MENU or MT_RETURN_ID is allowed in here */
108 if (type == MT_RETURN_ID)
109 {
Jonathan Gordon2816dc92007-02-27 09:06:30 +0000110 if (menu->flags&MENU_DYNAMIC_DESC)
111 return menu->menu_get_name_and_icon->list_get_name(selected_item,
William Wilgus10e5e562019-09-20 03:07:29 -0500112 menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len);
Nils Wallménius3200d042009-08-20 16:47:44 +0000113 return menu->strings[selected_item];
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000114 }
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000115
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000116 menu = menu->submenus[selected_item];
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000117
Jonathan Gordon97090862007-03-03 14:23:03 +0000118 if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT))
Jonathan Gordon1ba493e2007-02-26 08:17:07 +0000119 return menu->menu_get_name_and_icon->list_get_name(selected_item,
William Wilgus10e5e562019-09-20 03:07:29 -0500120 menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000121
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000122 type = (menu->flags&MENU_TYPE_MASK);
Jonathan Gordon97090862007-03-03 14:23:03 +0000123 if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000124 {
125 const struct settings_list *v
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000126 = find_setting(menu->variable, NULL);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000127 if (v)
128 return str(v->lang_id);
129 else return "Not Done yet!";
130 }
131 return P2STR(menu->callback_and_desc->desc);
132}
Jonathan Gordon5599d682007-02-14 06:58:30 +0000133#ifdef HAVE_LCD_BITMAP
Andrew Mahone1bc67c82009-07-11 00:22:26 +0000134static enum themable_icons menu_get_icon(int selected_item, void * data)
Jonathan Gordon5599d682007-02-14 06:58:30 +0000135{
136 const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
Jonathan Gordon97090862007-03-03 14:23:03 +0000137 int menu_icon = Icon_NOICON;
Jonathan Gordon5599d682007-02-14 06:58:30 +0000138 selected_item = get_menu_selection(selected_item, menu);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000139
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000140 if ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID)
141 {
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000142 return Icon_Menu_functioncall;
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000143 }
Jonathan Gordon5599d682007-02-14 06:58:30 +0000144 menu = menu->submenus[selected_item];
Jonathan Gordon1ba493e2007-02-26 08:17:07 +0000145 if (menu->flags&MENU_HAS_DESC)
Jonathan Gordon02a87172007-03-03 13:52:14 +0000146 menu_icon = menu->callback_and_desc->icon_id;
Jonathan Gordon1ba493e2007-02-26 08:17:07 +0000147 else if (menu->flags&MENU_DYNAMIC_DESC)
Jonathan Gordon02a87172007-03-03 13:52:14 +0000148 menu_icon = menu->menu_get_name_and_icon->icon_id;
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000149
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000150 if (menu_icon == Icon_NOICON)
Jonathan Gordon5599d682007-02-14 06:58:30 +0000151 {
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000152 switch (menu->flags&MENU_TYPE_MASK)
153 {
154 case MT_SETTING:
155 case MT_SETTING_W_TEXT:
156 menu_icon = Icon_Menu_setting;
157 break;
158 case MT_MENU:
159 menu_icon = Icon_Submenu;
160 break;
161 case MT_FUNCTION_CALL:
162 case MT_RETURN_VALUE:
163 menu_icon = Icon_Menu_functioncall;
164 break;
165 }
Jonathan Gordon5599d682007-02-14 06:58:30 +0000166 }
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000167 return menu_icon;
Jonathan Gordon5599d682007-02-14 06:58:30 +0000168}
169#endif
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000170
171static void init_menu_lists(const struct menu_item_ex *menu,
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000172 struct gui_synclist *lists, int selected, bool callback,
173 struct viewport parent[NB_SCREENS])
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000174{
Jonathan Gordonb5e587c2007-03-18 06:31:33 +0000175 int i, count = MENU_GET_COUNT(menu->flags);
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000176 int type = (menu->flags&MENU_TYPE_MASK);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000177 menu_callback_type menu_callback = NULL;
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000178 int icon;
William Wilgus10e5e562019-09-20 03:07:29 -0500179 char * title;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000180 current_subitems_count = 0;
Jonathan Gordon34521462007-03-07 13:00:46 +0000181
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000182 if (type == MT_RETURN_ID)
183 get_menu_callback(menu, &menu_callback);
184
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000185 for (i=0; i<count; i++)
186 {
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000187 if (type != MT_RETURN_ID)
188 get_menu_callback(menu->submenus[i],&menu_callback);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000189 if (menu_callback)
190 {
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000191 if (menu_callback(ACTION_REQUEST_MENUITEM,
192 type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i])
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000193 != ACTION_EXIT_MENUITEM)
194 {
195 current_subitems[current_subitems_count] = i;
196 current_subitems_count++;
197 }
198 }
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000199 else
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000200 {
201 current_subitems[current_subitems_count] = i;
202 current_subitems_count++;
203 }
204 }
Jonathan Gordon3d39c4d2007-03-17 14:16:11 +0000205 current_submenus_menu = (struct menu_item_ex *)menu;
Jonathan Gordon208136d2007-03-17 14:10:51 +0000206
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000207 gui_synclist_init(lists,get_menu_item_name,(void*)menu,false,1, parent);
Jonathan Gordon5599d682007-02-14 06:58:30 +0000208#ifdef HAVE_LCD_BITMAP
William Wilgus10e5e562019-09-20 03:07:29 -0500209
210 if (menu->flags&MENU_HAS_DESC)
211 {
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000212 icon = menu->callback_and_desc->icon_id;
William Wilgus10e5e562019-09-20 03:07:29 -0500213 title = P2STR(menu->callback_and_desc->desc);
214 }
215 else if (menu->flags&MENU_DYNAMIC_DESC)
216 {
217 char buffer[80];
218 icon = menu->menu_get_name_and_icon->icon_id;
219 title = menu->menu_get_name_and_icon->
220 list_get_name(-1, menu->menu_get_name_and_icon->
221 list_get_name_data, buffer, sizeof(buffer));
222 }
223 else
224 {
225 icon = Icon_NOICON;
226 title = "";
227 }
228
229 if (icon == Icon_NOICON)
230 icon = Icon_Submenu_Entered;
231 gui_synclist_set_title(lists, title, icon);
Jonathan Gordone4253712009-12-16 08:36:46 +0000232 gui_synclist_set_icon_callback(lists, global_settings.show_icons?menu_get_icon:NULL);
Jonathan Gordonf8e08f02007-02-15 23:27:57 +0000233#else
234 (void)icon;
William Wilgus10e5e562019-09-20 03:07:29 -0500235 (void)title;
Steve Bavin361a60c2007-03-01 18:25:13 +0000236 gui_synclist_set_icon_callback(lists, NULL);
Jonathan Gordon5599d682007-02-14 06:58:30 +0000237#endif
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000238 if(global_settings.talk_menu)
239 gui_synclist_set_voice_callback(lists, talk_menu_item);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000240 gui_synclist_set_nb_items(lists,current_subitems_count);
241 gui_synclist_limit_scroll(lists,true);
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000242 gui_synclist_select_item(lists, find_menu_selection(selected));
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000243
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000244 get_menu_callback(menu,&menu_callback);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000245 if (callback && menu_callback)
246 menu_callback(ACTION_ENTER_MENUITEM,menu);
247}
248
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000249static int talk_menu_item(int selected_item, void *data)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000250{
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000251 const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000252 int id = -1;
Jonathan Gordon97090862007-03-03 14:23:03 +0000253 int type;
Linus Nielsen Feltzing298c2bb2007-03-05 00:32:33 +0000254 unsigned char *str;
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000255 int sel = get_menu_selection(selected_item, menu);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000256
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000257 if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)
258 {
Jonathan Gordon97090862007-03-03 14:23:03 +0000259 type = menu->submenus[sel]->flags&MENU_TYPE_MASK;
260 if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT))
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000261 talk_setting(menu->submenus[sel]->variable);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000262 else
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000263 {
Linus Nielsen Feltzing298c2bb2007-03-05 00:32:33 +0000264 if (menu->submenus[sel]->flags&(MENU_DYNAMIC_DESC))
265 {
Stéphane Doyon5acf0912007-10-09 03:48:56 +0000266 int (*list_speak_item)(int selected_item, void * data)
267 = menu->submenus[sel]->menu_get_name_and_icon->
268 list_speak_item;
269 if(list_speak_item)
270 list_speak_item(sel, menu->submenus[sel]->
271 menu_get_name_and_icon->
272 list_get_name_data);
273 else
274 {
275 char buffer[80];
276 str = menu->submenus[sel]->menu_get_name_and_icon->
277 list_get_name(sel, menu->submenus[sel]->
William Wilgus10e5e562019-09-20 03:07:29 -0500278 menu_get_name_and_icon->
279 list_get_name_data, buffer, sizeof(buffer));
Stéphane Doyon5acf0912007-10-09 03:48:56 +0000280 id = P2ID(str);
281 }
Linus Nielsen Feltzing298c2bb2007-03-05 00:32:33 +0000282 }
283 else
284 id = P2ID(menu->submenus[sel]->callback_and_desc->desc);
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000285 if (id != -1)
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000286 talk_id(id,false);
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000287 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000288 }
Jonathan Gordon94b98042007-08-20 09:11:05 +0000289 else if(((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID))
290 {
291 if ((menu->flags&MENU_DYNAMIC_DESC) == 0)
292 {
293 unsigned char *s = (unsigned char *)menu->strings[sel];
294 /* string list, try to talk it if ID2P was used */
295 id = P2ID(s);
296 if (id != -1)
297 talk_id(id,false);
298 }
299 }
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000300 return 0;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000301}
Steve Bavincd88e2a2008-03-25 15:24:03 +0000302
Jonathan Gordon101693f2011-11-15 13:22:02 +0000303void do_setting_screen(const struct settings_list *setting, const char * title,
304 struct viewport parent[NB_SCREENS])
Jonathan Gordon2801a872007-02-19 02:14:51 +0000305{
Jonathan Gordon91ccc012007-11-05 13:15:35 +0000306 char padded_title[MAX_PATH];
Linus Nielsen Feltzing34d08b22007-11-16 08:18:08 +0000307 /* Pad the title string by repeating it. This is needed
308 so the scroll settings title can actually be used to
309 test the setting */
Jonathan Gordon91ccc012007-11-05 13:15:35 +0000310 if (setting->flags&F_PADTITLE)
311 {
312 int i = 0, len;
313 if (setting->lang_id == -1)
314 title = (char*)setting->cfg_vals;
315 else
316 title = P2STR((unsigned char*)title);
317 len = strlen(title);
Linus Nielsen Feltzing34d08b22007-11-16 08:18:08 +0000318 while (i < MAX_PATH-1)
Jonathan Gordon91ccc012007-11-05 13:15:35 +0000319 {
Linus Nielsen Feltzing34d08b22007-11-16 08:18:08 +0000320 int padlen = MIN(len, MAX_PATH-1-i);
Teruaki Kawashimaf4954882009-07-29 13:35:00 +0000321 memcpy(&padded_title[i], title, padlen);
Linus Nielsen Feltzing34d08b22007-11-16 08:18:08 +0000322 i += padlen;
Jonathan Gordon91ccc012007-11-05 13:15:35 +0000323 if (i<MAX_PATH-1)
324 padded_title[i++] = ' ';
325 }
326 padded_title[i] = '\0';
327 title = padded_title;
328 }
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000329
Jonathan Gordonfe9dca32008-04-23 11:07:40 +0000330 option_screen((struct settings_list *)setting, parent,
Jonathan Gordon101693f2011-11-15 13:22:02 +0000331 setting->flags&F_TEMPVAR, (char*)title);
332}
333
334
335void do_setting_from_menu(const struct menu_item_ex *temp,
336 struct viewport parent[NB_SCREENS])
337{
338 char *title;
339 int setting_id;
340 const struct settings_list *setting =
341 find_setting(temp->variable, &setting_id);
342 if (temp && ((temp->flags&MENU_TYPE_MASK) == MT_SETTING_W_TEXT))
343 title = temp->callback_and_desc->desc;
344 else
345 title = ID2P(setting->lang_id);
346 do_setting_screen(setting, title, parent);
Jonathan Gordon2801a872007-02-19 02:14:51 +0000347}
348
Jonathan Gordon62decc42007-11-04 12:10:41 +0000349/* display a menu */
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000350int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
Thomas Martitz5629d552010-01-26 20:14:42 +0000351 struct viewport parent[NB_SCREENS], bool hide_theme)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000352{
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000353 int selected = start_selected? *start_selected : 0;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000354 int action;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000355 struct gui_synclist lists;
Thomas Martitz89a4cf22011-01-29 01:01:12 +0000356 const struct menu_item_ex *temp, *menu = start_menu;
Björn Stenberg0942e2a2011-10-15 19:35:02 +0000357 int ret = 0;
Jonathan Gordon411f3e22007-07-11 02:22:03 +0000358 bool redraw_lists;
Thomas Martitzca4439f2010-08-07 21:30:22 +0000359 int old_audio_status = audio_status();
Thomas Martitzfab72642012-01-26 23:48:54 +0100360
361#ifdef HAVE_TOUCHSCREEN
362 /* plugins possibly have grid mode active. force global settings in lists */
363 enum touchscreen_mode tsm = touchscreen_get_mode();
364 touchscreen_set_mode(global_settings.touch_mode);
365#endif
366
Jonathan Gordon9ca03c72009-12-17 07:47:08 +0000367 FOR_NB_SCREENS(i)
Thomas Martitz5629d552010-01-26 20:14:42 +0000368 viewportmanager_theme_enable(i, !hide_theme, NULL);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000369
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000370 const struct menu_item_ex *menu_stack[MAX_MENUS];
371 int menu_stack_selected_item[MAX_MENUS];
372 int stack_top = 0;
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000373 bool in_stringlist, done = false;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000374 struct viewport *vps = NULL;
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000375#ifdef HAVE_BUTTONBAR
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000376 struct gui_buttonbar buttonbar;
377 gui_buttonbar_init(&buttonbar);
378 gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
379 gui_buttonbar_set(&buttonbar, "<<<", "", "");
380#endif
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000381 menu_callback_type menu_callback = NULL;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000382
Thomas Martitz5629d552010-01-26 20:14:42 +0000383 /* if hide_theme is true, assume parent has been fixed before passed into
Thomas Martitz85d8e952009-06-13 18:24:07 +0000384 * this function, e.g. with viewport_set_defaults(parent, screen) */
Teruaki Kawashimab1f5e562010-07-11 14:04:34 +0000385 init_menu_lists(menu, &lists, selected, true, parent);
Jonathan Gordone385ee12008-12-31 05:59:26 +0000386 vps = *(lists.parent);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000387 in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID);
Jonathan Gordond563cb22007-02-21 12:22:07 +0000388 /* load the callback, and only reload it if menu changes */
389 get_menu_callback(menu, &menu_callback);
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000390
Teruaki Kawashimab1f5e562010-07-11 14:04:34 +0000391 gui_synclist_draw(&lists);
392 gui_synclist_speak_item(&lists);
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000393#ifdef HAVE_BUTTONBAR
Thomas Martitz5629d552010-01-26 20:14:42 +0000394 if (!hide_theme)
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000395 {
396 gui_buttonbar_set(&buttonbar, "<<<", "", "");
397 gui_buttonbar_draw(&buttonbar);
398 }
399#endif
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000400 while (!done)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000401 {
Thomas Martitz2113e222010-08-07 21:37:55 +0000402 int new_audio_status;
Jonathan Gordon411f3e22007-07-11 02:22:03 +0000403 redraw_lists = false;
Thomas Martitz5629d552010-01-26 20:14:42 +0000404 if (!hide_theme)
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000405 {
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000406#ifdef HAVE_BUTTONBAR
407 gui_buttonbar_draw(&buttonbar);
408#endif
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000409 }
Jonathan Gordoneb2ea7f2012-01-12 22:28:36 +1100410#if CONFIG_CODEC == SWCODEC
411 keyclick_set_callback(gui_synclist_keyclick_callback, &lists);
412#endif
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000413 action = get_action(CONTEXT_MAINMENU,
414 list_do_action_timeout(&lists, HZ));
Thomas Martitzca4439f2010-08-07 21:30:22 +0000415
416 /* query audio status to see if it changed */
Thomas Martitz2113e222010-08-07 21:37:55 +0000417 new_audio_status = audio_status();
418 if (old_audio_status != new_audio_status)
Thomas Martitzca4439f2010-08-07 21:30:22 +0000419 { /* force a redraw if anything changed the audio status
420 * from outside */
421 redraw_lists = true;
Thomas Martitz2113e222010-08-07 21:37:55 +0000422 old_audio_status = new_audio_status;
Thomas Martitzca4439f2010-08-07 21:30:22 +0000423 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000424 /* HZ so the status bar redraws corectly */
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000425
Jonathan Gordonfdd40502008-10-30 07:07:45 +0000426 if (menu_callback)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000427 {
Jonathan Gordon9144be52007-02-27 09:16:47 +0000428 int old_action = action;
Jonathan Gordond563cb22007-02-21 12:22:07 +0000429 action = menu_callback(action, menu);
Jonathan Gordon9144be52007-02-27 09:16:47 +0000430 if (action == ACTION_EXIT_AFTER_THIS_MENUITEM)
431 {
432 action = old_action;
433 ret = MENU_SELECTED_EXIT; /* will exit after returning
434 from selection */
435 }
Jonathan Gordon411f3e22007-07-11 02:22:03 +0000436 else if (action == ACTION_REDRAW)
437 {
438 action = old_action;
439 redraw_lists = true;
440 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000441 }
442
Jonathan Gordoncf1cef52007-09-17 10:08:50 +0000443 if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
Jonathan Gordonb9f22af2007-07-11 01:23:57 +0000444 continue;
Jonathan Gordon286d48f2008-04-23 10:33:46 +0000445#ifdef HAVE_QUICKSCREEN
446 else if (action == ACTION_STD_QUICKSCREEN)
447 {
448 quick_screen_quick(action);
449 redraw_lists = true;
450 }
451#endif
Jonathan Gordon73336e92007-08-02 12:13:20 +0000452#ifdef HAVE_RECORDING
Jonathan Gordon286d48f2008-04-23 10:33:46 +0000453 else if (action == ACTION_STD_REC)
Jonathan Gordon73336e92007-08-02 12:13:20 +0000454 {
455 ret = GO_TO_RECSCREEN;
456 done = true;
457 }
Jonathan Gordon73336e92007-08-02 12:13:20 +0000458#endif
Jonathan Gordon286d48f2008-04-23 10:33:46 +0000459 else if (action == ACTION_TREE_WPS)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000460 {
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000461 ret = GO_TO_PREVIOUS_MUSIC;
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000462 done = true;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000463 }
Jonathan Gordona053e582007-04-08 01:33:01 +0000464 else if (action == ACTION_TREE_STOP)
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000465 {
Magnus Holmgren1d9f6932007-08-05 15:21:47 +0000466 redraw_lists = list_stop_handler();
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000467 }
Jonathan Gordona22749b2008-11-05 09:30:20 +0000468 else if (action == ACTION_STD_CONTEXT)
Jonathan Gordonf9fb4922007-04-12 15:28:51 +0000469 {
Jonathan Gordona22749b2008-11-05 09:30:20 +0000470 if (menu == &root_menu_)
471 {
472 ret = GO_TO_ROOTITEM_CONTEXT;
473 done = true;
474 }
475 else if (!in_stringlist)
476 {
477 int type;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000478 selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu);
Jonathan Gordona22749b2008-11-05 09:30:20 +0000479 temp = menu->submenus[selected];
480 type = (temp->flags&MENU_TYPE_MASK);
Rafaël Carré65bb8e42012-05-06 23:10:19 -0400481 if (type == MT_SETTING_W_TEXT || type == MT_SETTING)
Jonathan Gordona22749b2008-11-05 09:30:20 +0000482 {
483#ifdef HAVE_QUICKSCREEN
484 MENUITEM_STRINGLIST(quickscreen_able_option,
485 ID2P(LANG_ONPLAY_MENU_TITLE), NULL,
486 ID2P(LANG_RESET_SETTING),
Thomas Martitze454a392009-08-29 14:42:03 +0000487 ID2P(LANG_TOP_QS_ITEM),
Jonathan Gordona22749b2008-11-05 09:30:20 +0000488 ID2P(LANG_LEFT_QS_ITEM),
489 ID2P(LANG_BOTTOM_QS_ITEM),
Jonathan Gordon101693f2011-11-15 13:22:02 +0000490 ID2P(LANG_RIGHT_QS_ITEM),
491 ID2P(LANG_ADD_TO_FAVES));
Jonathan Gordona22749b2008-11-05 09:30:20 +0000492#endif
493 MENUITEM_STRINGLIST(notquickscreen_able_option,
494 ID2P(LANG_ONPLAY_MENU_TITLE), NULL,
495 ID2P(LANG_RESET_SETTING));
496 const struct menu_item_ex *menu;
497 int menu_selection = 0;
498 const struct settings_list *setting =
499 find_setting(temp->variable, NULL);
500#ifdef HAVE_QUICKSCREEN
501 if (is_setting_quickscreenable(setting))
502 menu = &quickscreen_able_option;
503 else
504#endif
505 menu = &notquickscreen_able_option;
506 switch (do_menu(menu, &menu_selection, NULL, false))
507 {
508 case GO_TO_PREVIOUS:
509 break;
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000510 case 0: /* reset setting */
511 reset_setting(setting, setting->setting);
Igor B. Poretsky9e186e32017-02-28 23:46:39 +0300512 settings_save();
513 settings_apply(false);
Jonathan Gordona22749b2008-11-05 09:30:20 +0000514 break;
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000515#ifdef HAVE_QUICKSCREEN
Thomas Martitze454a392009-08-29 14:42:03 +0000516 case 1: /* set as top QS item */
517 set_as_qs_item(setting, QUICKSCREEN_TOP);
518 break;
519 case 2: /* set as left QS item */
Jonathan Gordona22749b2008-11-05 09:30:20 +0000520 set_as_qs_item(setting, QUICKSCREEN_LEFT);
521 break;
Thomas Martitze454a392009-08-29 14:42:03 +0000522 case 3: /* set as bottom QS item */
Jonathan Gordona22749b2008-11-05 09:30:20 +0000523 set_as_qs_item(setting, QUICKSCREEN_BOTTOM);
524 break;
Thomas Martitze454a392009-08-29 14:42:03 +0000525 case 4: /* set as right QS item */
Jonathan Gordona22749b2008-11-05 09:30:20 +0000526 set_as_qs_item(setting, QUICKSCREEN_RIGHT);
527 break;
Jonathan Gordon101693f2011-11-15 13:22:02 +0000528 case 5: /* Add to faves. Same limitation on which can be
529 added to the shortcuts menu as the quickscreen */
530 shortcuts_add(SHORTCUT_SETTING, (void*)setting);
531 break;
Jonathan Gordona22749b2008-11-05 09:30:20 +0000532#endif
533 } /* swicth(do_menu()) */
534 redraw_lists = true;
535 }
536 } /* else if (!in_stringlist) */
537 }
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000538 else if (action == ACTION_STD_MENU)
539 {
540 if (menu != &root_menu_)
541 ret = GO_TO_ROOT;
Jonathan Gordona74eefe2007-03-06 13:35:15 +0000542 else
543 ret = GO_TO_PREVIOUS;
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000544 done = true;
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000545 }
546 else if (action == ACTION_STD_CANCEL)
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000547 {
Jonathan Gordon5cab5da2007-11-07 10:06:21 +0000548 bool exiting_menu = false;
Linus Nielsen Feltzing6ffd8042007-02-16 10:40:59 +0000549 in_stringlist = false;
Peter D'Hoyec5383c12008-10-13 22:08:01 +0000550 /* might be leaving list, so stop scrolling */
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000551 gui_synclist_scroll_stop(&lists);
Jonathan Gordond563cb22007-02-21 12:22:07 +0000552 if (menu_callback)
553 menu_callback(ACTION_EXIT_MENUITEM, menu);
Peter D'Hoyec5383c12008-10-13 22:08:01 +0000554
Jonathan Gordon3a7760c2007-04-30 13:41:33 +0000555 if (menu->flags&MENU_EXITAFTERTHISMENU)
556 done = true;
Jonathan Gordon5cab5da2007-11-07 10:06:21 +0000557 else if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)
558 exiting_menu = true;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000559 if (stack_top > 0)
560 {
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000561 stack_top--;
562 menu = menu_stack[stack_top];
Jonathan Gordon5cab5da2007-11-07 10:06:21 +0000563 if (!exiting_menu && (menu->flags&MENU_EXITAFTERTHISMENU))
Jonathan Gordon3a7760c2007-04-30 13:41:33 +0000564 done = true;
Jonathan Gordon75e2f192007-08-04 09:47:17 +0000565 else
566 init_menu_lists(menu, &lists,
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000567 menu_stack_selected_item[stack_top], false, vps);
Teruaki Kawashimab1f5e562010-07-11 14:04:34 +0000568 redraw_lists = true;
Jonathan Gordond563cb22007-02-21 12:22:07 +0000569 /* new menu, so reload the callback */
Jonathan Gordon1ea4f0d2007-02-16 00:55:52 +0000570 get_menu_callback(menu, &menu_callback);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000571 }
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000572 else if (menu != &root_menu_)
573 {
574 ret = GO_TO_PREVIOUS;
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000575 done = true;
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000576 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000577 }
578 else if (action == ACTION_STD_OK)
579 {
580 int type;
Peter D'Hoyec5383c12008-10-13 22:08:01 +0000581 /* entering an item that may not be a list, so stop scrolling */
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000582 gui_synclist_scroll_stop(&lists);
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000583#ifdef HAVE_BUTTONBAR
Thomas Martitz5629d552010-01-26 20:14:42 +0000584 if (!hide_theme)
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000585 {
586 gui_buttonbar_unset(&buttonbar);
587 gui_buttonbar_draw(&buttonbar);
588 }
Jonathan Gordon1ba493e2007-02-26 08:17:07 +0000589#endif
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000590 selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu);
591 temp = menu->submenus[selected];
Jonathan Gordon50dc0ca2007-07-11 04:17:43 +0000592 redraw_lists = true;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000593 if (in_stringlist)
594 type = (menu->flags&MENU_TYPE_MASK);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000595 else
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000596 {
Jonathan Gordon1f5ee2a2007-03-25 14:31:56 +0000597 type = (temp->flags&MENU_TYPE_MASK);
598 get_menu_callback(temp, &menu_callback);
599 if (menu_callback)
600 {
601 action = menu_callback(ACTION_ENTER_MENUITEM,temp);
602 if (action == ACTION_EXIT_MENUITEM)
603 break;
604 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000605 }
606 switch (type)
607 {
608 case MT_MENU:
609 if (stack_top < MAX_MENUS)
610 {
611 menu_stack[stack_top] = menu;
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000612 menu_stack_selected_item[stack_top] = selected;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000613 stack_top++;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000614 menu = temp;
Teruaki Kawashimab1f5e562010-07-11 14:04:34 +0000615 init_menu_lists(menu, &lists, 0, true, vps);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000616 }
617 break;
618 case MT_FUNCTION_CALL:
Jonathan Gordondaf66942007-03-17 12:33:34 +0000619 {
620 int return_value;
Jonathan Gordondaf66942007-03-17 12:33:34 +0000621 if (temp->flags&MENU_FUNC_USEPARAM)
622 return_value = temp->function->function_w_param(
623 temp->function->param);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000624 else
Jonathan Gordondaf66942007-03-17 12:33:34 +0000625 return_value = temp->function->function();
Michael Chicoinec0c7c8e2010-10-30 09:38:26 +0000626 if (!(menu->flags&MENU_EXITAFTERTHISMENU) ||
627 (temp->flags&MENU_EXITAFTERTHISMENU))
628 {
629 init_menu_lists(menu, &lists, selected, true, vps);
630 }
Jonathan Gordondaf66942007-03-17 12:33:34 +0000631 if (temp->flags&MENU_FUNC_CHECK_RETVAL)
632 {
Jonathan Gordonfdd40502008-10-30 07:07:45 +0000633 if (return_value != 0)
Jonathan Gordonb5e587c2007-03-18 06:31:33 +0000634 {
635 done = true;
636 ret = return_value;
637 }
Jonathan Gordondaf66942007-03-17 12:33:34 +0000638 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000639 break;
Jonathan Gordondaf66942007-03-17 12:33:34 +0000640 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000641 case MT_SETTING:
Jonathan Gordon97090862007-03-03 14:23:03 +0000642 case MT_SETTING_W_TEXT:
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000643 {
Steve Bavinf14999e2009-03-10 07:27:13 +0000644 do_setting_from_menu(temp, vps);
Jonathan Gordon466e5d92010-02-26 03:45:41 +0000645 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000646 break;
647 }
648 case MT_RETURN_ID:
649 if (in_stringlist)
650 {
Jonathan Gordonb5e587c2007-03-18 06:31:33 +0000651 done = true;
652 ret = selected;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000653 }
654 else if (stack_top < MAX_MENUS)
655 {
656 menu_stack[stack_top] = menu;
657 menu_stack_selected_item[stack_top] = selected;
658 stack_top++;
659 menu = temp;
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000660 init_menu_lists(menu,&lists,0,false, vps);
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000661 in_stringlist = true;
662 }
663 break;
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000664 case MT_RETURN_VALUE:
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000665 ret = temp->value;
666 done = true;
667 break;
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000668 }
Jonathan Gordon3a7760c2007-04-30 13:41:33 +0000669 if (type != MT_MENU)
670 {
671 if (menu_callback)
672 menu_callback(ACTION_EXIT_MENUITEM,temp);
673 }
Jonathan Gordon208136d2007-03-17 14:10:51 +0000674 if (current_submenus_menu != menu)
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000675 init_menu_lists(menu,&lists,selected,true,vps);
Jonathan Gordond563cb22007-02-21 12:22:07 +0000676 /* callback was changed, so reload the menu's callback */
677 get_menu_callback(menu, &menu_callback);
Jonathan Gordon3a7760c2007-04-30 13:41:33 +0000678 if ((menu->flags&MENU_EXITAFTERTHISMENU) &&
679 !(temp->flags&MENU_EXITAFTERTHISMENU))
680 {
681 done = true;
682 break;
683 }
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000684#ifdef HAVE_BUTTONBAR
Thomas Martitz5629d552010-01-26 20:14:42 +0000685 if (!hide_theme)
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000686 {
687 gui_buttonbar_set(&buttonbar, "<<<", "", "");
688 gui_buttonbar_draw(&buttonbar);
689 }
Jonathan Gordon1ba493e2007-02-26 08:17:07 +0000690#endif
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000691 }
Thomas Martitz49f1ec82010-10-31 15:32:57 +0000692 else
Peter D'Hoyed2b30552007-03-30 21:54:48 +0000693 {
Thomas Martitz98591a22014-01-16 00:25:40 +0100694 if (action == SYS_USB_CONNECTED)
695 gui_synclist_scroll_stop(&lists);
696
Thomas Martitz49f1ec82010-10-31 15:32:57 +0000697 switch(default_event_handler(action))
698 {
699 case SYS_USB_CONNECTED:
700 ret = MENU_ATTACHED_USB;
701 done = true;
702 break;
703 case SYS_CALL_HUNG_UP:
704 case BUTTON_MULTIMEDIA_PLAYPAUSE:
705 /* remove splash from playlist_resume() */
706 redraw_lists = true;
707 break;
708 }
Peter D'Hoyed2b30552007-03-30 21:54:48 +0000709 }
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000710
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000711 if (redraw_lists && !done)
712 {
Jonathan Gordonfdd40502008-10-30 07:07:45 +0000713 if (menu_callback)
714 menu_callback(ACTION_REDRAW, menu);
Jonathan Gordon411f3e22007-07-11 02:22:03 +0000715 gui_synclist_draw(&lists);
Stéphane Doyon4e09b782007-10-21 00:23:23 +0000716 gui_synclist_speak_item(&lists);
717 }
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000718 }
Thomas Martitz98591a22014-01-16 00:25:40 +0100719
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000720 if (start_selected)
Jonathan Gordonfd9d1402007-05-20 14:24:02 +0000721 {
722 /* make sure the start_selected variable is set to
723 the selected item from the menu do_menu() was called from */
724 if (stack_top > 0)
725 {
726 menu = menu_stack[0];
Jonathan Gordon5ca15392008-03-26 03:35:24 +0000727 init_menu_lists(menu,&lists,menu_stack_selected_item[0],true, vps);
Jonathan Gordonfd9d1402007-05-20 14:24:02 +0000728 }
Jonathan Gordon43b2d092007-03-07 10:13:07 +0000729 *start_selected = get_menu_selection(
730 gui_synclist_get_sel_pos(&lists), menu);
Jonathan Gordonfd9d1402007-05-20 14:24:02 +0000731 }
Thomas Martitzfab72642012-01-26 23:48:54 +0100732
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000733 FOR_NB_SCREENS(i)
734 viewportmanager_theme_undo(i, false);
Thomas Martitzfab72642012-01-26 23:48:54 +0100735#ifdef HAVE_TOUCHSCREEN
736 touchscreen_set_mode(tsm);
737#endif
738
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000739 return ret;
740}