Daniel Stenberg | 1c0c861 | 2002-05-17 12:22:24 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 Robert E. Hak |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * 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 Stenberg | 1c0c861 | 2002-05-17 12:22:24 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Kevin Ferrare | db8415c | 2005-10-30 22:34:51 +0000 | [diff] [blame] | 21 | /* |
| 22 | 2005 Kevin Ferrare : |
| 23 | - Multi screen support |
| 24 | - Rewrote/removed a lot of code now useless with the new gui API |
| 25 | */ |
Björn Stenberg | 2ac0572 | 2002-05-26 17:03:17 +0000 | [diff] [blame] | 26 | #include <stdbool.h> |
Linus Nielsen Feltzing | 10b92c4 | 2004-03-12 10:20:33 +0000 | [diff] [blame] | 27 | #include <stdlib.h> |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 28 | #include "config.h" |
Linus Nielsen Feltzing | 34d08b2 | 2007-11-16 08:18:08 +0000 | [diff] [blame] | 29 | #include "system.h" |
Justin Heiner | b5025a8 | 2002-08-31 04:58:35 +0000 | [diff] [blame] | 30 | |
Jonathan Gordon | 466e5d9 | 2010-02-26 03:45:41 +0000 | [diff] [blame] | 31 | #include "appevents.h" |
Daniel Stenberg | 1c0c861 | 2002-05-17 12:22:24 +0000 | [diff] [blame] | 32 | #include "lcd.h" |
Daniel Stenberg | 93b231c | 2002-09-12 13:33:59 +0000 | [diff] [blame] | 33 | #include "font.h" |
Nils Wallménius | 47608e0 | 2009-08-19 22:15:45 +0000 | [diff] [blame] | 34 | #include "file.h" |
Daniel Stenberg | 1c0c861 | 2002-05-17 12:22:24 +0000 | [diff] [blame] | 35 | #include "menu.h" |
Björn Stenberg | b21a3bd | 2002-05-21 14:25:45 +0000 | [diff] [blame] | 36 | #include "button.h" |
| 37 | #include "kernel.h" |
| 38 | #include "debug.h" |
Justin Heiner | 2630245 | 2002-08-23 02:17:00 +0000 | [diff] [blame] | 39 | #include "usb.h" |
Björn Stenberg | cd22573 | 2002-08-11 09:17:47 +0000 | [diff] [blame] | 40 | #include "panic.h" |
Markus Braun | 5e4c1d2 | 2002-08-20 19:37:00 +0000 | [diff] [blame] | 41 | #include "settings.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 42 | #include "settings_list.h" |
Jonathan Gordon | a5278fa | 2007-07-11 05:41:23 +0000 | [diff] [blame] | 43 | #include "option_select.h" |
Björn Stenberg | a4c3b03 | 2002-09-24 18:04:15 +0000 | [diff] [blame] | 44 | #include "screens.h" |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 45 | #include "talk.h" |
Jörg Hohensohn | b1403ee | 2004-07-23 23:01:20 +0000 | [diff] [blame] | 46 | #include "lang.h" |
Linus Nielsen Feltzing | ade5d7b | 2004-07-26 16:06:59 +0000 | [diff] [blame] | 47 | #include "misc.h" |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 48 | #include "action.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 49 | #include "menus/exported_menus.h" |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 50 | #include "string.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 51 | #include "root_menu.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 52 | #include "audio.h" |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 53 | #include "viewport.h" |
Jonathan Gordon | ea664e0 | 2008-05-03 12:30:40 +0000 | [diff] [blame] | 54 | #include "quickscreen.h" |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 55 | #include "shortcuts.h" |
Markus Braun | 000c2db | 2002-08-30 13:49:32 +0000 | [diff] [blame] | 56 | |
Daniel Stenberg | bf603f9 | 2002-06-14 08:47:44 +0000 | [diff] [blame] | 57 | #ifdef HAVE_LCD_BITMAP |
| 58 | #include "icons.h" |
| 59 | #endif |
Markus Braun | 000c2db | 2002-08-30 13:49:32 +0000 | [diff] [blame] | 60 | |
Kevin Ferrare | db8415c | 2005-10-30 22:34:51 +0000 | [diff] [blame] | 61 | /* gui api */ |
| 62 | #include "list.h" |
Kevin Ferrare | db8415c | 2005-10-30 22:34:51 +0000 | [diff] [blame] | 63 | #include "buttonbar.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 64 | |
Jonathan Gordon | 77a458a | 2007-05-08 11:55:43 +0000 | [diff] [blame] | 65 | #define MAX_MENUS 8 |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 66 | /* used to allow for dynamic menus */ |
| 67 | #define MAX_MENU_SUBITEMS 64 |
Jonathan Gordon | 208136d | 2007-03-17 14:10:51 +0000 | [diff] [blame] | 68 | static struct menu_item_ex *current_submenus_menu; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 69 | static int current_subitems[MAX_MENU_SUBITEMS]; |
| 70 | static int current_subitems_count = 0; |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 71 | static int talk_menu_item(int selected_item, void *data); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 72 | |
Nils Wallménius | f31e123 | 2007-05-19 19:54:11 +0000 | [diff] [blame] | 73 | static void get_menu_callback(const struct menu_item_ex *m, |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 74 | menu_callback_type *menu_callback) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 75 | { |
Jonathan Gordon | 2801a87 | 2007-02-19 02:14:51 +0000 | [diff] [blame] | 76 | if (m->flags&(MENU_HAS_DESC|MENU_DYNAMIC_DESC)) |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 77 | *menu_callback= m->callback_and_desc->menu_callback; |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 78 | else |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 79 | *menu_callback = m->menu_callback; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static int get_menu_selection(int selected_item, const struct menu_item_ex *menu) |
| 83 | { |
| 84 | int type = (menu->flags&MENU_TYPE_MASK); |
Johannes Schwarz | 73d2574 | 2009-06-26 17:59:33 +0000 | [diff] [blame] | 85 | if ((type == MT_MENU || type == MT_RETURN_ID) |
| 86 | && (selected_item<current_subitems_count)) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 87 | return current_subitems[selected_item]; |
| 88 | return selected_item; |
| 89 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 90 | static 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énius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 98 | static const char* get_menu_item_name(int selected_item, |
| 99 | void * data, |
| 100 | char *buffer, |
| 101 | size_t buffer_len) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 102 | { |
| 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 Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 106 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 107 | /* only MT_MENU or MT_RETURN_ID is allowed in here */ |
| 108 | if (type == MT_RETURN_ID) |
| 109 | { |
Jonathan Gordon | 2816dc9 | 2007-02-27 09:06:30 +0000 | [diff] [blame] | 110 | if (menu->flags&MENU_DYNAMIC_DESC) |
| 111 | return menu->menu_get_name_and_icon->list_get_name(selected_item, |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 112 | menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len); |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 113 | return menu->strings[selected_item]; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 114 | } |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 115 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 116 | menu = menu->submenus[selected_item]; |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 117 | |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 118 | if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT)) |
Jonathan Gordon | 1ba493e | 2007-02-26 08:17:07 +0000 | [diff] [blame] | 119 | return menu->menu_get_name_and_icon->list_get_name(selected_item, |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 120 | menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 121 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 122 | type = (menu->flags&MENU_TYPE_MASK); |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 123 | if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT)) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 124 | { |
| 125 | const struct settings_list *v |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 126 | = find_setting(menu->variable, NULL); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 127 | 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 Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 133 | #ifdef HAVE_LCD_BITMAP |
Andrew Mahone | 1bc67c8 | 2009-07-11 00:22:26 +0000 | [diff] [blame] | 134 | static enum themable_icons menu_get_icon(int selected_item, void * data) |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 135 | { |
| 136 | const struct menu_item_ex *menu = (const struct menu_item_ex *)data; |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 137 | int menu_icon = Icon_NOICON; |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 138 | selected_item = get_menu_selection(selected_item, menu); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 139 | |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 140 | if ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID) |
| 141 | { |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 142 | return Icon_Menu_functioncall; |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 143 | } |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 144 | menu = menu->submenus[selected_item]; |
Jonathan Gordon | 1ba493e | 2007-02-26 08:17:07 +0000 | [diff] [blame] | 145 | if (menu->flags&MENU_HAS_DESC) |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 146 | menu_icon = menu->callback_and_desc->icon_id; |
Jonathan Gordon | 1ba493e | 2007-02-26 08:17:07 +0000 | [diff] [blame] | 147 | else if (menu->flags&MENU_DYNAMIC_DESC) |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 148 | menu_icon = menu->menu_get_name_and_icon->icon_id; |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 149 | |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 150 | if (menu_icon == Icon_NOICON) |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 151 | { |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 152 | 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 Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 166 | } |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 167 | return menu_icon; |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 168 | } |
| 169 | #endif |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 170 | |
| 171 | static void init_menu_lists(const struct menu_item_ex *menu, |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 172 | struct gui_synclist *lists, int selected, bool callback, |
| 173 | struct viewport parent[NB_SCREENS]) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 174 | { |
Jonathan Gordon | b5e587c | 2007-03-18 06:31:33 +0000 | [diff] [blame] | 175 | int i, count = MENU_GET_COUNT(menu->flags); |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 176 | int type = (menu->flags&MENU_TYPE_MASK); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 177 | menu_callback_type menu_callback = NULL; |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 178 | int icon; |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 179 | char * title; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 180 | current_subitems_count = 0; |
Jonathan Gordon | 3452146 | 2007-03-07 13:00:46 +0000 | [diff] [blame] | 181 | |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 182 | if (type == MT_RETURN_ID) |
| 183 | get_menu_callback(menu, &menu_callback); |
| 184 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 185 | for (i=0; i<count; i++) |
| 186 | { |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 187 | if (type != MT_RETURN_ID) |
| 188 | get_menu_callback(menu->submenus[i],&menu_callback); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 189 | if (menu_callback) |
| 190 | { |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 191 | if (menu_callback(ACTION_REQUEST_MENUITEM, |
| 192 | type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i]) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 193 | != ACTION_EXIT_MENUITEM) |
| 194 | { |
| 195 | current_subitems[current_subitems_count] = i; |
| 196 | current_subitems_count++; |
| 197 | } |
| 198 | } |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 199 | else |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 200 | { |
| 201 | current_subitems[current_subitems_count] = i; |
| 202 | current_subitems_count++; |
| 203 | } |
| 204 | } |
Jonathan Gordon | 3d39c4d | 2007-03-17 14:16:11 +0000 | [diff] [blame] | 205 | current_submenus_menu = (struct menu_item_ex *)menu; |
Jonathan Gordon | 208136d | 2007-03-17 14:10:51 +0000 | [diff] [blame] | 206 | |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 207 | gui_synclist_init(lists,get_menu_item_name,(void*)menu,false,1, parent); |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 208 | #ifdef HAVE_LCD_BITMAP |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 209 | |
| 210 | if (menu->flags&MENU_HAS_DESC) |
| 211 | { |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 212 | icon = menu->callback_and_desc->icon_id; |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 213 | 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 Gordon | e425371 | 2009-12-16 08:36:46 +0000 | [diff] [blame] | 232 | gui_synclist_set_icon_callback(lists, global_settings.show_icons?menu_get_icon:NULL); |
Jonathan Gordon | f8e08f0 | 2007-02-15 23:27:57 +0000 | [diff] [blame] | 233 | #else |
| 234 | (void)icon; |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 235 | (void)title; |
Steve Bavin | 361a60c | 2007-03-01 18:25:13 +0000 | [diff] [blame] | 236 | gui_synclist_set_icon_callback(lists, NULL); |
Jonathan Gordon | 5599d68 | 2007-02-14 06:58:30 +0000 | [diff] [blame] | 237 | #endif |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 238 | if(global_settings.talk_menu) |
| 239 | gui_synclist_set_voice_callback(lists, talk_menu_item); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 240 | gui_synclist_set_nb_items(lists,current_subitems_count); |
| 241 | gui_synclist_limit_scroll(lists,true); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 242 | gui_synclist_select_item(lists, find_menu_selection(selected)); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 243 | |
Jonathan Gordon | fe3cfcc | 2007-02-08 10:28:42 +0000 | [diff] [blame] | 244 | get_menu_callback(menu,&menu_callback); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 245 | if (callback && menu_callback) |
| 246 | menu_callback(ACTION_ENTER_MENUITEM,menu); |
| 247 | } |
| 248 | |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 249 | static int talk_menu_item(int selected_item, void *data) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 250 | { |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 251 | const struct menu_item_ex *menu = (const struct menu_item_ex *)data; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 252 | int id = -1; |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 253 | int type; |
Linus Nielsen Feltzing | 298c2bb | 2007-03-05 00:32:33 +0000 | [diff] [blame] | 254 | unsigned char *str; |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 255 | int sel = get_menu_selection(selected_item, menu); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 256 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 257 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) |
| 258 | { |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 259 | type = menu->submenus[sel]->flags&MENU_TYPE_MASK; |
| 260 | if ((type == MT_SETTING) || (type == MT_SETTING_W_TEXT)) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 261 | talk_setting(menu->submenus[sel]->variable); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 262 | else |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 263 | { |
Linus Nielsen Feltzing | 298c2bb | 2007-03-05 00:32:33 +0000 | [diff] [blame] | 264 | if (menu->submenus[sel]->flags&(MENU_DYNAMIC_DESC)) |
| 265 | { |
Stéphane Doyon | 5acf091 | 2007-10-09 03:48:56 +0000 | [diff] [blame] | 266 | 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 Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 278 | menu_get_name_and_icon-> |
| 279 | list_get_name_data, buffer, sizeof(buffer)); |
Stéphane Doyon | 5acf091 | 2007-10-09 03:48:56 +0000 | [diff] [blame] | 280 | id = P2ID(str); |
| 281 | } |
Linus Nielsen Feltzing | 298c2bb | 2007-03-05 00:32:33 +0000 | [diff] [blame] | 282 | } |
| 283 | else |
| 284 | id = P2ID(menu->submenus[sel]->callback_and_desc->desc); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 285 | if (id != -1) |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 286 | talk_id(id,false); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 287 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 288 | } |
Jonathan Gordon | 94b9804 | 2007-08-20 09:11:05 +0000 | [diff] [blame] | 289 | 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 Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 300 | return 0; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 301 | } |
Steve Bavin | cd88e2a | 2008-03-25 15:24:03 +0000 | [diff] [blame] | 302 | |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 303 | void do_setting_screen(const struct settings_list *setting, const char * title, |
| 304 | struct viewport parent[NB_SCREENS]) |
Jonathan Gordon | 2801a87 | 2007-02-19 02:14:51 +0000 | [diff] [blame] | 305 | { |
Jonathan Gordon | 91ccc01 | 2007-11-05 13:15:35 +0000 | [diff] [blame] | 306 | char padded_title[MAX_PATH]; |
Linus Nielsen Feltzing | 34d08b2 | 2007-11-16 08:18:08 +0000 | [diff] [blame] | 307 | /* 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 Gordon | 91ccc01 | 2007-11-05 13:15:35 +0000 | [diff] [blame] | 310 | 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 Feltzing | 34d08b2 | 2007-11-16 08:18:08 +0000 | [diff] [blame] | 318 | while (i < MAX_PATH-1) |
Jonathan Gordon | 91ccc01 | 2007-11-05 13:15:35 +0000 | [diff] [blame] | 319 | { |
Linus Nielsen Feltzing | 34d08b2 | 2007-11-16 08:18:08 +0000 | [diff] [blame] | 320 | int padlen = MIN(len, MAX_PATH-1-i); |
Teruaki Kawashima | f495488 | 2009-07-29 13:35:00 +0000 | [diff] [blame] | 321 | memcpy(&padded_title[i], title, padlen); |
Linus Nielsen Feltzing | 34d08b2 | 2007-11-16 08:18:08 +0000 | [diff] [blame] | 322 | i += padlen; |
Jonathan Gordon | 91ccc01 | 2007-11-05 13:15:35 +0000 | [diff] [blame] | 323 | if (i<MAX_PATH-1) |
| 324 | padded_title[i++] = ' '; |
| 325 | } |
| 326 | padded_title[i] = '\0'; |
| 327 | title = padded_title; |
| 328 | } |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 329 | |
Jonathan Gordon | fe9dca3 | 2008-04-23 11:07:40 +0000 | [diff] [blame] | 330 | option_screen((struct settings_list *)setting, parent, |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 331 | setting->flags&F_TEMPVAR, (char*)title); |
| 332 | } |
| 333 | |
| 334 | |
| 335 | void 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 Gordon | 2801a87 | 2007-02-19 02:14:51 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Jonathan Gordon | 62decc4 | 2007-11-04 12:10:41 +0000 | [diff] [blame] | 349 | /* display a menu */ |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 350 | int do_menu(const struct menu_item_ex *start_menu, int *start_selected, |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 351 | struct viewport parent[NB_SCREENS], bool hide_theme) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 352 | { |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 353 | int selected = start_selected? *start_selected : 0; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 354 | int action; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 355 | struct gui_synclist lists; |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 356 | const struct menu_item_ex *temp, *menu = start_menu; |
Björn Stenberg | 0942e2a | 2011-10-15 19:35:02 +0000 | [diff] [blame] | 357 | int ret = 0; |
Jonathan Gordon | 411f3e2 | 2007-07-11 02:22:03 +0000 | [diff] [blame] | 358 | bool redraw_lists; |
Thomas Martitz | ca4439f | 2010-08-07 21:30:22 +0000 | [diff] [blame] | 359 | int old_audio_status = audio_status(); |
Thomas Martitz | fab7264 | 2012-01-26 23:48:54 +0100 | [diff] [blame] | 360 | |
| 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 Gordon | 9ca03c7 | 2009-12-17 07:47:08 +0000 | [diff] [blame] | 367 | FOR_NB_SCREENS(i) |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 368 | viewportmanager_theme_enable(i, !hide_theme, NULL); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 369 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 370 | const struct menu_item_ex *menu_stack[MAX_MENUS]; |
| 371 | int menu_stack_selected_item[MAX_MENUS]; |
| 372 | int stack_top = 0; |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 373 | bool in_stringlist, done = false; |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 374 | struct viewport *vps = NULL; |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 375 | #ifdef HAVE_BUTTONBAR |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 376 | 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 Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 381 | menu_callback_type menu_callback = NULL; |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 382 | |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 383 | /* if hide_theme is true, assume parent has been fixed before passed into |
Thomas Martitz | 85d8e95 | 2009-06-13 18:24:07 +0000 | [diff] [blame] | 384 | * this function, e.g. with viewport_set_defaults(parent, screen) */ |
Teruaki Kawashima | b1f5e56 | 2010-07-11 14:04:34 +0000 | [diff] [blame] | 385 | init_menu_lists(menu, &lists, selected, true, parent); |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 386 | vps = *(lists.parent); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 387 | in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID); |
Jonathan Gordon | d563cb2 | 2007-02-21 12:22:07 +0000 | [diff] [blame] | 388 | /* load the callback, and only reload it if menu changes */ |
| 389 | get_menu_callback(menu, &menu_callback); |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 390 | |
Teruaki Kawashima | b1f5e56 | 2010-07-11 14:04:34 +0000 | [diff] [blame] | 391 | gui_synclist_draw(&lists); |
| 392 | gui_synclist_speak_item(&lists); |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 393 | #ifdef HAVE_BUTTONBAR |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 394 | if (!hide_theme) |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 395 | { |
| 396 | gui_buttonbar_set(&buttonbar, "<<<", "", ""); |
| 397 | gui_buttonbar_draw(&buttonbar); |
| 398 | } |
| 399 | #endif |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 400 | while (!done) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 401 | { |
Thomas Martitz | 2113e22 | 2010-08-07 21:37:55 +0000 | [diff] [blame] | 402 | int new_audio_status; |
Jonathan Gordon | 411f3e2 | 2007-07-11 02:22:03 +0000 | [diff] [blame] | 403 | redraw_lists = false; |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 404 | if (!hide_theme) |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 405 | { |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 406 | #ifdef HAVE_BUTTONBAR |
| 407 | gui_buttonbar_draw(&buttonbar); |
| 408 | #endif |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 409 | } |
Jonathan Gordon | eb2ea7f | 2012-01-12 22:28:36 +1100 | [diff] [blame] | 410 | #if CONFIG_CODEC == SWCODEC |
| 411 | keyclick_set_callback(gui_synclist_keyclick_callback, &lists); |
| 412 | #endif |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 413 | action = get_action(CONTEXT_MAINMENU, |
| 414 | list_do_action_timeout(&lists, HZ)); |
Thomas Martitz | ca4439f | 2010-08-07 21:30:22 +0000 | [diff] [blame] | 415 | |
| 416 | /* query audio status to see if it changed */ |
Thomas Martitz | 2113e22 | 2010-08-07 21:37:55 +0000 | [diff] [blame] | 417 | new_audio_status = audio_status(); |
| 418 | if (old_audio_status != new_audio_status) |
Thomas Martitz | ca4439f | 2010-08-07 21:30:22 +0000 | [diff] [blame] | 419 | { /* force a redraw if anything changed the audio status |
| 420 | * from outside */ |
| 421 | redraw_lists = true; |
Thomas Martitz | 2113e22 | 2010-08-07 21:37:55 +0000 | [diff] [blame] | 422 | old_audio_status = new_audio_status; |
Thomas Martitz | ca4439f | 2010-08-07 21:30:22 +0000 | [diff] [blame] | 423 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 424 | /* HZ so the status bar redraws corectly */ |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 425 | |
Jonathan Gordon | fdd4050 | 2008-10-30 07:07:45 +0000 | [diff] [blame] | 426 | if (menu_callback) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 427 | { |
Jonathan Gordon | 9144be5 | 2007-02-27 09:16:47 +0000 | [diff] [blame] | 428 | int old_action = action; |
Jonathan Gordon | d563cb2 | 2007-02-21 12:22:07 +0000 | [diff] [blame] | 429 | action = menu_callback(action, menu); |
Jonathan Gordon | 9144be5 | 2007-02-27 09:16:47 +0000 | [diff] [blame] | 430 | 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 Gordon | 411f3e2 | 2007-07-11 02:22:03 +0000 | [diff] [blame] | 436 | else if (action == ACTION_REDRAW) |
| 437 | { |
| 438 | action = old_action; |
| 439 | redraw_lists = true; |
| 440 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 441 | } |
| 442 | |
Jonathan Gordon | cf1cef5 | 2007-09-17 10:08:50 +0000 | [diff] [blame] | 443 | if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) |
Jonathan Gordon | b9f22af | 2007-07-11 01:23:57 +0000 | [diff] [blame] | 444 | continue; |
Jonathan Gordon | 286d48f | 2008-04-23 10:33:46 +0000 | [diff] [blame] | 445 | #ifdef HAVE_QUICKSCREEN |
| 446 | else if (action == ACTION_STD_QUICKSCREEN) |
| 447 | { |
| 448 | quick_screen_quick(action); |
| 449 | redraw_lists = true; |
| 450 | } |
| 451 | #endif |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 452 | #ifdef HAVE_RECORDING |
Jonathan Gordon | 286d48f | 2008-04-23 10:33:46 +0000 | [diff] [blame] | 453 | else if (action == ACTION_STD_REC) |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 454 | { |
| 455 | ret = GO_TO_RECSCREEN; |
| 456 | done = true; |
| 457 | } |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 458 | #endif |
Jonathan Gordon | 286d48f | 2008-04-23 10:33:46 +0000 | [diff] [blame] | 459 | else if (action == ACTION_TREE_WPS) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 460 | { |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 461 | ret = GO_TO_PREVIOUS_MUSIC; |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 462 | done = true; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 463 | } |
Jonathan Gordon | a053e58 | 2007-04-08 01:33:01 +0000 | [diff] [blame] | 464 | else if (action == ACTION_TREE_STOP) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 465 | { |
Magnus Holmgren | 1d9f693 | 2007-08-05 15:21:47 +0000 | [diff] [blame] | 466 | redraw_lists = list_stop_handler(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 467 | } |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 468 | else if (action == ACTION_STD_CONTEXT) |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 469 | { |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 470 | 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 Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 478 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu); |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 479 | temp = menu->submenus[selected]; |
| 480 | type = (temp->flags&MENU_TYPE_MASK); |
Rafaël Carré | 65bb8e4 | 2012-05-06 23:10:19 -0400 | [diff] [blame] | 481 | if (type == MT_SETTING_W_TEXT || type == MT_SETTING) |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 482 | { |
| 483 | #ifdef HAVE_QUICKSCREEN |
| 484 | MENUITEM_STRINGLIST(quickscreen_able_option, |
| 485 | ID2P(LANG_ONPLAY_MENU_TITLE), NULL, |
| 486 | ID2P(LANG_RESET_SETTING), |
Thomas Martitz | e454a39 | 2009-08-29 14:42:03 +0000 | [diff] [blame] | 487 | ID2P(LANG_TOP_QS_ITEM), |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 488 | ID2P(LANG_LEFT_QS_ITEM), |
| 489 | ID2P(LANG_BOTTOM_QS_ITEM), |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 490 | ID2P(LANG_RIGHT_QS_ITEM), |
| 491 | ID2P(LANG_ADD_TO_FAVES)); |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 492 | #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 = ¬quickscreen_able_option; |
| 506 | switch (do_menu(menu, &menu_selection, NULL, false)) |
| 507 | { |
| 508 | case GO_TO_PREVIOUS: |
| 509 | break; |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 510 | case 0: /* reset setting */ |
| 511 | reset_setting(setting, setting->setting); |
Igor B. Poretsky | 9e186e3 | 2017-02-28 23:46:39 +0300 | [diff] [blame] | 512 | settings_save(); |
| 513 | settings_apply(false); |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 514 | break; |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 515 | #ifdef HAVE_QUICKSCREEN |
Thomas Martitz | e454a39 | 2009-08-29 14:42:03 +0000 | [diff] [blame] | 516 | 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 Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 520 | set_as_qs_item(setting, QUICKSCREEN_LEFT); |
| 521 | break; |
Thomas Martitz | e454a39 | 2009-08-29 14:42:03 +0000 | [diff] [blame] | 522 | case 3: /* set as bottom QS item */ |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 523 | set_as_qs_item(setting, QUICKSCREEN_BOTTOM); |
| 524 | break; |
Thomas Martitz | e454a39 | 2009-08-29 14:42:03 +0000 | [diff] [blame] | 525 | case 4: /* set as right QS item */ |
Jonathan Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 526 | set_as_qs_item(setting, QUICKSCREEN_RIGHT); |
| 527 | break; |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 528 | 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 Gordon | a22749b | 2008-11-05 09:30:20 +0000 | [diff] [blame] | 532 | #endif |
| 533 | } /* swicth(do_menu()) */ |
| 534 | redraw_lists = true; |
| 535 | } |
| 536 | } /* else if (!in_stringlist) */ |
| 537 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 538 | else if (action == ACTION_STD_MENU) |
| 539 | { |
| 540 | if (menu != &root_menu_) |
| 541 | ret = GO_TO_ROOT; |
Jonathan Gordon | a74eefe | 2007-03-06 13:35:15 +0000 | [diff] [blame] | 542 | else |
| 543 | ret = GO_TO_PREVIOUS; |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 544 | done = true; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 545 | } |
| 546 | else if (action == ACTION_STD_CANCEL) |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 547 | { |
Jonathan Gordon | 5cab5da | 2007-11-07 10:06:21 +0000 | [diff] [blame] | 548 | bool exiting_menu = false; |
Linus Nielsen Feltzing | 6ffd804 | 2007-02-16 10:40:59 +0000 | [diff] [blame] | 549 | in_stringlist = false; |
Peter D'Hoye | c5383c1 | 2008-10-13 22:08:01 +0000 | [diff] [blame] | 550 | /* might be leaving list, so stop scrolling */ |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 551 | gui_synclist_scroll_stop(&lists); |
Jonathan Gordon | d563cb2 | 2007-02-21 12:22:07 +0000 | [diff] [blame] | 552 | if (menu_callback) |
| 553 | menu_callback(ACTION_EXIT_MENUITEM, menu); |
Peter D'Hoye | c5383c1 | 2008-10-13 22:08:01 +0000 | [diff] [blame] | 554 | |
Jonathan Gordon | 3a7760c | 2007-04-30 13:41:33 +0000 | [diff] [blame] | 555 | if (menu->flags&MENU_EXITAFTERTHISMENU) |
| 556 | done = true; |
Jonathan Gordon | 5cab5da | 2007-11-07 10:06:21 +0000 | [diff] [blame] | 557 | else if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) |
| 558 | exiting_menu = true; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 559 | if (stack_top > 0) |
| 560 | { |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 561 | stack_top--; |
| 562 | menu = menu_stack[stack_top]; |
Jonathan Gordon | 5cab5da | 2007-11-07 10:06:21 +0000 | [diff] [blame] | 563 | if (!exiting_menu && (menu->flags&MENU_EXITAFTERTHISMENU)) |
Jonathan Gordon | 3a7760c | 2007-04-30 13:41:33 +0000 | [diff] [blame] | 564 | done = true; |
Jonathan Gordon | 75e2f19 | 2007-08-04 09:47:17 +0000 | [diff] [blame] | 565 | else |
| 566 | init_menu_lists(menu, &lists, |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 567 | menu_stack_selected_item[stack_top], false, vps); |
Teruaki Kawashima | b1f5e56 | 2010-07-11 14:04:34 +0000 | [diff] [blame] | 568 | redraw_lists = true; |
Jonathan Gordon | d563cb2 | 2007-02-21 12:22:07 +0000 | [diff] [blame] | 569 | /* new menu, so reload the callback */ |
Jonathan Gordon | 1ea4f0d | 2007-02-16 00:55:52 +0000 | [diff] [blame] | 570 | get_menu_callback(menu, &menu_callback); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 571 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 572 | else if (menu != &root_menu_) |
| 573 | { |
| 574 | ret = GO_TO_PREVIOUS; |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 575 | done = true; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 576 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 577 | } |
| 578 | else if (action == ACTION_STD_OK) |
| 579 | { |
| 580 | int type; |
Peter D'Hoye | c5383c1 | 2008-10-13 22:08:01 +0000 | [diff] [blame] | 581 | /* entering an item that may not be a list, so stop scrolling */ |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 582 | gui_synclist_scroll_stop(&lists); |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 583 | #ifdef HAVE_BUTTONBAR |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 584 | if (!hide_theme) |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 585 | { |
| 586 | gui_buttonbar_unset(&buttonbar); |
| 587 | gui_buttonbar_draw(&buttonbar); |
| 588 | } |
Jonathan Gordon | 1ba493e | 2007-02-26 08:17:07 +0000 | [diff] [blame] | 589 | #endif |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 590 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); |
| 591 | temp = menu->submenus[selected]; |
Jonathan Gordon | 50dc0ca | 2007-07-11 04:17:43 +0000 | [diff] [blame] | 592 | redraw_lists = true; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 593 | if (in_stringlist) |
| 594 | type = (menu->flags&MENU_TYPE_MASK); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 595 | else |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 596 | { |
Jonathan Gordon | 1f5ee2a | 2007-03-25 14:31:56 +0000 | [diff] [blame] | 597 | 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 Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 605 | } |
| 606 | switch (type) |
| 607 | { |
| 608 | case MT_MENU: |
| 609 | if (stack_top < MAX_MENUS) |
| 610 | { |
| 611 | menu_stack[stack_top] = menu; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 612 | menu_stack_selected_item[stack_top] = selected; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 613 | stack_top++; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 614 | menu = temp; |
Teruaki Kawashima | b1f5e56 | 2010-07-11 14:04:34 +0000 | [diff] [blame] | 615 | init_menu_lists(menu, &lists, 0, true, vps); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 616 | } |
| 617 | break; |
| 618 | case MT_FUNCTION_CALL: |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 619 | { |
| 620 | int return_value; |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 621 | if (temp->flags&MENU_FUNC_USEPARAM) |
| 622 | return_value = temp->function->function_w_param( |
| 623 | temp->function->param); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 624 | else |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 625 | return_value = temp->function->function(); |
Michael Chicoine | c0c7c8e | 2010-10-30 09:38:26 +0000 | [diff] [blame] | 626 | if (!(menu->flags&MENU_EXITAFTERTHISMENU) || |
| 627 | (temp->flags&MENU_EXITAFTERTHISMENU)) |
| 628 | { |
| 629 | init_menu_lists(menu, &lists, selected, true, vps); |
| 630 | } |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 631 | if (temp->flags&MENU_FUNC_CHECK_RETVAL) |
| 632 | { |
Jonathan Gordon | fdd4050 | 2008-10-30 07:07:45 +0000 | [diff] [blame] | 633 | if (return_value != 0) |
Jonathan Gordon | b5e587c | 2007-03-18 06:31:33 +0000 | [diff] [blame] | 634 | { |
| 635 | done = true; |
| 636 | ret = return_value; |
| 637 | } |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 638 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 639 | break; |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 640 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 641 | case MT_SETTING: |
Jonathan Gordon | 9709086 | 2007-03-03 14:23:03 +0000 | [diff] [blame] | 642 | case MT_SETTING_W_TEXT: |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 643 | { |
Steve Bavin | f14999e | 2009-03-10 07:27:13 +0000 | [diff] [blame] | 644 | do_setting_from_menu(temp, vps); |
Jonathan Gordon | 466e5d9 | 2010-02-26 03:45:41 +0000 | [diff] [blame] | 645 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 646 | break; |
| 647 | } |
| 648 | case MT_RETURN_ID: |
| 649 | if (in_stringlist) |
| 650 | { |
Jonathan Gordon | b5e587c | 2007-03-18 06:31:33 +0000 | [diff] [blame] | 651 | done = true; |
| 652 | ret = selected; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 653 | } |
| 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 Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 660 | init_menu_lists(menu,&lists,0,false, vps); |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 661 | in_stringlist = true; |
| 662 | } |
| 663 | break; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 664 | case MT_RETURN_VALUE: |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 665 | ret = temp->value; |
| 666 | done = true; |
| 667 | break; |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 668 | } |
Jonathan Gordon | 3a7760c | 2007-04-30 13:41:33 +0000 | [diff] [blame] | 669 | if (type != MT_MENU) |
| 670 | { |
| 671 | if (menu_callback) |
| 672 | menu_callback(ACTION_EXIT_MENUITEM,temp); |
| 673 | } |
Jonathan Gordon | 208136d | 2007-03-17 14:10:51 +0000 | [diff] [blame] | 674 | if (current_submenus_menu != menu) |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 675 | init_menu_lists(menu,&lists,selected,true,vps); |
Jonathan Gordon | d563cb2 | 2007-02-21 12:22:07 +0000 | [diff] [blame] | 676 | /* callback was changed, so reload the menu's callback */ |
| 677 | get_menu_callback(menu, &menu_callback); |
Jonathan Gordon | 3a7760c | 2007-04-30 13:41:33 +0000 | [diff] [blame] | 678 | if ((menu->flags&MENU_EXITAFTERTHISMENU) && |
| 679 | !(temp->flags&MENU_EXITAFTERTHISMENU)) |
| 680 | { |
| 681 | done = true; |
| 682 | break; |
| 683 | } |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 684 | #ifdef HAVE_BUTTONBAR |
Thomas Martitz | 5629d55 | 2010-01-26 20:14:42 +0000 | [diff] [blame] | 685 | if (!hide_theme) |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 686 | { |
| 687 | gui_buttonbar_set(&buttonbar, "<<<", "", ""); |
| 688 | gui_buttonbar_draw(&buttonbar); |
| 689 | } |
Jonathan Gordon | 1ba493e | 2007-02-26 08:17:07 +0000 | [diff] [blame] | 690 | #endif |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 691 | } |
Thomas Martitz | 49f1ec8 | 2010-10-31 15:32:57 +0000 | [diff] [blame] | 692 | else |
Peter D'Hoye | d2b3055 | 2007-03-30 21:54:48 +0000 | [diff] [blame] | 693 | { |
Thomas Martitz | 98591a2 | 2014-01-16 00:25:40 +0100 | [diff] [blame] | 694 | if (action == SYS_USB_CONNECTED) |
| 695 | gui_synclist_scroll_stop(&lists); |
| 696 | |
Thomas Martitz | 49f1ec8 | 2010-10-31 15:32:57 +0000 | [diff] [blame] | 697 | 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'Hoye | d2b3055 | 2007-03-30 21:54:48 +0000 | [diff] [blame] | 709 | } |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 710 | |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 711 | if (redraw_lists && !done) |
| 712 | { |
Jonathan Gordon | fdd4050 | 2008-10-30 07:07:45 +0000 | [diff] [blame] | 713 | if (menu_callback) |
| 714 | menu_callback(ACTION_REDRAW, menu); |
Jonathan Gordon | 411f3e2 | 2007-07-11 02:22:03 +0000 | [diff] [blame] | 715 | gui_synclist_draw(&lists); |
Stéphane Doyon | 4e09b78 | 2007-10-21 00:23:23 +0000 | [diff] [blame] | 716 | gui_synclist_speak_item(&lists); |
| 717 | } |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 718 | } |
Thomas Martitz | 98591a2 | 2014-01-16 00:25:40 +0100 | [diff] [blame] | 719 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 720 | if (start_selected) |
Jonathan Gordon | fd9d140 | 2007-05-20 14:24:02 +0000 | [diff] [blame] | 721 | { |
| 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 Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 727 | init_menu_lists(menu,&lists,menu_stack_selected_item[0],true, vps); |
Jonathan Gordon | fd9d140 | 2007-05-20 14:24:02 +0000 | [diff] [blame] | 728 | } |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 729 | *start_selected = get_menu_selection( |
| 730 | gui_synclist_get_sel_pos(&lists), menu); |
Jonathan Gordon | fd9d140 | 2007-05-20 14:24:02 +0000 | [diff] [blame] | 731 | } |
Thomas Martitz | fab7264 | 2012-01-26 23:48:54 +0100 | [diff] [blame] | 732 | |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 733 | FOR_NB_SCREENS(i) |
| 734 | viewportmanager_theme_undo(i, false); |
Thomas Martitz | fab7264 | 2012-01-26 23:48:54 +0100 | [diff] [blame] | 735 | #ifdef HAVE_TOUCHSCREEN |
| 736 | touchscreen_set_mode(tsm); |
| 737 | #endif |
| 738 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 739 | return ret; |
| 740 | } |