summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-11-30 12:27:52 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-04 11:19:57 -0500
commit1e6c8d2ea684e8a8e7a5f2cc08858c2ba2c15387 (patch)
tree5be985909f1c985f6f433d8934c92ad91f6aa0d4
parent4ff97ae07c9b7beed4c8c9bf965e2ba679d05a20 (diff)
downloadrockbox-1e6c8d2ea684e8a8e7a5f2cc08858c2ba2c15387.tar.gz
rockbox-1e6c8d2ea684e8a8e7a5f2cc08858c2ba2c15387.zip
skin engine: Settings ID to pointer conversions
Convert %St tag to operate on settings pointers instead of IDs. Change-Id: Iabf4c280be82b495a64b560b59620fb477e0c738
-rw-r--r--apps/gui/option_select.c6
-rw-r--r--apps/gui/option_select.h4
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_parser.c16
-rw-r--r--apps/gui/skin_engine/skin_tokens.c2
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c4
-rw-r--r--apps/gui/skin_engine/wps_internals.h3
7 files changed, 19 insertions, 18 deletions
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,
578 return false; 578 return false;
579} 579}
580 580
581int get_setting_info_for_bar(int setting_id, int *count, int *val) 581int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val)
582{ 582{
583 const struct settings_list *setting = &settings[setting_id];
584 int var_type = setting->flags&F_T_MASK; 583 int var_type = setting->flags&F_T_MASK;
585 void (*function)(int) = NULL; 584 void (*function)(int) = NULL;
586 int oldvalue; 585 int oldvalue;
@@ -605,9 +604,8 @@ int get_setting_info_for_bar(int setting_id, int *count, int *val)
605} 604}
606 605
607#ifdef HAVE_TOUCHSCREEN 606#ifdef HAVE_TOUCHSCREEN
608void update_setting_value_from_touch(int setting_id, int selection) 607void update_setting_value_from_touch(const struct settings_list *setting, int selection)
609{ 608{
610 const struct settings_list *setting = &settings[setting_id];
611 int new_val = selection_to_val(setting, selection); 609 int new_val = selection_to_val(setting, selection);
612 int var_type = setting->flags&F_T_MASK; 610 int var_type = setting->flags&F_T_MASK;
613 611
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
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(int setting_id, int *count, int *val); 49int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val);
50#ifdef HAVE_TOUCHSCREEN 50#ifdef HAVE_TOUCHSCREEN
51void update_setting_value_from_touch(int setting_id, int selection); 51void update_setting_value_from_touch(const struct settings_list *setting, 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 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,
212 else if (pb->type == SKIN_TOKEN_SETTINGBAR) 212 else if (pb->type == SKIN_TOKEN_SETTINGBAR)
213 { 213 {
214 int val, count; 214 int val, count;
215 get_setting_info_for_bar(pb->setting_id, &count, &val); 215 get_setting_info_for_bar(pb->setting, &count, &val);
216 length = count - 1; 216 length = count - 1;
217 end = val; 217 end = val;
218 } 218 }
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,
803 */ 803 */
804 (void)wps_data; 804 (void)wps_data;
805 char *temp = get_param_text(element, 0); 805 char *temp = get_param_text(element, 0);
806 int i;
807 806
808 if (token->type == SKIN_TOKEN_TRANSLATEDSTRING) 807 if (token->type == SKIN_TOKEN_TRANSLATEDSTRING)
809 { 808 {
810#ifndef __PCTOOL__ 809#ifndef __PCTOOL__
811 i = lang_english_to_id(temp); 810 int i = lang_english_to_id(temp);
812 if (i < 0) 811 if (i < 0)
813 i = LANG_LAST_INDEX_IN_ARRAY; 812 i = LANG_LAST_INDEX_IN_ARRAY;
813 token->value.i = i;
814#endif 814#endif
815 } 815 }
816 else if (element->params_count > 1) 816 else if (element->params_count > 1)
@@ -823,12 +823,13 @@ static int parse_setting_and_lang(struct skin_element *element,
823 else 823 else
824 { 824 {
825#ifndef __PCTOOL__ 825#ifndef __PCTOOL__
826 if (find_setting_by_cfgname(temp, &i) == NULL) 826 const struct settings_list *setting = find_setting_by_cfgname(temp, NULL);
827 if (!setting)
827 return WPS_ERROR_INVALID_PARAM; 828 return WPS_ERROR_INVALID_PARAM;
829
830 token->value.xdata = (void *)setting;
828#endif 831#endif
829 } 832 }
830 /* Store the setting number */
831 token->value.i = i;
832 return 0; 833 return 0;
833} 834}
834 835
@@ -972,7 +973,7 @@ static int parse_progressbar_tag(struct skin_element* element,
972 pb->image = PTRTOSKINOFFSET(skin_buffer, NULL); 973 pb->image = PTRTOSKINOFFSET(skin_buffer, NULL);
973 pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL); 974 pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL);
974 pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL); 975 pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL);
975 pb->setting_id = -1; 976 pb->setting = NULL;
976 pb->invert_fill_direction = false; 977 pb->invert_fill_direction = false;
977 pb->horizontal = true; 978 pb->horizontal = true;
978 979
@@ -1157,7 +1158,8 @@ static int parse_progressbar_tag(struct skin_element* element,
1157 param++; 1158 param++;
1158 text = SKINOFFSETTOPTR(skin_buffer, param->data.text); 1159 text = SKINOFFSETTOPTR(skin_buffer, param->data.text);
1159#ifndef __PCTOOL__ 1160#ifndef __PCTOOL__
1160 if (find_setting_by_cfgname(text, &pb->setting_id) == NULL) 1161 pb->setting = find_setting_by_cfgname(text, NULL);
1162 if (!pb->setting)
1161 return WPS_ERROR_INVALID_PARAM; 1163 return WPS_ERROR_INVALID_PARAM;
1162#endif 1164#endif
1163 } 1165 }
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,
1371 1371
1372 case SKIN_TOKEN_SETTING: 1372 case SKIN_TOKEN_SETTING:
1373 { 1373 {
1374 const struct settings_list *s = settings+token->value.i; 1374 const struct settings_list *s = token->value.xdata;
1375 if (intval) 1375 if (intval)
1376 { 1376 {
1377 /* Handle contionals */ 1377 /* 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)
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_id, &count, &val); 316 get_setting_info_for_bar(bar->setting, &count, &val);
317 val = *edge_offset * count / 1000; 317 val = *edge_offset * count / 1000;
318 update_setting_value_from_touch(bar->setting_id, val); 318 update_setting_value_from_touch(bar->setting, 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 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 {
73 unsigned short i; 73 unsigned short i;
74 long l; 74 long l;
75 OFFSETTYPE(void*) data; 75 OFFSETTYPE(void*) data;
76 void *xdata;
76 } value; 77 } value;
77 78
78 enum skin_token_type type; /* enough to store the token type */ 79 enum skin_token_type type; /* enough to store the token type */
@@ -131,7 +132,7 @@ struct progressbar {
131 OFFSETTYPE(struct gui_img *) slider; 132 OFFSETTYPE(struct gui_img *) slider;
132 bool horizontal; 133 bool horizontal;
133 OFFSETTYPE(struct gui_img *) backdrop; 134 OFFSETTYPE(struct gui_img *) backdrop;
134 int setting_id; /* for the setting bar type */ 135 const struct settings_list *setting;
135 136
136}; 137};
137 138