From 7b1dd6b60a1b39468be02bb7a1e71f4be354ce0f Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 8 Dec 2023 20:30:59 -0500 Subject: 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 --- apps/gui/option_select.c | 12 ++++++++---- apps/gui/option_select.h | 6 +++--- apps/gui/skin_engine/skin_display.c | 2 +- apps/gui/skin_engine/skin_parser.c | 17 ++++++++++++++--- apps/gui/skin_engine/skin_touchsupport.c | 26 +++++++++++++------------- apps/gui/skin_engine/wps_internals.h | 2 +- manual/appendix/wps_tags.tex | 3 ++- 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, return false; } -int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val) +int get_setting_info_for_bar(const struct settings_list *setting, int offset, int *count, int *val) { int var_type = setting->flags&F_T_MASK; void (*function)(int) = NULL; @@ -602,7 +602,9 @@ int get_setting_info_for_bar(const struct settings_list *setting, int *count, in if (var_type == F_T_INT || var_type == F_T_UINT) { - oldvalue = *(int*)setting->setting; + if (!(setting->flags&F_EQSETTING) || offset > 2) + offset = 0; + oldvalue = ((int*)setting->setting)[offset]; } else if (var_type == F_T_BOOL) { @@ -620,14 +622,16 @@ int get_setting_info_for_bar(const struct settings_list *setting, int *count, in } #ifdef HAVE_TOUCHSCREEN -void update_setting_value_from_touch(const struct settings_list *setting, int selection) +void update_setting_value_from_touch(const struct settings_list *setting, int offset, int selection) { int new_val = selection_to_val(setting, selection); int var_type = setting->flags&F_T_MASK; if (var_type == F_T_INT || var_type == F_T_UINT) { - *(int*)setting->setting = new_val; + if (!(setting->flags&F_EQSETTING) || offset > 2) + offset = 0; + ((int*)setting->setting)[offset] = new_val; } else if (var_type == F_T_BOOL) { 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, void option_select_next_val(const struct settings_list *setting, bool previous, bool apply); #endif -const char *option_get_valuestring(const struct settings_list *setting, +const char *option_get_valuestring(const struct settings_list *setting, char *buffer, int buf_len, intptr_t temp_var); void 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 /* only use this for int and bool settings */ int option_value_as_int(const struct settings_list *setting); -int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val); +int get_setting_info_for_bar(const struct settings_list *setting, int offset, int *count, int *val); #ifdef HAVE_TOUCHSCREEN -void update_setting_value_from_touch(const struct settings_list *setting, int selection); +void update_setting_value_from_touch(const struct settings_list *setting, int offset, int selection); #endif #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, else if (pb->type == SKIN_TOKEN_SETTINGBAR) { int val, count; - get_setting_info_for_bar(pb->setting, &count, &val); + get_setting_info_for_bar(pb->setting, pb->setting_offset, &count, &val); length = count - 1; end = val; } 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, struct viewport *vp = &curr_vp->vp; struct skin_tag_parameter *param = get_param(element, 0); int curr_param = 0; + int setting_offset = 0; char *image_filename = NULL; #ifdef HAVE_TOUCHSCREEN bool suppress_touchregion = false; @@ -1082,7 +1083,7 @@ static int parse_progressbar_tag(struct skin_element* element, enum { eINVERT = 0, eNOFILL, eNOBORDER, eNOBAR, eSLIDER, eIMAGE, - eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, + eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, eSETTING_OFFSET, e_PB_TAG_COUNT }; @@ -1090,7 +1091,7 @@ static int parse_progressbar_tag(struct skin_element* element, [eNOFILL] = "nofill", [eNOBORDER] = "noborder", [eNOBAR] = "nobar", [eSLIDER] = "slider", [eIMAGE] = "image", [eBACKDROP] = "backdrop", [eVERTICAL] = "vertical", [eHORIZONTAL] = "horizontal", - [eNOTOUCH] = "notouch", [eSETTING] = "setting", [e_PB_TAG_COUNT] = NULL}; + [eNOTOUCH] = "notouch", [eSETTING] = "setting", [eSETTING_OFFSET] = "soffset", [e_PB_TAG_COUNT] = NULL}; int pb_op; while (curr_param < element->params_count) @@ -1158,6 +1159,15 @@ static int parse_progressbar_tag(struct skin_element* element, else if (pb_op == eNOTOUCH) suppress_touchregion = true; #endif + else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING_OFFSET) + { + if (curr_param+1 < element->params_count) + { + curr_param++; + param++; + setting_offset = param->data.number; + } + } else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING) { if (curr_param+1 < element->params_count) @@ -1169,6 +1179,7 @@ static int parse_progressbar_tag(struct skin_element* element, pb->setting = find_setting_by_cfgname(text); if (!pb->setting) return WPS_ERROR_INVALID_PARAM; + pb->setting_offset = setting_offset; #endif } } @@ -1223,7 +1234,7 @@ static int parse_progressbar_tag(struct skin_element* element, else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR) token->type = SKIN_TOKEN_LIST_SCROLLBAR; else if (token->type == SKIN_TOKEN_SETTING) - token->type = SKIN_TOKEN_SETTINGBAR; + token->type = SKIN_TOKEN_SETTINGBAR; pb->type = token->type; #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 @@ * KIND, either express or implied. * ****************************************************************************/ - + #include "config.h" #include #include "action.h" @@ -80,7 +80,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) regions = SKINOFFSETTOPTR(skin_buffer, regions->next); continue; } - if (data->touchscreen_locked && + if (data->touchscreen_locked && (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked)) { regions = SKINOFFSETTOPTR(skin_buffer, regions->next); @@ -143,7 +143,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) r->last_press = current_tick; break; default: - if (r->armed && ((repeated && needs_repeat) || + if (r->armed && ((repeated && needs_repeat) || (released && !needs_repeat))) { returncode = r->action; @@ -166,7 +166,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) skin_disarm_touchregions(gwps); if (temp && temp->press_length == LONG_PRESS) temp->armed = false; - + if (returncode != ACTION_NONE) { if (global_settings.party_mode) @@ -227,9 +227,9 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { - const struct settings_list *setting = + const struct settings_list *setting = temp->setting_data.setting; - option_select_next_val(setting, + option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true); returncode = ACTION_REDRAW; @@ -245,7 +245,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) case F_T_CUSTOM: s->custom_setting ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text)); - break; + break; case F_T_INT: case F_T_UINT: *(int*)s->setting = data->value.number; @@ -287,7 +287,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) break; case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ { - global_settings.playlist_shuffle = + global_settings.playlist_shuffle = !global_settings.playlist_shuffle; replaygain_update(); if (global_settings.playlist_shuffle) @@ -299,7 +299,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) break; case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ { - const struct settings_list *rep_setting = + const struct settings_list *rep_setting = find_setting(&global_settings.repeat_mode); option_select_next_val(rep_setting, false, true); audio_flush_and_reload_tracks(); @@ -307,15 +307,15 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) } break; case ACTION_TOUCH_SETTING: - { + { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, temp->bar); if (bar && edge_offset) - { + { int val, count; - get_setting_info_for_bar(bar->setting, &count, &val); + get_setting_info_for_bar(bar->setting, bar->setting_offset, &count, &val); val = *edge_offset * count / 1000; - update_setting_value_from_touch(bar->setting, val); + update_setting_value_from_touch(bar->setting, bar->setting_offset, val); } } 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 { bool nobar; OFFSETTYPE(struct gui_img *) slider; bool horizontal; + char setting_offset; OFFSETTYPE(struct gui_img *) backdrop; const struct settings_list *setting; - }; struct 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. \config{\%Vi('label',\dots)} & Declare a Custom UI Viewport. The `\dots' parameters use the same logic as - the \config{\%V} tag explained above. See section \ref{ref:Viewports}.\\ + the \config{\%V} tag explained above. See section \ref{ref:Viewports}.\\ \config{\%VI('label')} & Set the Info Viewport to use the viewport called label, as declared with the previous tag.\\ @@ -708,6 +708,7 @@ display cycling round the defined sublines. See \opt{touchscreen}{ \item[notouch] -- don't create the touchregion for progress/volume bars. } + \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. \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} -- cgit v1.2.3