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
This commit is contained in:
Solomon Peachy 2023-12-08 20:30:59 -05:00
parent e8a51569ad
commit 7b1dd6b60a
7 changed files with 42 additions and 26 deletions

View file

@ -594,7 +594,7 @@ bool option_screen(const struct settings_list *setting,
return false; 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; int var_type = setting->flags&F_T_MASK;
void (*function)(int) = NULL; 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) 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) 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 #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 new_val = selection_to_val(setting, selection);
int var_type = setting->flags&F_T_MASK; int var_type = setting->flags&F_T_MASK;
if (var_type == F_T_INT || var_type == F_T_UINT) 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) else if (var_type == F_T_BOOL)
{ {

View file

@ -38,7 +38,7 @@ bool option_screen(const struct settings_list *setting,
void option_select_next_val(const struct settings_list *setting, void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply); bool previous, bool apply);
#endif #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, char *buffer, int buf_len,
intptr_t temp_var); intptr_t temp_var);
void option_talk_value(const struct settings_list *setting, int value, bool enqueue); 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 */ /* 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(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 #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
#endif /* _GUI_OPTION_SELECT_H_ */ #endif /* _GUI_OPTION_SELECT_H_ */

View file

@ -217,7 +217,7 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
else if (pb->type == SKIN_TOKEN_SETTINGBAR) else if (pb->type == SKIN_TOKEN_SETTINGBAR)
{ {
int val, count; 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; length = count - 1;
end = val; end = val;
} }

View file

