From 1e6c8d2ea684e8a8e7a5f2cc08858c2ba2c15387 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 30 Nov 2022 12:27:52 +0000 Subject: skin engine: Settings ID to pointer conversions Convert %St tag to operate on settings pointers instead of IDs. Change-Id: Iabf4c280be82b495a64b560b59620fb477e0c738 --- apps/gui/option_select.c | 6 ++---- apps/gui/option_select.h | 4 ++-- apps/gui/skin_engine/skin_display.c | 2 +- apps/gui/skin_engine/skin_parser.c | 16 +++++++++------- apps/gui/skin_engine/skin_tokens.c | 2 +- apps/gui/skin_engine/skin_touchsupport.c | 4 ++-- apps/gui/skin_engine/wps_internals.h | 3 ++- 7 files changed, 19 insertions(+), 18 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index afd97e418b..242b5294da 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -578,9 +578,8 @@ bool option_screen(const struct settings_list *setting, return false; } -int get_setting_info_for_bar(int setting_id, int *count, int *val) +int get_setting_info_for_bar(const struct settings_list *setting, 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; @@ -605,9 +604,8 @@ int get_setting_info_for_bar(int setting_id, int *count, int *val) } #ifdef HAVE_TOUCHSCREEN -void update_setting_value_from_touch(int setting_id, int selection) +void update_setting_value_from_touch(const struct settings_list *setting, int selection) { - const struct settings_list *setting = &settings[setting_id]; int new_val = selection_to_val(setting, selection); int var_type = setting->flags&F_T_MASK; diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index 104e86f64d..eabe5825e7 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h @@ -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(int setting_id, int *count, int *val); +int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val); #ifdef HAVE_TOUCHSCREEN -void update_setting_value_from_touch(int setting_id, int selection); +void update_setting_value_from_touch(const struct settings_list *setting, 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 43337049fd..9cc9e8c74d 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -212,7 +212,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_id, &count, &val); + get_setting_info_for_bar(pb->setting, &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 8ecbf7b7f9..435bad9e1f 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -803,14 +803,14 @@ static int parse_setting_and_lang(struct skin_element *element, */ (void)wps_data; char *temp = get_param_text(element, 0); - int i; if (token->type == SKIN_TOKEN_TRANSLATEDSTRING) { #ifndef __PCTOOL__ - i = lang_english_to_id(temp); + int i = lang_english_to_id(temp); if (i < 0) i = LANG_LAST_INDEX_IN_ARRAY; + token->value.i = i; #endif } else if (element->params_count > 1) @@ -823,12 +823,13 @@ static int parse_setting_and_lang(struct skin_element *element, else { #ifndef __PCTOOL__ - if (find_setting_by_cfgname(temp, &i) == NULL) + const struct settings_list *setting = find_setting_by_cfgname(temp, NULL); + if (!setting) return WPS_ERROR_INVALID_PARAM; + + token->value.xdata = (void *)setting; #endif } - /* Store the setting number */ - token->value.i = i; return 0; } @@ -972,7 +973,7 @@ static int parse_progressbar_tag(struct skin_element* element, pb->image = PTRTOSKINOFFSET(skin_buffer, NULL); pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL); pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL); - pb->setting_id = -1; + pb->setting = NULL; pb->invert_fill_direction = false; pb->horizontal = true; @@ -1157,7 +1158,8 @@ static int parse_progressbar_tag(struct skin_element* element, param++; text = SKINOFFSETTOPTR(skin_buffer, param->data.text); #ifndef __PCTOOL__ - if (find_setting_by_cfgname(text, &pb->setting_id) == NULL) + pb->setting = find_setting_by_cfgname(text, NULL); + if (!pb->setting) return WPS_ERROR_INVALID_PARAM; #endif } diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 39f1e3b4db..f6c166b140 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -1371,7 +1371,7 @@ const char *get_token_value(struct gui_wps *gwps, case SKIN_TOKEN_SETTING: { - const struct settings_list *s = settings+token->value.i; + const struct settings_list *s = token->value.xdata; if (intval) { /* Handle contionals */ diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index 77ab30d675..27b82e6608 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c @@ -313,9 +313,9 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) if (bar && edge_offset) { int val, count; - get_setting_info_for_bar(bar->setting_id, &count, &val); + get_setting_info_for_bar(bar->setting, &count, &val); val = *edge_offset * count / 1000; - update_setting_value_from_touch(bar->setting_id, val); + update_setting_value_from_touch(bar->setting, val); } } break; diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 6a5d3c27f9..6b9719282e 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -73,6 +73,7 @@ struct wps_token { unsigned short i; long l; OFFSETTYPE(void*) data; + void *xdata; } value; enum skin_token_type type; /* enough to store the token type */ @@ -131,7 +132,7 @@ struct progressbar { OFFSETTYPE(struct gui_img *) slider; bool horizontal; OFFSETTYPE(struct gui_img *) backdrop; - int setting_id; /* for the setting bar type */ + const struct settings_list *setting; }; -- cgit v1.2.3