From fe9dca3d5b6156b85f1085ecc11ba8e3a1dcd2d7 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 23 Apr 2008 11:07:40 +0000 Subject: option_screen() now accepts a viewport git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17223 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/option_select.c | 3 ++- apps/gui/option_select.h | 3 +++ apps/menu.c | 7 ++++--- apps/menu.h | 3 ++- apps/menus/eq_menu.c | 2 +- apps/plugin.h | 1 + apps/plugins/lib/playback_control.c | 12 ++++++++---- apps/plugins/lib/playback_control.h | 9 +++++++-- apps/settings.c | 4 ++-- 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, } bool option_screen(struct settings_list *setting, + struct viewport parent[NB_SCREENS], bool use_temp_var, unsigned char* option_title) { int action; @@ -451,7 +452,7 @@ bool option_screen(struct settings_list *setting, } else return false; /* only int/bools can go here */ gui_synclist_init(&lists, value_setting_get_name_cb, - (void*)setting, false, 1, NULL); + (void*)setting, false, 1, parent); if (setting->lang_id == -1) title = (char*)setting->cfg_vals; 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 @@ #ifndef _GUI_OPTION_SELECT_H_ #define _GUI_OPTION_SELECT_H_ +#include "config.h" +#include "screen_access.h" #include "settings.h" bool option_screen(struct settings_list *setting, + struct viewport parent[NB_SCREENS], bool use_temp_var, unsigned char* option_title); struct 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 #endif } -bool do_setting_from_menu(const struct menu_item_ex *temp) +bool do_setting_from_menu(const struct menu_item_ex *temp, + struct viewport parent[NB_SCREENS]) { int setting_id, oldval; const struct settings_list *setting = find_setting( @@ -351,7 +352,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp) title = padded_title; } - option_screen((struct settings_list *)setting, + option_screen((struct settings_list *)setting, parent, setting->flags&F_TEMPVAR, title); if (var_type == F_T_INT || var_type == F_T_UINT) { @@ -585,7 +586,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, case MT_SETTING: case MT_SETTING_W_TEXT: { - if (do_setting_from_menu(temp)) + if (do_setting_from_menu(temp, menu_vp)) { init_default_menu_viewports(menu_vp, hide_bars); 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 { typedef int (*menu_callback_type)(int action, const struct menu_item_ex *this_item); -bool do_setting_from_menu(const struct menu_item_ex *temp); +bool do_setting_from_menu(const struct menu_item_ex *temp, + struct viewport parent[NB_SCREENS]); /* 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) { const struct menu_item_ex *setting = (const struct menu_item_ex*)param; lowlatency_callback(ACTION_ENTER_MENUITEM, setting); - do_setting_from_menu(setting); + do_setting_from_menu(setting, NULL); eq_apply(); lowlatency_callback(ACTION_EXIT_MENUITEM, setting); 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 { /* options */ const struct settings_list* (*find_setting)(const void* variable, int *id); bool (*option_screen)(struct settings_list *setting, + struct viewport parent[NB_SCREENS], bool use_temp_var, unsigned char* option_title); bool (*set_option)(const char* string, const void* variable, 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 @@ #include "plugin.h" struct plugin_api* api = 0; +struct viewport *parentvp = NULL; bool prevtrack(void) { @@ -61,14 +62,14 @@ static bool volume(void) { const struct settings_list* vol = api->find_setting(&api->global_settings->volume, NULL); - return api->option_screen((struct settings_list*)vol, false, "Volume"); + return api->option_screen((struct settings_list*)vol, parentvp, false, "Volume"); } static bool shuffle(void) { const struct settings_list* shuffle = api->find_setting(&api->global_settings->playlist_shuffle, NULL); - return api->option_screen((struct settings_list*)shuffle, false, "Shuffle"); + return api->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle"); } static bool repeat_mode(void) @@ -77,7 +78,7 @@ static bool repeat_mode(void) api->find_setting(&api->global_settings->repeat_mode, NULL); int old_repeat = api->global_settings->repeat_mode; - api->option_screen((struct settings_list*)repeat, false, "Repeat"); + api->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat"); if (old_repeat != api->global_settings->repeat_mode && (api->audio_status() & AUDIO_STATUS_PLAY)) @@ -103,14 +104,17 @@ MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON, &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, &volume_item, &shuffle_item, &repeat_mode_item); -void playback_control_init(struct plugin_api* newapi) +void playback_control_init(struct plugin_api* newapi, + struct viewport parent[NB_SCREENS]) { api = newapi; + parentvp = parent; } bool playback_control(struct plugin_api* newapi, struct viewport parent[NB_SCREENS]) { api = newapi; + parentvp = parent; return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB; } 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 @@ #define __PLAYBACK_CONTROL_H__ /* Use these if your menu uses the new menu api. - REMEBER to call playback_control_init(rb) before rb->do_menu()... */ + REMEBER to call playback_control_init(rb) before rb->do_menu()... + The parent viewport here is needed by the internal functions, + So, make sure you use the same viewport for the rb->do_menu() call + that you use in the playback_control_init() call +*/ extern const struct menu_item_ex playback_control_menu; -void playback_control_init(struct plugin_api* newapi); +void playback_control_init(struct plugin_api* newapi, + struct viewport parent[NB_SCREENS]); /* Use this if your menu still uses the old menu api */ bool 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, item.lang_id = -1; item.cfg_vals = (char*)string; item.setting = (void *)variable; - return option_screen(&item, false, NULL); + return option_screen(&item, NULL, false, NULL); } @@ -1088,7 +1088,7 @@ bool set_option(const char* string, const void* variable, enum optiontype type, temp = *(bool*)variable? 1: 0; else temp = *(int*)variable; - if (!option_screen(&item, false, NULL)) + if (!option_screen(&item, NULL, false, NULL)) { if (type == BOOL) *(bool*)variable = (temp == 1? true: false); -- cgit v1.2.3