summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2023-12-08 20:30:59 -0500
committerSolomon Peachy <pizza@shaftnet.org>2024-04-21 18:27:11 -0400
commit7b1dd6b60a1b39468be02bb7a1e71f4be354ce0f (patch)
tree877e3de05638c85d6876b64d536232951e47db88
parente8a51569ada3bfd85fc0c93911bd5061ce3b6017 (diff)
downloadrockbox-7b1dd6b60a1b39468be02bb7a1e71f4be354ce0f.tar.gz
rockbox-7b1dd6b60a1b39468be02bb7a1e71f4be354ce0f.zip
RFC: Extend skin engine to handle EQ settings
EQ settings are actually an array of 3 ints. I added a skin parameter token that allows specifying which array element to use. So instead of this now-incorrect syntax: %St(0,0,-,-,image,eqbar.bmp,vertical,setting,eq band 1 gain) You would use: %St(0,0,-,-,image,eqbar.bmp,vertical,soffset,2,setting,eq peak filter 1) (the 'gain' is the third element in the eq setting array, thus soffset 2) Change-Id: Ibda712ab87759efb45420566c967742bcefb513b
-rw-r--r--apps/gui/option_select.c12
-rw-r--r--apps/gui/option_select.h6
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_parser.c17
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c26
-rw-r--r--apps/gui/skin_engine/wps_internals.h2
-rw-r--r--manual/appendix/wps_tags.tex3
7 files changed, 42 insertions, 26 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index afc11fc4ee..1ce7fd5026 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -594,7 +594,7 @@ bool option_screen(const struct settings_list *setting,
594 return false; 594 return false;
595} 595}
596 596
597int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val) 597int get_setting_info_for_bar(const struct settings_list *setting, int offset, int *count, int *val)
598{ 598{
599 int var_type = setting->flags&F_T_MASK; 599 int var_type = setting->flags&F_T_MASK;
600 void (*function)(int) = NULL; 600 void (*function)(int) = NULL;
@@ -602,7 +602,9 @@ int get_setting_info_for_bar(const struct settings_list *setting, int *count, in
602 602
603 if (var_type == F_T_INT || var_type == F_T_UINT) 603 if (var_type == F_T_INT || var_type == F_T_UINT)
604 { 604 {
605 oldvalue = *(int*)setting->setting; 605 if (!(setting->flags&F_EQSETTING) || offset > 2)
606 offset = 0;
607 oldvalue = ((int*)setting->setting)[offset];
606 } 608 }
607 else if (var_type == F_T_BOOL) 609 else if (var_type == F_T_BOOL)
608 { 610 {
@@ -620,14 +622,16 @@ int get_setting_info_for_bar(const struct settings_list *setting, int *count, in
620} 622}
621 623
622#ifdef HAVE_TOUCHSCREEN 624#ifdef HAVE_TOUCHSCREEN
623void update_setting_value_from_touch(const struct settings_list *setting, int selection) 625void update_setting_value_from_touch(const struct settings_list *setting, int offset, int selection)
624{ 626{
625 int new_val = selection_to_val(setting, selection); 627 int new_val = selection_to_val(setting, selection);
626 int var_type = setting->flags&F_T_MASK; 628 int var_type = setting->flags&F_T_MASK;
627 629
628 if (var_type == F_T_INT || var_type == F_T_UINT) 630 if (var_type == F_T_INT || var_type == F_T_UINT)
629 { 631 {
630 *(int*)setting->setting = new_val; 632 if (!(setting->flags&F_EQSETTING) || offset > 2)
633 offset = 0;
634 ((int*)setting->setting)[offset] = new_val;
631 } 635 }
632 else if (var_type == F_T_BOOL) 636 else if (var_type == F_T_BOOL)
633 { 637 {
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
index eabe5825e7..4053603b63 100644
--- a/apps/gui/option_select.h
+++ b/apps/gui/option_select.h
@@ -38,7 +38,7 @@ bool option_screen(const struct settings_list *setting,
38void option_select_next_val(const struct settings_list *setting, 38void option_select_next_val(const struct settings_list *setting,
39 bool previous, bool apply); 39 bool previous, bool apply);
40#endif 40#endif
41const char *option_get_valuestring(const struct settings_list *setting, 41const char *option_get_valuestring(const struct settings_list *setting,
42 char *buffer, int buf_len, 42 char *buffer, int buf_len,
43 intptr_t temp_var); 43 intptr_t temp_var);
44void option_talk_value(const struct settings_list *setting, int value, bool enqueue); 44void option_talk_value(const struct settings_list *setting, int value, bool enqueue);
@@ -46,9 +46,9 @@ void option_talk_value(const struct settings_list *setting, int value, bool enqu
46/* only use this for int and bool settings */ 46/* only use this for int and bool settings */
47int option_value_as_int(const struct settings_list *setting); 47int option_value_as_int(const struct settings_list *setting);
48 48
49int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val); 49int get_setting_info_for_bar(const struct settings_list *setting, int offset, int *count, int *val);
50#ifdef HAVE_TOUCHSCREEN 50#ifdef HAVE_TOUCHSCREEN
51void update_setting_value_from_touch(const struct settings_list *setting, int selection); 51void update_setting_value_from_touch(const struct settings_list *setting, int offset, int selection);
52#endif 52#endif
53 53
54#endif /* _GUI_OPTION_SELECT_H_ */ 54#endif /* _GUI_OPTION_SELECT_H_ */
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 913bdcfbc4..aa2184a407 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -217,7 +217,7 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
217 else if (pb->type == SKIN_TOKEN_SETTINGBAR) 217 else if (pb->type == SKIN_TOKEN_SETTINGBAR)
218 { 218 {
219 int val, count; 219 int val, count;
220 get_setting_info_for_bar(pb->setting, &count, &val); 220 get_setting_info_for_bar(pb->setting, pb->setting_offset, &count, &val);
221 length = count - 1; 221 length = count - 1;
222 end = val; 222 end = val;
223 } 223 }
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 39029f79c6..ac68b0dcba 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -960,6 +960,7 @@ static int parse_progressbar_tag(struct skin_element* element,
960 struct viewport *vp = &curr_vp->vp; 960 struct viewport *vp = &curr_vp->vp;
961 struct skin_tag_parameter *param = get_param(element, 0); 961 struct skin_tag_parameter *param = get_param(element, 0);
962 int curr_param = 0; 962 int curr_param = 0;
963 int setting_offset = 0;
963 char *image_filename = NULL; 964 char *image_filename = NULL;
964#ifdef HAVE_TOUCHSCREEN 965#ifdef HAVE_TOUCHSCREEN
965 bool suppress_touchregion = false; 966 bool suppress_touchregion = false;
@@ -1082,7 +1083,7 @@ static int parse_progressbar_tag(struct skin_element* element,
1082 enum 1083 enum
1083 { 1084 {
1084 eINVERT = 0, eNOFILL, eNOBORDER, eNOBAR, eSLIDER, eIMAGE, 1085 eINVERT = 0, eNOFILL, eNOBORDER, eNOBAR, eSLIDER, eIMAGE,
1085 eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, 1086 eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, eSETTING_OFFSET,
1086 e_PB_TAG_COUNT 1087 e_PB_TAG_COUNT
1087 }; 1088 };
1088 1089
@@ -1090,7 +1091,7 @@ static int parse_progressbar_tag(struct skin_element* element,
1090 [eNOFILL] = "nofill", [eNOBORDER] = "noborder", [eNOBAR] = "nobar", 1091 [eNOFILL] = "nofill", [eNOBORDER] = "noborder", [eNOBAR] = "nobar",
1091 [eSLIDER] = "slider", [eIMAGE] = "image", [eBACKDROP] = "backdrop", 1092 [eSLIDER] = "slider", [eIMAGE] = "image", [eBACKDROP] = "backdrop",
1092 [eVERTICAL] = "vertical", [eHORIZONTAL] = "horizontal", 1093 [eVERTICAL] = "vertical", [eHORIZONTAL] = "horizontal",
1093 [eNOTOUCH] = "notouch", [eSETTING] = "setting", [e_PB_TAG_COUNT] = NULL}; 1094 [eNOTOUCH] = "notouch", [eSETTING] = "setting", [eSETTING_OFFSET] = "soffset", [e_PB_TAG_COUNT] = NULL};
1094 int pb_op; 1095 int pb_op;
1095 1096
1096 while (curr_param < element->params_count) 1097 while (curr_param < element->params_count)
@@ -1158,6 +1159,15 @@ static int parse_progressbar_tag(struct skin_element* element,
1158 else if (pb_op == eNOTOUCH) 1159 else if (pb_op == eNOTOUCH)
1159 suppress_touchregion = true; 1160 suppress_touchregion = true;
1160#endif 1161#endif
1162 else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING_OFFSET)
1163 {
1164 if (curr_param+1 < element->params_count)
1165 {
1166 curr_param++;
1167 param++;
1168 setting_offset = param->data.number;
1169 }
1170 }
1161 else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING) 1171 else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING)
1162 { 1172 {
1163 if (curr_param+1 < element->params_count) 1173 if (curr_param+1 < element->params_count)
@@ -1169,6 +1179,7 @@ static int parse_progressbar_tag(struct skin_element* element,
1169 pb->setting = find_setting_by_cfgname(text); 1179 pb->setting = find_setting_by_cfgname(text);
1170 if (!pb->setting) 1180 if (!pb->setting)
1171 return WPS_ERROR_INVALID_PARAM; 1181 return WPS_ERROR_INVALID_PARAM;
1182 pb->setting_offset = setting_offset;
1172#endif 1183#endif
1173 } 1184 }
1174 } 1185 }
@@ -1223,7 +1234,7 @@ static int parse_progressbar_tag(struct skin_element* element,
1223 else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR) 1234 else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR)
1224 token->type = SKIN_TOKEN_LIST_SCROLLBAR; 1235 token->type = SKIN_TOKEN_LIST_SCROLLBAR;
1225 else if (token->type == SKIN_TOKEN_SETTING) 1236 else if (token->type == SKIN_TOKEN_SETTING)
1226 token->type = SKIN_TOKEN_SETTINGBAR; 1237 token->type = SKIN_TOKEN_SETTINGBAR;
1227 pb->type = token->type; 1238 pb->type = token->type;
1228 1239
1229#ifdef HAVE_TOUCHSCREEN 1240#ifdef HAVE_TOUCHSCREEN
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c
index b952709562..cd2f5b6cd2 100644
--- a/apps/gui/skin_engine/skin_touchsupport.c
+++ b/apps/gui/skin_engine/skin_touchsupport.c
@@ -18,7 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#include <stdio.h> 23#include <stdio.h>
24#include "action.h" 24#include "action.h"
@@ -80,7 +80,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
80 regions = SKINOFFSETTOPTR(skin_buffer, regions->next); 80 regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
81 continue; 81 continue;
82 } 82 }
83 if (data->touchscreen_locked && 83 if (data->touchscreen_locked &&
84 (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked)) 84 (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked))
85 { 85 {
86 regions = SKINOFFSETTOPTR(skin_buffer, regions->next); 86 regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
@@ -143,7 +143,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
143 r->last_press = current_tick; 143 r->last_press = current_tick;
144 break; 144 break;
145 default: 145 default:
146 if (r->armed && ((repeated && needs_repeat) || 146 if (r->armed && ((repeated && needs_repeat) ||
147 (released && !needs_repeat))) 147 (released && !needs_repeat)))
148 { 148 {
149 returncode = r->action; 149 returncode = r->action;
@@ -166,7 +166,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
166 skin_disarm_touchregions(gwps); 166 skin_disarm_touchregions(gwps);
167 if (temp && temp->press_length == LONG_PRESS) 167 if (temp && temp->press_length == LONG_PRESS)
168 temp->armed = false; 168 temp->armed = false;
169 169
170 if (returncode != ACTION_NONE) 170 if (returncode != ACTION_NONE)
171 { 171 {
172 if (global_settings.party_mode) 172 if (global_settings.party_mode)
@@ -227,9 +227,9 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
227 case ACTION_SETTINGS_INC: 227 case ACTION_SETTINGS_INC:
228 case ACTION_SETTINGS_DEC: 228 case ACTION_SETTINGS_DEC:
229 { 229 {
230 const struct settings_list *setting = 230 const struct settings_list *setting =
231 temp->setting_data.setting; 231 temp->setting_data.setting;
232 option_select_next_val(setting, 232 option_select_next_val(setting,
233 returncode == ACTION_SETTINGS_DEC, 233 returncode == ACTION_SETTINGS_DEC,
234 true); 234 true);
235 returncode = ACTION_REDRAW; 235 returncode = ACTION_REDRAW;
@@ -245,7 +245,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
245 case F_T_CUSTOM: 245 case F_T_CUSTOM:
246 s->custom_setting 246 s->custom_setting
247 ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text)); 247 ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text));
248 break; 248 break;
249 case F_T_INT: 249 case F_T_INT:
250 case F_T_UINT: 250 case F_T_UINT:
251 *(int*)s->setting = data->value.number; 251 *(int*)s->setting = data->value.number;
@@ -287,7 +287,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
287 break; 287 break;
288 case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ 288 case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */
289 { 289 {
290 global_settings.playlist_shuffle = 290 global_settings.playlist_shuffle =
291 !global_settings.playlist_shuffle; 291 !global_settings.playlist_shuffle;
292 replaygain_update(); 292 replaygain_update();
293 if (global_settings.playlist_shuffle) 293 if (global_settings.playlist_shuffle)
@@ -299,7 +299,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
299 break; 299 break;
300 case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ 300 case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */
301 { 301 {
302 const struct settings_list *rep_setting = 302 const struct settings_list *rep_setting =
303 find_setting(&global_settings.repeat_mode); 303 find_setting(&global_settings.repeat_mode);
304 option_select_next_val(rep_setting, false, true); 304 option_select_next_val(rep_setting, false, true);
305 audio_flush_and_reload_tracks(); 305 audio_flush_and_reload_tracks();
@@ -307,15 +307,15 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
307 } 307 }
308 break; 308 break;
309 case ACTION_TOUCH_SETTING: 309 case ACTION_TOUCH_SETTING:
310 { 310 {
311 struct progressbar *bar = 311 struct progressbar *bar =
312 SKINOFFSETTOPTR(skin_buffer, temp->bar); 312 SKINOFFSETTOPTR(skin_buffer, temp->bar);
313 if (bar && edge_offset) 313 if (bar && edge_offset)
314 { 314 {
315 int val, count; 315 int val, count;
316 get_setting_info_for_bar(bar->setting, &count, &val); 316 get_setting_info_for_bar(bar->setting, bar->setting_offset, &count, &val);
317 val = *edge_offset * count / 1000; 317 val = *edge_offset * count / 1000;
318 update_setting_value_from_touch(bar->setting, val); 318 update_setting_value_from_touch(bar->setting, bar->setting_offset, val);
319 } 319 }
320 } 320 }
321 break; 321 break;
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 8ad8325e66..6e20ed8da9 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -132,9 +132,9 @@ struct progressbar {
132 bool nobar; 132 bool nobar;
133 OFFSETTYPE(struct gui_img *) slider; 133 OFFSETTYPE(struct gui_img *) slider;
134 bool horizontal; 134 bool horizontal;
135 char setting_offset;
135 OFFSETTYPE(struct gui_img *) backdrop; 136 OFFSETTYPE(struct gui_img *) backdrop;
136 const struct settings_list *setting; 137 const struct settings_list *setting;
137
138}; 138};
139 139
140struct draw_rectangle { 140struct draw_rectangle {
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex
index 70fef71015..94b61e9534 100644
--- a/manual/appendix/wps_tags.tex
+++ b/manual/appendix/wps_tags.tex
@@ -85,7 +85,7 @@ show the information for the next song to be played.
85 85
86 \config{\%Vi('label',\dots)} & 86 \config{\%Vi('label',\dots)} &
87 Declare a Custom UI Viewport. The `\dots' parameters use the same logic as 87 Declare a Custom UI Viewport. The `\dots' parameters use the same logic as
88 the \config{\%V} tag explained above. See section \ref{ref:Viewports}.\\ 88 the \config{\%V} tag explained above. See section \ref{ref:Viewports}.\\
89 89
90 \config{\%VI('label')} & Set the Info Viewport to use the viewport called 90 \config{\%VI('label')} & Set the Info Viewport to use the viewport called
91 label, as declared with the previous tag.\\ 91 label, as declared with the previous tag.\\
@@ -708,6 +708,7 @@ display cycling round the defined sublines. See
708 \opt{touchscreen}{ 708 \opt{touchscreen}{
709 \item[notouch] -- don't create the touchregion for progress/volume bars. 709 \item[notouch] -- don't create the touchregion for progress/volume bars.
710 } 710 }
711 \item[soffset] -- For compound settings (such as the equalizer), this lets you pick which element in the set to use. The next param must be the number. Must be specified prior to the setting name.
711 \item[setting] -- Specify the setting name to draw the bar from (bar must be 712 \item[setting] -- Specify the setting name to draw the bar from (bar must be
712 \%St type), the next param is the settings config name. 713 \%St type), the next param is the settings config name.
713\end{description} 714\end{description}