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:
parent
286d48f4ec
commit
fe9dca3d5b
9 changed files with 30 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue