diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2012-07-05 22:44:13 +1000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2012-07-05 23:30:06 +1000 |
commit | 65f9df3083623484efccf502c33ecc959555d247 (patch) | |
tree | 6d55b2eb2d874166be00306a5cc3a7c67ebea227 | |
parent | f6d6a4602c9bb94565f8bb421b465a06f215fb7d (diff) | |
download | rockbox-65f9df3083623484efccf502c33ecc959555d247.tar.gz rockbox-65f9df3083623484efccf502c33ecc959555d247.zip |
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
-rw-r--r-- | apps/gui/option_select.c | 25 | ||||
-rw-r--r-- | apps/gui/option_select.h | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 8 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 27 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_render.c | 1 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 2 | ||||
-rw-r--r-- | lib/skin_parser/tag_table.c | 5 | ||||
-rw-r--r-- | lib/skin_parser/tag_table.h | 1 | ||||
-rw-r--r-- | manual/appendix/wps_tags.tex | 4 |
9 files changed, 73 insertions, 2 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index ca206b86da..f85570d699 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -575,3 +575,28 @@ bool option_screen(const struct settings_list *setting, | |||
575 | return false; | 575 | return false; |
576 | } | 576 | } |
577 | 577 | ||
578 | int get_setting_info_for_bar(int setting_id, int *count, int *val) | ||
579 | { | ||
580 | const struct settings_list *setting = &settings[setting_id]; | ||
581 | int var_type = setting->flags&F_T_MASK; | ||
582 | void (*function)(int) = NULL; | ||
583 | int oldvalue; | ||
584 | |||
585 | if (var_type == F_T_INT || var_type == F_T_UINT) | ||
586 | { | ||
587 | oldvalue = *(int*)setting->setting; | ||
588 | } | ||
589 | else if (var_type == F_T_BOOL) | ||
590 | { | ||
591 | oldvalue = *(bool*)setting->setting?1:0; | ||
592 | } | ||
593 | else | ||
594 | { | ||
595 | *val = 0; | ||
596 | *count = 1; | ||
597 | return false; /* only int/bools can go here */ | ||
598 | } | ||
599 | |||
600 | val_to_selection(setting, oldvalue, count, val, &function); | ||
601 | return true; | ||
602 | } | ||
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index 0a7600ce80..3a14a179a6 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h | |||
@@ -48,4 +48,6 @@ void option_talk_value(const struct settings_list *setting, int value, bool enqu | |||
48 | /* only use this for int and bool settings */ | 48 | /* only use this for int and bool settings */ |
49 | int option_value_as_int(const struct settings_list *setting); | 49 | int option_value_as_int(const struct settings_list *setting); |
50 | 50 | ||
51 | int get_setting_info_for_bar(int setting_id, int *count, int *val); | ||
52 | |||
51 | #endif /* _GUI_OPTION_SELECT_H_ */ | 53 | #endif /* _GUI_OPTION_SELECT_H_ */ |
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 08d17a0258..4f491dea24 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "audio.h" | 44 | #include "audio.h" |
45 | #include "tagcache.h" | 45 | #include "tagcache.h" |
46 | #include "list.h" | 46 | #include "list.h" |
47 | #include "option_select.h" | ||
47 | 48 | ||
48 | #ifdef HAVE_LCD_BITMAP | 49 | #ifdef HAVE_LCD_BITMAP |
49 | #include "peakmeter.h" | 50 | #include "peakmeter.h" |
@@ -145,6 +146,13 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
145 | end = val - min; | 146 | end = val - min; |
146 | length = max - min; | 147 | length = max - min; |
147 | } | 148 | } |
149 | else if (pb->type == SKIN_TOKEN_SETTINGBAR) | ||
150 | { | ||
151 | int val, count; | ||
152 | get_setting_info_for_bar(pb->setting_id, &count, &val); | ||
153 | length = count - 1; | ||
154 | end = val; | ||
155 | } | ||
148 | #if CONFIG_TUNER | 156 | #if CONFIG_TUNER |
149 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) | 157 | else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) |
150 | { | 158 | { |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index f66961d488..cbc2ebed4e 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -736,6 +736,10 @@ static int parse_image_special(struct skin_element *element, | |||
736 | 736 | ||
737 | #endif /* HAVE_LCD_BITMAP */ | 737 | #endif /* HAVE_LCD_BITMAP */ |
738 | 738 | ||
739 | static int parse_progressbar_tag(struct skin_element* element, | ||
740 | struct wps_token *token, | ||
741 | struct wps_data *wps_data); | ||
742 | |||
739 | static int parse_setting_and_lang(struct skin_element *element, | 743 | static int parse_setting_and_lang(struct skin_element *element, |
740 | struct wps_token *token, | 744 | struct wps_token *token, |
741 | struct wps_data *wps_data) | 745 | struct wps_data *wps_data) |
@@ -757,6 +761,13 @@ static int parse_setting_and_lang(struct skin_element *element, | |||
757 | return WPS_ERROR_INVALID_PARAM; | 761 | return WPS_ERROR_INVALID_PARAM; |
758 | #endif | 762 | #endif |
759 | } | 763 | } |
764 | else if (element->params_count > 1) | ||
765 | { | ||
766 | if (element->params_count > 4) | ||
767 | return parse_progressbar_tag(element, token, wps_data); | ||
768 | else | ||
769 | return WPS_ERROR_INVALID_PARAM; | ||
770 | } | ||
760 | else | 771 | else |
761 | { | 772 | { |
762 | #ifndef __PCTOOL__ | 773 | #ifndef __PCTOOL__ |
@@ -891,6 +902,7 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
891 | pb->image = PTRTOSKINOFFSET(skin_buffer, NULL); | 902 | pb->image = PTRTOSKINOFFSET(skin_buffer, NULL); |
892 | pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL); | 903 | pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL); |
893 | pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL); | 904 | pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL); |
905 | pb->setting_id = -1; | ||
894 | pb->invert_fill_direction = false; | 906 | pb->invert_fill_direction = false; |
895 | pb->horizontal = true; | 907 | pb->horizontal = true; |
896 | 908 | ||
@@ -1015,6 +1027,19 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
1015 | else if (!strcmp(text, "notouch")) | 1027 | else if (!strcmp(text, "notouch")) |
1016 | suppress_touchregion = true; | 1028 | suppress_touchregion = true; |
1017 | #endif | 1029 | #endif |
1030 | else if (token->type == SKIN_TOKEN_SETTING && !strcmp(text, "setting")) | ||
1031 | { | ||
1032 | if (curr_param+1 < element->params_count) | ||
1033 | { | ||
1034 | curr_param++; | ||
1035 | param++; | ||
1036 | text = SKINOFFSETTOPTR(skin_buffer, param->data.text); | ||
1037 | #ifndef __PCTOOL__ | ||
1038 | if (find_setting_by_cfgname(text, &pb->setting_id) == NULL) | ||
1039 | return WPS_ERROR_INVALID_PARAM; | ||
1040 | #endif | ||
1041 | } | ||
1042 | } | ||
1018 | else if (curr_param == 4) | 1043 | else if (curr_param == 4) |
1019 | image_filename = text; | 1044 | image_filename = text; |
1020 | 1045 | ||
@@ -1060,6 +1085,8 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
1060 | token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR; | 1085 | token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR; |
1061 | else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR) | 1086 | else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR) |
1062 | token->type = SKIN_TOKEN_LIST_SCROLLBAR; | 1087 | token->type = SKIN_TOKEN_LIST_SCROLLBAR; |
1088 | else if (token->type == SKIN_TOKEN_SETTING) | ||
1089 | token->type = SKIN_TOKEN_SETTINGBAR; | ||
1063 | pb->type = token->type; | 1090 | pb->type = token->type; |
1064 | 1091 | ||
1065 | #ifdef HAVE_TOUCHSCREEN | 1092 | #ifdef HAVE_TOUCHSCREEN |
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index bf7f03d738..0fdf6b019f 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c | |||
@@ -209,6 +209,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, | |||
209 | #endif | 209 | #endif |
210 | case SKIN_TOKEN_VOLUMEBAR: | 210 | case SKIN_TOKEN_VOLUMEBAR: |
211 | case SKIN_TOKEN_BATTERY_PERCENTBAR: | 211 | case SKIN_TOKEN_BATTERY_PERCENTBAR: |
212 | case SKIN_TOKEN_SETTINGBAR: | ||
212 | #ifdef HAVE_LCD_BITMAP | 213 | #ifdef HAVE_LCD_BITMAP |
213 | case SKIN_TOKEN_PROGRESSBAR: | 214 | case SKIN_TOKEN_PROGRESSBAR: |
214 | case SKIN_TOKEN_TUNER_RSSI_BAR: | 215 | case SKIN_TOKEN_TUNER_RSSI_BAR: |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index ab2bc3579e..8cd5d9cb60 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -112,6 +112,8 @@ struct progressbar { | |||
112 | OFFSETTYPE(struct gui_img *) slider; | 112 | OFFSETTYPE(struct gui_img *) slider; |
113 | bool horizontal; | 113 | bool horizontal; |
114 | OFFSETTYPE(struct gui_img *) backdrop; | 114 | OFFSETTYPE(struct gui_img *) backdrop; |
115 | int setting_id; /* for the setting bar type */ | ||
116 | |||
115 | }; | 117 | }; |
116 | 118 | ||
117 | struct draw_rectangle { | 119 | struct draw_rectangle { |
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index 1842cb9f70..76139df04e 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c | |||
@@ -211,8 +211,9 @@ static const struct tag_info legal_tags[] = | |||
211 | { SKIN_TOKEN_VIEWPORT_LOAD, "V" , "IIiii", 0 }, | 211 | { SKIN_TOKEN_VIEWPORT_LOAD, "V" , "IIiii", 0 }, |
212 | 212 | ||
213 | { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK }, | 213 | { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK }, |
214 | 214 | /* This uses the bar tag params also but the first item can be a string | |
215 | { SKIN_TOKEN_SETTING, "St" , "S", SKIN_REFRESH_DYNAMIC }, | 215 | * and we don't allow no params. */ |
216 | { SKIN_TOKEN_SETTING, "St" , "[Si]|iiis*", SKIN_REFRESH_DYNAMIC }, | ||
216 | { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC }, | 217 | { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", SKIN_REFRESH_STATIC }, |
217 | { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC }, | 218 | { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", SKIN_REFRESH_STATIC }, |
218 | 219 | ||
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h index 932f4a5ffd..b29c6d79d8 100644 --- a/lib/skin_parser/tag_table.h +++ b/lib/skin_parser/tag_table.h | |||
@@ -246,6 +246,7 @@ enum skin_token_type { | |||
246 | 246 | ||
247 | /* Setting option */ | 247 | /* Setting option */ |
248 | SKIN_TOKEN_SETTING, | 248 | SKIN_TOKEN_SETTING, |
249 | SKIN_TOKEN_SETTINGBAR, | ||
249 | SKIN_TOKEN_CURRENT_SCREEN, | 250 | SKIN_TOKEN_CURRENT_SCREEN, |
250 | SKIN_TOKEN_LANG_IS_RTL, | 251 | SKIN_TOKEN_LANG_IS_RTL, |
251 | 252 | ||
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 14e0308940..220a308322 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex | |||
@@ -360,6 +360,8 @@ that, it will display the volume value. | |||
360 | \config{\%St(<setting\tabnlindent{}name>)} & The value of the Rockbox | 360 | \config{\%St(<setting\tabnlindent{}name>)} & The value of the Rockbox |
361 | setting with the specified name. See \reference{ref:config_file_options} | 361 | setting with the specified name. See \reference{ref:config_file_options} |
362 | for the list of the available settings.\\ | 362 | for the list of the available settings.\\ |
363 | \config{\%St(...)} & Draw a bar using from the setting. | ||
364 | See \reference{ref:bar_tags} for details.\\ | ||
363 | \end{tagmap} | 365 | \end{tagmap} |
364 | 366 | ||
365 | Examples: | 367 | Examples: |
@@ -715,6 +717,8 @@ display cycling round the defined sublines. See | |||
715 | \opt{touchscreen}{ | 717 | \opt{touchscreen}{ |
716 | \item[notouch] -- don't create the touchregion for progress/volume bars. | 718 | \item[notouch] -- don't create the touchregion for progress/volume bars. |
717 | } | 719 | } |
720 | \item[setting] -- Specify the setting name to draw the bar from (bar must be | ||
721 | \%St type), the next param is the settings config name. | ||
718 | \end{description} | 722 | \end{description} |
719 | 723 | ||
720 | Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw | 724 | Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw |