summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-04-23 11:07:40 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-04-23 11:07:40 +0000
commitfe9dca3d5b6156b85f1085ecc11ba8e3a1dcd2d7 (patch)
tree8e85e29dad56030c399377bcb429db6d935b544c
parent286d48f4ec99ec3f63687f623053e6dd01445863 (diff)
downloadrockbox-fe9dca3d5b6156b85f1085ecc11ba8e3a1dcd2d7.tar.gz
rockbox-fe9dca3d5b6156b85f1085ecc11ba8e3a1dcd2d7.zip
option_screen() now accepts a viewport
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17223 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/option_select.c3
-rw-r--r--apps/gui/option_select.h3
-rw-r--r--apps/menu.c7
-rw-r--r--apps/menu.h3
-rw-r--r--apps/menus/eq_menu.c2
-rw-r--r--apps/plugin.h1
-rw-r--r--apps/plugins/lib/playback_control.c12
-rw-r--r--apps/plugins/lib/playback_control.h9
-rw-r--r--apps/settings.c4
9 files changed, 30 insertions, 14 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index e26bab3b82..c6136ebf17 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -426,6 +426,7 @@ static void val_to_selection(struct settings_list *setting, int oldvalue,
426} 426}
427 427
428bool option_screen(struct settings_list *setting, 428bool option_screen(struct settings_list *setting,
429 struct viewport parent[NB_SCREENS],
429 bool use_temp_var, unsigned char* option_title) 430 bool use_temp_var, unsigned char* option_title)
430{ 431{
431 int action; 432 int action;
@@ -451,7 +452,7 @@ bool option_screen(struct settings_list *setting,
451 } 452 }
452 else return false; /* only int/bools can go here */ 453 else return false; /* only int/bools can go here */
453 gui_synclist_init(&lists, value_setting_get_name_cb, 454 gui_synclist_init(&lists, value_setting_get_name_cb,
454 (void*)setting, false, 1, NULL); 455 (void*)setting, false, 1, parent);
455 if (setting->lang_id == -1) 456 if (setting->lang_id == -1)
456 title = (char*)setting->cfg_vals; 457 title = (char*)setting->cfg_vals;
457 else 458 else
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
index fa2f3660b6..bb609346a3 100644
--- a/apps/gui/option_select.h
+++ b/apps/gui/option_select.h
@@ -19,9 +19,12 @@
19 19
20#ifndef _GUI_OPTION_SELECT_H_ 20#ifndef _GUI_OPTION_SELECT_H_
21#define _GUI_OPTION_SELECT_H_ 21#define _GUI_OPTION_SELECT_H_
22#include "config.h"
23#include "screen_access.h"
22#include "settings.h" 24#include "settings.h"
23 25
24bool option_screen(struct settings_list *setting, 26bool option_screen(struct settings_list *setting,
27 struct viewport parent[NB_SCREENS],
25 bool use_temp_var, unsigned char* option_title); 28 bool use_temp_var, unsigned char* option_title);
26 29
27struct option_select 30struct option_select
diff --git a/apps/menu.c b/apps/menu.c
index 1609aa0fb6..e29b9c4e76 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -304,7 +304,8 @@ void init_default_menu_viewports(struct viewport parent[NB_SCREENS], bool hide_b
304#endif 304#endif
305} 305}
306 306
307bool do_setting_from_menu(const struct menu_item_ex *temp) 307bool do_setting_from_menu(const struct menu_item_ex *temp,
308 struct viewport parent[NB_SCREENS])
308{ 309{
309 int setting_id, oldval; 310 int setting_id, oldval;
310 const struct settings_list *setting = find_setting( 311 const struct settings_list *setting = find_setting(
@@ -351,7 +352,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp)
351 title = padded_title; 352 title = padded_title;
352 } 353 }
353 354
354 option_screen((struct settings_list *)setting, 355 option_screen((struct settings_list *)setting, parent,
355 setting->flags&F_TEMPVAR, title); 356 setting->flags&F_TEMPVAR, title);
356 if (var_type == F_T_INT || var_type == F_T_UINT) 357 if (var_type == F_T_INT || var_type == F_T_UINT)
357 { 358 {
@@ -585,7 +586,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
585 case MT_SETTING: 586 case MT_SETTING:
586 case MT_SETTING_W_TEXT: 587 case MT_SETTING_W_TEXT:
587 { 588 {
588 if (do_setting_from_menu(temp)) 589 if (do_setting_from_menu(temp, menu_vp))
589 { 590 {
590 init_default_menu_viewports(menu_vp, hide_bars); 591 init_default_menu_viewports(menu_vp, hide_bars);
591 init_menu_lists(menu, &lists, selected, true,vps); 592 init_menu_lists(menu, &lists, selected, true,vps);
diff --git a/apps/menu.h b/apps/menu.h
index 1b4ffd5cd4..018f3f18ad 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -99,7 +99,8 @@ struct menu_item_ex {
99 99
100typedef int (*menu_callback_type)(int action, 100typedef int (*menu_callback_type)(int action,
101 const struct menu_item_ex *this_item); 101 const struct menu_item_ex *this_item);
102bool do_setting_from_menu(const struct menu_item_ex *temp); 102bool do_setting_from_menu(const struct menu_item_ex *temp,
103 struct viewport parent[NB_SCREENS]);
103 104
104/* 105/*
105 int do_menu(const struct menu_item_ex *menu, int *start_selected) 106 int do_menu(const struct menu_item_ex *menu, int *start_selected)
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 2b4e9ad8a8..1afd5b6db7 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -134,7 +134,7 @@ static int do_option(void * param)
134{ 134{
135 const struct menu_item_ex *setting = (const struct menu_item_ex*)param; 135 const struct menu_item_ex *setting = (const struct menu_item_ex*)param;
136 lowlatency_callback(ACTION_ENTER_MENUITEM, setting); 136 lowlatency_callback(ACTION_ENTER_MENUITEM, setting);
137 do_setting_from_menu(setting); 137 do_setting_from_menu(setting, NULL);
138 eq_apply(); 138 eq_apply();
139 lowlatency_callback(ACTION_EXIT_MENUITEM, setting); 139 lowlatency_callback(ACTION_EXIT_MENUITEM, setting);
140 return 0; 140 return 0;
diff --git a/apps/plugin.h b/apps/plugin.h
index 2db38eda4c..9e0386f001 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -569,6 +569,7 @@ struct plugin_api {
569 /* options */ 569 /* options */
570 const struct settings_list* (*find_setting)(const void* variable, int *id); 570 const struct settings_list* (*find_setting)(const void* variable, int *id);
571 bool (*option_screen)(struct settings_list *setting, 571 bool (*option_screen)(struct settings_list *setting,
572 struct viewport parent[NB_SCREENS],
572 bool use_temp_var, unsigned char* option_title); 573 bool use_temp_var, unsigned char* option_title);
573 bool (*set_option)(const char* string, const void* variable, 574 bool (*set_option)(const char* string, const void* variable,
574 enum optiontype type, const struct opt_items* options, 575 enum optiontype type, const struct opt_items* options,
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c
index cba4f5a0ee..af4384ef0a 100644
--- a/apps/plugins/lib/playback_control.c
+++ b/apps/plugins/lib/playback_control.c
@@ -20,6 +20,7 @@
20#include "plugin.h" 20#include "plugin.h"
21 21
22struct plugin_api* api = 0; 22struct plugin_api* api = 0;
23struct viewport *parentvp = NULL;
23 24
24bool prevtrack(void) 25bool prevtrack(void)
25{ 26{
@@ -61,14 +62,14 @@ static bool volume(void)
61{ 62{
62 const struct settings_list* vol = 63 const struct settings_list* vol =
63 api->find_setting(&api->global_settings->volume, NULL); 64 api->find_setting(&api->global_settings->volume, NULL);
64 return api->option_screen((struct settings_list*)vol, false, "Volume"); 65 return api->option_screen((struct settings_list*)vol, parentvp, false, "Volume");
65} 66}
66 67
67static bool shuffle(void) 68static bool shuffle(void)
68{ 69{
69 const struct settings_list* shuffle = 70 const struct settings_list* shuffle =
70 api->find_setting(&api->global_settings->playlist_shuffle, NULL); 71 api->find_setting(&api->global_settings->playlist_shuffle, NULL);
71 return api->option_screen((struct settings_list*)shuffle, false, "Shuffle"); 72 return api->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle");
72} 73}
73 74
74static bool repeat_mode(void) 75static bool repeat_mode(void)
@@ -77,7 +78,7 @@ static bool repeat_mode(void)
77 api->find_setting(&api->global_settings->repeat_mode, NULL); 78 api->find_setting(&api->global_settings->repeat_mode, NULL);
78 int old_repeat = api->global_settings->repeat_mode; 79 int old_repeat = api->global_settings->repeat_mode;
79 80
80 api->option_screen((struct settings_list*)repeat, false, "Repeat"); 81 api->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat");
81 82
82 if (old_repeat != api->global_settings->repeat_mode && 83 if (old_repeat != api->global_settings->repeat_mode &&
83 (api->audio_status() & AUDIO_STATUS_PLAY)) 84 (api->audio_status() & AUDIO_STATUS_PLAY))
@@ -103,14 +104,17 @@ MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON,
103 &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, 104 &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item,
104 &volume_item, &shuffle_item, &repeat_mode_item); 105 &volume_item, &shuffle_item, &repeat_mode_item);
105 106
106void playback_control_init(struct plugin_api* newapi) 107void playback_control_init(struct plugin_api* newapi,
108 struct viewport parent[NB_SCREENS])
107{ 109{
108 api = newapi; 110 api = newapi;
111 parentvp = parent;
109} 112}
110 113
111bool playback_control(struct plugin_api* newapi, 114bool playback_control(struct plugin_api* newapi,
112 struct viewport parent[NB_SCREENS]) 115 struct viewport parent[NB_SCREENS])
113{ 116{
114 api = newapi; 117 api = newapi;
118 parentvp = parent;
115 return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB; 119 return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB;
116} 120}
diff --git a/apps/plugins/lib/playback_control.h b/apps/plugins/lib/playback_control.h
index 6029152dcf..49e789bbdc 100644
--- a/apps/plugins/lib/playback_control.h
+++ b/apps/plugins/lib/playback_control.h
@@ -20,9 +20,14 @@
20#define __PLAYBACK_CONTROL_H__ 20#define __PLAYBACK_CONTROL_H__
21 21
22/* Use these if your menu uses the new menu api. 22/* Use these if your menu uses the new menu api.
23 REMEBER to call playback_control_init(rb) before rb->do_menu()... */ 23 REMEBER to call playback_control_init(rb) before rb->do_menu()...
24 The parent viewport here is needed by the internal functions,
25 So, make sure you use the same viewport for the rb->do_menu() call
26 that you use in the playback_control_init() call
27*/
24extern const struct menu_item_ex playback_control_menu; 28extern const struct menu_item_ex playback_control_menu;
25void playback_control_init(struct plugin_api* newapi); 29void playback_control_init(struct plugin_api* newapi,
30 struct viewport parent[NB_SCREENS]);
26 31
27/* Use this if your menu still uses the old menu api */ 32/* Use this if your menu still uses the old menu api */
28bool playback_control(struct plugin_api* api, 33bool playback_control(struct plugin_api* api,
diff --git a/apps/settings.c b/apps/settings.c
index 58d9220dc3..394f0a6c03 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1052,7 +1052,7 @@ bool set_int_ex(const unsigned char* string,
1052 item.lang_id = -1; 1052 item.lang_id = -1;
1053 item.cfg_vals = (char*)string; 1053 item.cfg_vals = (char*)string;
1054 item.setting = (void *)variable; 1054 item.setting = (void *)variable;
1055 return option_screen(&item, false, NULL); 1055 return option_screen(&item, NULL, false, NULL);
1056} 1056}
1057 1057
1058 1058
@@ -1088,7 +1088,7 @@ bool set_option(const char* string, const void* variable, enum optiontype type,
1088 temp = *(bool*)variable? 1: 0; 1088 temp = *(bool*)variable? 1: 0;
1089 else 1089 else
1090 temp = *(int*)variable; 1090 temp = *(int*)variable;
1091 if (!option_screen(&item, false, NULL)) 1091 if (!option_screen(&item, NULL, false, NULL))
1092 { 1092 {
1093 if (type == BOOL) 1093 if (type == BOOL)
1094 *(bool*)variable = (temp == 1? true: false); 1094 *(bool*)variable = (temp == 1? true: false);