option_screen() now accepts a viewport

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17223 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2008-04-23 11:07:40 +00:00
parent 286d48f4ec
commit fe9dca3d5b
9 changed files with 30 additions and 14 deletions

View file

@ -426,6 +426,7 @@ static void val_to_selection(struct settings_list *setting, int oldvalue,
} }
bool option_screen(struct settings_list *setting, bool option_screen(struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title) bool use_temp_var, unsigned char* option_title)
{ {
int action; int action;
@ -451,7 +452,7 @@ bool option_screen(struct settings_list *setting,
} }
else return false; /* only int/bools can go here */ else return false; /* only int/bools can go here */
gui_synclist_init(&lists, value_setting_get_name_cb, gui_synclist_init(&lists, value_setting_get_name_cb,
(void*)setting, false, 1, NULL); (void*)setting, false, 1, parent);
if (setting->lang_id == -1) if (setting->lang_id == -1)
title = (char*)setting->cfg_vals; title = (char*)setting->cfg_vals;
else else

View file

@ -19,9 +19,12 @@
#ifndef _GUI_OPTION_SELECT_H_ #ifndef _GUI_OPTION_SELECT_H_
#define _GUI_OPTION_SELECT_H_ #define _GUI_OPTION_SELECT_H_
#include "config.h"
#include "screen_access.h"
#include "settings.h" #include "settings.h"
bool option_screen(struct settings_list *setting, bool option_screen(struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title); bool use_temp_var, unsigned char* option_title);
struct option_select struct option_select

View file

@ -304,7 +304,8 @@ void init_default_menu_viewports(struct viewport parent[NB_SCREENS], bool hide_b
#endif #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; int setting_id, oldval;
const struct settings_list *setting = find_setting( 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; title = padded_title;
} }
option_screen((struct settings_list *)setting, option_screen((struct settings_list *)setting, parent,
setting->flags&F_TEMPVAR, title); setting->flags&F_TEMPVAR, title);
if (var_type == F_T_INT || var_type == F_T_UINT) 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:
case MT_SETTING_W_TEXT: 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_default_menu_viewports(menu_vp, hide_bars);
init_menu_lists(menu, &lists, selected, true,vps); init_menu_lists(menu, &lists, selected, true,vps);

View file

@ -99,7 +99,8 @@ struct menu_item_ex {
typedef int (*menu_callback_type)(int action, typedef int (*menu_callback_type)(int action,
const struct menu_item_ex *this_item); 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) int do_menu(const struct menu_item_ex *menu, int *start_selected)

View file

@ -134,7 +134,7 @@ static int do_option(void * param)
{ {
const struct menu_item_ex *setting = (const struct menu_item_ex*)param; const struct menu_item_ex *setting = (const struct menu_item_ex*)param;
lowlatency_callback(ACTION_ENTER_MENUITEM, setting); lowlatency_callback(ACTION_ENTER_MENUITEM, setting);
do_setting_from_menu(setting); do_setting_from_menu(setting, NULL);
eq_apply(); eq_apply();
lowlatency_callback(ACTION_EXIT_MENUITEM, setting); lowlatency_callback(ACTION_EXIT_MENUITEM, setting);
return 0; return 0;

View file

@ -569,6 +569,7 @@ struct plugin_api {
/* options */ /* options */
const struct settings_list* (*find_setting)(const void* variable, int *id); const struct settings_list* (*find_setting)(const void* variable, int *id);
bool (*option_screen)(struct settings_list *setting, bool (*option_screen)(struct settings_list *setting,
struct viewport parent[NB_SCREENS],
bool use_temp_var, unsigned char* option_title); bool use_temp_var, unsigned char* option_title);
bool (*set_option)(const char* string, const void* variable, bool (*set_option)(const char* string, const void* variable,
enum optiontype type, const struct opt_items* options, enum optiontype type, const struct opt_items* options,

View file

@ -20,6 +20,7 @@
#include "plugin.h" #include "plugin.h"
struct plugin_api* api = 0; struct plugin_api* api = 0;
struct viewport *parentvp = NULL;
bool prevtrack(void) bool prevtrack(void)
{ {
@ -61,14 +62,14 @@ static bool volume(void)
{ {
const struct settings_list* vol = const struct settings_list* vol =
api->find_setting(&api->global_settings->volume, NULL); 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) static bool shuffle(void)
{ {
const struct settings_list* shuffle = const struct settings_list* shuffle =
api->find_setting(&api->global_settings->playlist_shuffle, NULL); 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) static bool repeat_mode(void)
@ -77,7 +78,7 @@ static bool repeat_mode(void)
api->find_setting(&api->global_settings->repeat_mode, NULL); api->find_setting(&api->global_settings->repeat_mode, NULL);
int old_repeat = api->global_settings->repeat_mode; 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 && if (old_repeat != api->global_settings->repeat_mode &&
(api->audio_status() & AUDIO_STATUS_PLAY)) (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, &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item,
&volume_item, &shuffle_item, &repeat_mode_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; api = newapi;
parentvp = parent;
} }
bool playback_control(struct plugin_api* newapi, bool playback_control(struct plugin_api* newapi,
struct viewport parent[NB_SCREENS]) struct viewport parent[NB_SCREENS])
{ {
api = newapi; api = newapi;
parentvp = parent;
return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB; return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB;
} }

View file

@ -20,9 +20,14 @@
#define __PLAYBACK_CONTROL_H__ #define __PLAYBACK_CONTROL_H__
/* Use these if your menu uses the new menu api. /* 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; 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 */ /* Use this if your menu still uses the old menu api */
bool playback_control(struct plugin_api* api, bool playback_control(struct plugin_api* api,

View file

@ -1052,7 +1052,7 @@ bool set_int_ex(const unsigned char* string,
item.lang_id = -1; item.lang_id = -1;
item.cfg_vals = (char*)string; item.cfg_vals = (char*)string;
item.setting = (void *)variable; 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; temp = *(bool*)variable? 1: 0;
else else
temp = *(int*)variable; temp = *(int*)variable;
if (!option_screen(&item, false, NULL)) if (!option_screen(&item, NULL, false, NULL))
{ {
if (type == BOOL) if (type == BOOL)
*(bool*)variable = (temp == 1? true: false); *(bool*)variable = (temp == 1? true: false);