@ -960,6 +960,7 @@ static int parse_progressbar_tag(struct skin_element* element,
struct viewport *vp = &curr_vp->vp; struct viewport *vp = &curr_vp->vp;
struct skin_tag_parameter *param = get_param(element, 0); struct skin_tag_parameter *param = get_param(element, 0);
int curr_param = 0; int curr_param = 0;
int setting_offset = 0;
char *image_filename = NULL; char *image_filename = NULL;
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN
bool suppress_touchregion = false; bool suppress_touchregion = false;
@ -1082,7 +1083,7 @@ static int parse_progressbar_tag(struct skin_element* element,
enum enum
{ {
eINVERT = 0, eNOFILL, eNOBORDER, eNOBAR, eSLIDER, eIMAGE, eINVERT = 0, eNOFILL, eNOBORDER, eNOBAR, eSLIDER, eIMAGE,
eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, eBACKDROP, eVERTICAL, eHORIZONTAL, eNOTOUCH, eSETTING, eSETTING_OFFSET,
e_PB_TAG_COUNT e_PB_TAG_COUNT
}; };
@ -1090,7 +1091,7 @@ static int parse_progressbar_tag(struct skin_element* element,
[eNOFILL] = "nofill", [eNOBORDER] = "noborder", [eNOBAR] = "nobar", [eNOFILL] = "nofill", [eNOBORDER] = "noborder", [eNOBAR] = "nobar",
[eSLIDER] = "slider", [eIMAGE] = "image", [eBACKDROP] = "backdrop", [eSLIDER] = "slider", [eIMAGE] = "image", [eBACKDROP] = "backdrop",
[eVERTICAL] = "vertical", [eHORIZONTAL] = "horizontal", [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; int pb_op;
while (curr_param < element->params_count) while (curr_param < element->params_count)
@ -1158,6 +1159,15 @@ static int parse_progressbar_tag(struct skin_element* element,
else if (pb_op == eNOTOUCH) else if (pb_op == eNOTOUCH)
suppress_touchregion = true; suppress_touchregion = true;
#endif #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) else if (token->type == SKIN_TOKEN_SETTING && pb_op == eSETTING)
{ {
if (curr_param+1 < element->params_count) 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); pb->setting = find_setting_by_cfgname(text);
if (!pb->setting) if (!pb->setting)
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
pb->setting_offset = setting_offset;
#endif #endif
} }
} }
@ -1223,7 +1234,7 @@ static int parse_progressbar_tag(struct skin_element* element,
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) else if (token->type == SKIN_TOKEN_SETTING)
token->type = SKIN_TOKEN_SETTINGBAR; token->type = SKIN_TOKEN_SETTINGBAR;
pb->type = token->type; pb->type = token->type;
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN

View file

@ -18,7 +18,7 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include "action.h" #include "action.h"
@ -80,7 +80,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
regions = SKINOFFSETTOPTR(skin_buffer, regions->next); regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
continue; continue;
} }
if (data->touchscreen_locked && if (data->touchscreen_locked &&
(r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked)) (r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked))
{ {
regions = SKINOFFSETTOPTR(skin_buffer, regions->next); 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; r->last_press = current_tick;
break; break;
default: default:
if (r->armed && ((repeated && needs_repeat) || if (r->armed && ((repeated && needs_repeat) ||
(released && !needs_repeat))) (released && !needs_repeat)))
{ {
returncode = r->action; returncode = r->action;
@ -166,7 +166,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
skin_disarm_touchregions(gwps); skin_disarm_touchregions(gwps);
if (temp && temp->press_length == LONG_PRESS) if (temp && temp->press_length == LONG_PRESS)
temp->armed = false; temp->armed = false;
if (returncode != ACTION_NONE) if (returncode != ACTION_NONE)
{ {
if (global_settings.party_mode) 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_INC:
case ACTION_SETTINGS_DEC: case ACTION_SETTINGS_DEC:
{ {
const struct settings_list *setting = const struct settings_list *setting =
temp->setting_data.setting; temp->setting_data.setting;
option_select_next_val(setting, option_select_next_val(setting,
returncode == ACTION_SETTINGS_DEC, returncode == ACTION_SETTINGS_DEC,
true); true);
returncode = ACTION_REDRAW; returncode = ACTION_REDRAW;
@ -245,7 +245,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
case F_T_CUSTOM: case F_T_CUSTOM:
s->custom_setting s->custom_setting
->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text)); ->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text));
break; break;
case F_T_INT: case F_T_INT:
case F_T_UINT: case F_T_UINT:
*(int*)s->setting = data->value.number; *(int*)s->setting = data->value.number;
@ -287,7 +287,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
break; break;
case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */ case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */
{ {
global_settings.playlist_shuffle = global_settings.playlist_shuffle =
!global_settings.playlist_shuffle; !global_settings.playlist_shuffle;
replaygain_update(); replaygain_update();
if (global_settings.playlist_shuffle) if (global_settings.playlist_shuffle)
@ -299,7 +299,7 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
break; break;
case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */ 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); find_setting(&global_settings.repeat_mode);
option_select_next_val(rep_setting, false, true); option_select_next_val(rep_setting, false, true);
audio_flush_and_reload_tracks(); audio_flush_and_reload_tracks();
@ -307,15 +307,15 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
} }
break; break;
case ACTION_TOUCH_SETTING: case ACTION_TOUCH_SETTING:
{ {
struct progressbar *bar = struct progressbar *bar =
SKINOFFSETTOPTR(skin_buffer, temp->bar); SKINOFFSETTOPTR(skin_buffer, temp->bar);
if (bar && edge_offset) if (bar && edge_offset)
{ {
int val, count; 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; 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; break;

View file

@ -132,9 +132,9 @@ struct progressbar {
bool nobar; bool nobar;
OFFSETTYPE(struct gui_img *) slider; OFFSETTYPE(struct gui_img *) slider;
bool horizontal; bool horizontal;
char setting_offset;
OFFSETTYPE(struct gui_img *) backdrop; OFFSETTYPE(struct gui_img *) backdrop;
const struct settings_list *setting; const struct settings_list *setting;
}; };
struct draw_rectangle { struct draw_rectangle {

View file

@ -85,7 +85,7 @@ show the information for the next song to be played.
\config{\%Vi('label',\dots)} & \config{\%Vi('label',\dots)} &
Declare a Custom UI Viewport. The `\dots' parameters use the same logic as 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 \config{\%VI('label')} & Set the Info Viewport to use the viewport called
label, as declared with the previous tag.\\ label, as declared with the previous tag.\\
@ -708,6 +708,7 @@ 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[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 \item[setting] -- Specify the setting name to draw the bar from (bar must be
\%St type), the next param is the settings config name. \%St type), the next param is the settings config name.
\end{description} \end{description}