skin_engine: Allow the %St() (setting) skin tag be used as a bar

%St(<setting name>) or %St(<bar tags>, setting, <setting name>)

Change-Id: I71396d683634d4d1ad2357018c4029ecb4229677
This commit is contained in:
Jonathan Gordon 2012-07-05 22:44:13 +10:00
parent f6d6a4602c
commit 65f9df3083
9 changed files with 73 additions and 2 deletions

View file

@ -575,3 +575,28 @@ bool option_screen(const struct settings_list *setting,
return false; return false;
} }
int get_setting_info_for_bar(int setting_id, int *count, int *val)
{
const struct settings_list *setting = &settings[setting_id];
int var_type = setting->flags&F_T_MASK;
void (*function)(int) = NULL;
int oldvalue;
if (var_type == F_T_INT || var_type == F_T_UINT)
{
oldvalue = *(int*)setting->setting;
}
else if (var_type == F_T_BOOL)
{
oldvalue = *(bool*)setting->setting?1:0;
}
else
{
*val = 0;
*count = 1;
return false; /* only int/bools can go here */
}
val_to_selection(setting, oldvalue, count, val, &function);
return true;
}

View file

@ -48,4 +48,6 @@ void option_talk_value(const struct settings_list *setting, int value, bool enqu
/* only use this for int and bool settings */ /* only use this for int and bool settings */
int option_value_as_int(const struct settings_list *setting); int option_value_as_int(const struct settings_list *setting);
int get_setting_info_for_bar(int setting_id, int *count, int *val);
#endif /* _GUI_OPTION_SELECT_H_ */ #endif /* _GUI_OPTION_SELECT_H_ */

View file

@ -44,6 +44,7 @@
#include "audio.h" #include "audio.h"
#include "tagcache.h" #include "tagcache.h"
#include "list.h" #include "list.h"
#include "option_select.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "peakmeter.h" #include "peakmeter.h"
@ -145,6 +146,13 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
end = val - min; end = val - min;
length = max - min; length = max - min;
} }
else if (pb->type == SKIN_TOKEN_SETTINGBAR)
{
int val, count;
get_setting_info_for_bar(pb->setting_id, &count, &val);
length = count - 1;
end = val;
}
#if CONFIG_TUNER #if CONFIG_TUNER
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
{ {

View file

@ -736,6 +736,10 @@ static int parse_image_special(struct skin_element *element,
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
static int parse_progressbar_tag(struct skin_element* element,
struct wps_token *token,
struct wps_data *wps_data);
static int parse_setting_and_lang(struct skin_element *element, static int parse_setting_and_lang(struct skin_element *element,
struct wps_token *token, struct wps_token *token,
struct wps_data *wps_data) struct wps_data *wps_data)
@ -757,6 +761,13 @@ static int parse_setting_and_lang(struct skin_element *element,
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
#endif #endif
} }
else if (element->params_count > 1)
{
if (element->params_count > 4)
return parse_progressbar_tag(element, token, wps_data);
else
return WPS_ERROR_INVALID_PARAM;
}
else else
{ {
#ifndef __PCTOOL__ #ifndef __PCTOOL__
@ -891,6 +902,7 @@ static int parse_progressbar_tag(struct skin_element* element,
pb->image = PTRTOSKINOFFSET(skin_buffer, NULL); pb->image = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL); pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL); pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->setting_id = -1;
pb->invert_fill_direction = false; pb->invert_fill_direction = false;
pb->horizontal = true; pb->horizontal = true;
@ -1015,6 +1027,19 @@ static int parse_progressbar_tag(struct skin_element* element,
else if (!strcmp(text, "notouch")) else if (!strcmp(text, "notouch"))
suppress_touchregion = true; suppress_touchregion = true;
#endif #endif
else if (token->type == SKIN_TOKEN_SETTING && !strcmp(text, "setting"))
{
if (curr_param+1 < element->params_count)
{
curr_param++;
param++;
text = SKINOFFSETTOPTR(skin_buffer, param->data.text);
#ifndef __PCTOOL__
if (find_setting_by_cfgname(text, &pb->setting_id) == NULL)
return WPS_ERROR_INVALID_PARAM;
#endif
}
}
else if (curr_param == 4) else if (curr_param == 4)
image_filename = text; image_filename = text;
@ -1060,6 +1085,8 @@ static int parse_progressbar_tag(struct skin_element* element,
token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR; token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR;
else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR) else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR)
token->type = SKIN_TOKEN_LIST_SCROLLBAR; token->type = SKIN_TOKEN_LIST_SCROLLBAR;
else if (token->type == SKIN_TOKEN_SETTING)
token->type = SKIN_TOKEN_SETTINGBAR;
pb->type = token->type; pb->type = token->type;
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN

View file

@ -209,6 +209,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
#endif #endif
case SKIN_TOKEN_VOLUMEBAR: case SKIN_TOKEN_VOLUMEBAR:
case SKIN_TOKEN_BATTERY_PERCENTBAR: case SKIN_TOKEN_BATTERY_PERCENTBAR:
case SKIN_TOKEN_SETTINGBAR:
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
case SKIN_TOKEN_PROGRESSBAR: case SKIN_TOKEN_PROGRESSBAR:
case SKIN_TOKEN_TUNER_RSSI_BAR: case SKIN_TOKEN_TUNER_RSSI_BAR:

View file

@ -112,6 +112,8 @@ struct progressbar {
OFFSETTYPE(struct gui_img *) slider; OFFSETTYPE(struct gui_img *) slider;
bool horizontal; bool horizontal;
OFFSETTYPE(struct gui_img *) backdrop; OFFSETTYPE(struct gui_img *) backdrop;
int setting_id; /* for the setting bar type */
}; };
struct draw_rectangle { struct draw_rectangle {

View file

@ -211,8 +211,9 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_VIEWPORT_LOAD, "V" , "IIiii", 0 }, { SKIN_TOKEN_VIEWPORT_LOAD, "V" , "IIiii", 0 },
{ SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK }, { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK },
/* This uses the bar tag params also but the first item can be a string
{ SKIN_TOKEN_SETTING, "St" , "S", SKIN_REFRESH_DYNAMIC }, * and we don't allow no params. */
{ SKIN_TOKEN_SETTING, "St" , "[Si]|iiis*", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC }, { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC }, { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC },

View file

@ -246,6 +246,7 @@ enum skin_token_type {
/* Setting option */ /* Setting option */
SKIN_TOKEN_SETTING, SKIN_TOKEN_SETTING,
SKIN_TOKEN_SETTINGBAR,
SKIN_TOKEN_CURRENT_SCREEN, SKIN_TOKEN_CURRENT_SCREEN,
SKIN_TOKEN_LANG_IS_RTL, SKIN_TOKEN_LANG_IS_RTL,

View file

@ -360,6 +360,8 @@ that, it will display the volume value.
\config{\%St(<setting\tabnlindent{}name>)} & The value of the Rockbox \config{\%St(<setting\tabnlindent{}name>)} & The value of the Rockbox
setting with the specified name. See \reference{ref:config_file_options} setting with the specified name. See \reference{ref:config_file_options}
for the list of the available settings.\\ for the list of the available settings.\\
\config{\%St(...)} & Draw a bar using from the setting.
See \reference{ref:bar_tags} for details.\\
\end{tagmap} \end{tagmap}
Examples: Examples:
@ -715,6 +717,8 @@ display cycling round the defined sublines. See
\opt{touchscreen}{ \opt{touchscreen}{
\item[notouch] -- don't create the touchregion for progress/volume bars. \item[notouch] -- don't create the touchregion for progress/volume bars.
} }
\item[setting] -- Specify the setting name to draw the bar from (bar must be
\%St type), the next param is the settings config name.
\end{description} \end{description}
Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw