diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-07-28 12:53:22 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-07-28 12:53:22 +0000 |
commit | 969903b5fe3bc852b7bbda766bf1123a63bea5c1 (patch) | |
tree | f4714593a170e1fd1698bde4c15a9ba10e188309 | |
parent | bb618dbd84389a8625244e97c5f61addd7870810 (diff) | |
download | rockbox-969903b5fe3bc852b7bbda766bf1123a63bea5c1.tar.gz rockbox-969903b5fe3bc852b7bbda766bf1123a63bea5c1.zip |
Change the way the %Tl() (touch region) tag is done to remove dodgey 1-char settings.
check the manual...
%Tl(..., &action) -> %Tl(..., action, repeat_press)
%Tl(..., *action) -> %Tl(..., action, long_press)
%Tl(..., !action) -> %Tl(..., action, reverse_bar)
and a new allow_while_lock to make the region fire when softlocked
these options must all be after the action name, but otherwise the order doesnt matter. And for the setting_inc/dec/set action the setting name must follow the action name, *then* the options
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30219 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 168 | ||||
-rw-r--r-- | manual/appendix/wps_tags.tex | 15 | ||||
-rw-r--r-- | wps/cabbiev2.240x400x16.wps | 6 | ||||
-rw-r--r-- | wps/cabbiev2.320x240x16.mrobe500.wps | 4 | ||||
-rw-r--r-- | wps/cabbiev2.320x480x16.wps | 6 | ||||
-rw-r--r-- | wps/cabbiev2.480x800x16.wps | 6 | ||||
-rw-r--r-- | wps/cabbiev2.800x480x16.wps | 6 |
7 files changed, 105 insertions, 106 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 659d974130..53e1efedd8 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -1071,6 +1071,68 @@ static const struct touchaction touchactions[] = { | |||
1071 | #endif | 1071 | #endif |
1072 | }; | 1072 | }; |
1073 | 1073 | ||
1074 | static int touchregion_setup_setting(struct skin_element *element, int param_no, | ||
1075 | struct touchregion *region) | ||
1076 | { | ||
1077 | int p = param_no; | ||
1078 | char *name = element->params[p++].data.text; | ||
1079 | int j; | ||
1080 | /* Find the setting */ | ||
1081 | for (j=0; j<nb_settings; j++) | ||
1082 | if (settings[j].cfg_name && | ||
1083 | !strcmp(settings[j].cfg_name, name)) | ||
1084 | break; | ||
1085 | if (j==nb_settings) | ||
1086 | return WPS_ERROR_INVALID_PARAM; | ||
1087 | region->setting_data.setting = (void*)&settings[j]; | ||
1088 | if (region->action == ACTION_SETTINGS_SET) | ||
1089 | { | ||
1090 | char* text; | ||
1091 | int temp; | ||
1092 | struct touchsetting *setting = | ||
1093 | ®ion->setting_data; | ||
1094 | if (element->params_count < p+1) | ||
1095 | return -1; | ||
1096 | #ifndef __PCTOOL__ | ||
1097 | text = element->params[p++].data.text; | ||
1098 | switch (settings[j].flags&F_T_MASK) | ||
1099 | { | ||
1100 | case F_T_CUSTOM: | ||
1101 | setting->value.text = text; | ||
1102 | break; | ||
1103 | case F_T_INT: | ||
1104 | case F_T_UINT: | ||
1105 | if (settings[j].cfg_vals == NULL) | ||
1106 | { | ||
1107 | setting->value.number = atoi(text); | ||
1108 | } | ||
1109 | else if (cfg_string_to_int(j, &temp, text)) | ||
1110 | { | ||
1111 | if (settings[j].flags&F_TABLE_SETTING) | ||
1112 | setting->value.number = | ||
1113 | settings[j].table_setting->values[temp]; | ||
1114 | else | ||
1115 | setting->value.number = temp; | ||
1116 | } | ||
1117 | else | ||
1118 | return -1; | ||
1119 | break; | ||
1120 | case F_T_BOOL: | ||
1121 | if (cfg_string_to_int(j, &temp, text)) | ||
1122 | { | ||
1123 | setting->value.number = temp; | ||
1124 | } | ||
1125 | else | ||
1126 | return -1; | ||
1127 | break; | ||
1128 | default: | ||
1129 | return -1; | ||
1130 | } | ||
1131 | #endif /* __PCTOOL__ */ | ||
1132 | } | ||
1133 | return p-param_no; | ||
1134 | } | ||
1135 | |||
1074 | static int parse_touchregion(struct skin_element *element, | 1136 | static int parse_touchregion(struct skin_element *element, |
1075 | struct wps_token *token, | 1137 | struct wps_token *token, |
1076 | struct wps_data *wps_data) | 1138 | struct wps_data *wps_data) |
@@ -1082,7 +1144,6 @@ static int parse_touchregion(struct skin_element *element, | |||
1082 | const char *action; | 1144 | const char *action; |
1083 | const char pb_string[] = "progressbar"; | 1145 | const char pb_string[] = "progressbar"; |
1084 | const char vol_string[] = "volume"; | 1146 | const char vol_string[] = "volume"; |
1085 | char temp[20]; | ||
1086 | 1147 | ||
1087 | /* format: %T([label,], x,y,width,height,action[, ...]) | 1148 | /* format: %T([label,], x,y,width,height,action[, ...]) |
1088 | * if action starts with & the area must be held to happen | 1149 | * if action starts with & the area must be held to happen |
@@ -1125,39 +1186,13 @@ static int parse_touchregion(struct skin_element *element, | |||
1125 | region->allow_while_locked = false; | 1186 | region->allow_while_locked = false; |
1126 | action = element->params[p++].data.text; | 1187 | action = element->params[p++].data.text; |
1127 | 1188 | ||
1128 | strcpy(temp, action); | 1189 | /* figure out the action */ |
1129 | action = temp; | ||
1130 | |||
1131 | switch (*action) | ||
1132 | { | ||
1133 | case '!': | ||
1134 | region->reverse_bar = true; | ||
1135 | action++; | ||
1136 | break; | ||
1137 | case '^': | ||
1138 | action++; | ||
1139 | region->allow_while_locked = true; | ||
1140 | break; | ||
1141 | } | ||
1142 | if(!strcmp(pb_string, action)) | 1190 | if(!strcmp(pb_string, action)) |
1143 | region->action = ACTION_TOUCH_SCROLLBAR; | 1191 | region->action = ACTION_TOUCH_SCROLLBAR; |
1144 | else if(!strcmp(vol_string, action)) | 1192 | else if(!strcmp(vol_string, action)) |
1145 | region->action = ACTION_TOUCH_VOLUME; | 1193 | region->action = ACTION_TOUCH_VOLUME; |
1146 | else | 1194 | else |
1147 | { | 1195 | { |
1148 | if (*action == '*') | ||
1149 | { | ||
1150 | action++; | ||
1151 | region->press_length = LONG_PRESS; | ||
1152 | } | ||
1153 | else if(*action == '&') | ||
1154 | { | ||
1155 | action++; | ||
1156 | region->press_length = REPEAT; | ||
1157 | } | ||
1158 | else | ||
1159 | region->press_length = PRESS; | ||
1160 | |||
1161 | imax = ARRAYLEN(touchactions); | 1196 | imax = ARRAYLEN(touchactions); |
1162 | for (i = 0; i < imax; i++) | 1197 | for (i = 0; i < imax; i++) |
1163 | { | 1198 | { |
@@ -1169,68 +1204,13 @@ static int parse_touchregion(struct skin_element *element, | |||
1169 | region->action == ACTION_SETTINGS_DEC || | 1204 | region->action == ACTION_SETTINGS_DEC || |
1170 | region->action == ACTION_SETTINGS_SET) | 1205 | region->action == ACTION_SETTINGS_SET) |
1171 | { | 1206 | { |
1207 | int val; | ||
1172 | if (element->params_count < p+1) | 1208 | if (element->params_count < p+1) |
1173 | { | ||
1174 | return WPS_ERROR_INVALID_PARAM; | 1209 | return WPS_ERROR_INVALID_PARAM; |
1175 | } | 1210 | val = touchregion_setup_setting(element, p, region); |
1176 | else | 1211 | if (val < 0) |
1177 | { | 1212 | return WPS_ERROR_INVALID_PARAM; |
1178 | char *name = element->params[p].data.text; | 1213 | p += val; |
1179 | int j; | ||
1180 | /* Find the setting */ | ||
1181 | for (j=0; j<nb_settings; j++) | ||
1182 | if (settings[j].cfg_name && | ||
1183 | !strcmp(settings[j].cfg_name, name)) | ||
1184 | break; | ||
1185 | if (j==nb_settings) | ||
1186 | return WPS_ERROR_INVALID_PARAM; | ||
1187 | region->setting_data.setting = (void*)&settings[j]; | ||
1188 | if (region->action == ACTION_SETTINGS_SET) | ||
1189 | { | ||
1190 | char* text; | ||
1191 | int temp; | ||
1192 | struct touchsetting *setting = | ||
1193 | ®ion->setting_data; | ||
1194 | if (element->params_count < p+2) | ||
1195 | return WPS_ERROR_INVALID_PARAM; | ||
1196 | #ifndef __PCTOOL__ | ||
1197 | text = element->params[p+1].data.text; | ||
1198 | switch (settings[j].flags&F_T_MASK) | ||
1199 | { | ||
1200 | case F_T_CUSTOM: | ||
1201 | setting->value.text = text; | ||
1202 | break; | ||
1203 | case F_T_INT: | ||
1204 | case F_T_UINT: | ||
1205 | if (settings[j].cfg_vals == NULL) | ||
1206 | { | ||
1207 | setting->value.number = atoi(text); | ||
1208 | } | ||
1209 | else if (cfg_string_to_int(j, &temp, text)) | ||
1210 | { | ||
1211 | if (settings[j].flags&F_TABLE_SETTING) | ||
1212 | setting->value.number = | ||
1213 | settings[j].table_setting->values[temp]; | ||
1214 | else | ||
1215 | setting->value.number = temp; | ||
1216 | } | ||
1217 | else | ||
1218 | return WPS_ERROR_INVALID_PARAM; | ||
1219 | break; | ||
1220 | case F_T_BOOL: | ||
1221 | if (cfg_string_to_int(j, &temp, text)) | ||
1222 | { | ||
1223 | setting->value.number = temp; | ||
1224 | } | ||
1225 | else | ||
1226 | return WPS_ERROR_INVALID_PARAM; | ||
1227 | break; | ||
1228 | default: | ||
1229 | return WPS_ERROR_INVALID_PARAM; | ||
1230 | } | ||
1231 | #endif /* __PCTOOL__ */ | ||
1232 | } | ||
1233 | } | ||
1234 | } | 1214 | } |
1235 | break; | 1215 | break; |
1236 | } | 1216 | } |
@@ -1238,6 +1218,18 @@ static int parse_touchregion(struct skin_element *element, | |||
1238 | if (region->action == ACTION_NONE) | 1218 | if (region->action == ACTION_NONE) |
1239 | return WPS_ERROR_INVALID_PARAM; | 1219 | return WPS_ERROR_INVALID_PARAM; |
1240 | } | 1220 | } |
1221 | while (p < element->params_count) | ||
1222 | { | ||
1223 | char* param = element->params[p++].data.text; | ||
1224 | if (!strcmp(param, "allow_while_locked")) | ||
1225 | region->allow_while_locked = true; | ||
1226 | else if (!strcmp(param, "reverse_bar")) | ||
1227 | region->reverse_bar = true; | ||
1228 | else if (!strcmp(param, "repeat_press")) | ||
1229 | region->press_length = REPEAT; | ||
1230 | else if (!strcmp(param, "long_press")) | ||
1231 | region->press_length = LONG_PRESS; | ||
1232 | } | ||
1241 | struct skin_token_list *item = new_skin_token_list_item(NULL, region); | 1233 | struct skin_token_list *item = new_skin_token_list_item(NULL, region); |
1242 | if (!item) | 1234 | if (!item) |
1243 | return WPS_ERROR_INVALID_PARAM; | 1235 | return WPS_ERROR_INVALID_PARAM; |
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index ebd2a4c7ce..02561c5d6e 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex | |||
@@ -600,13 +600,11 @@ display cycling round the defined sublines. See | |||
600 | \opt{touchscreen}{ | 600 | \opt{touchscreen}{ |
601 | \section{Touchscreen Areas} | 601 | \section{Touchscreen Areas} |
602 | \begin{tagmap} | 602 | \begin{tagmap} |
603 | \config{\%T(x,y,width,\tabnlindent{}height,action)} | 603 | \config{\%T(x,y,width,\tabnlindent{}height, action, [options])} |
604 | & Invoke the action specified when the user presses in the defined | 604 | & Invoke the action specified when the user presses in the defined |
605 | touchscreen area.\\ | 605 | touchscreen area.\\ |
606 | \end{tagmap} | 606 | \end{tagmap} |
607 | If the action starts with \& then the area must be held and allows repeat presses (e.g. for seeking). | 607 | |
608 | If the action starts with * then the area must be held but the press only triggers once | ||
609 | (e.g. for switching a setting on a long press). | ||
610 | Possible actions are: | 608 | Possible actions are: |
611 | 609 | ||
612 | \begin{description} | 610 | \begin{description} |
@@ -636,6 +634,15 @@ display cycling round the defined sublines. See | |||
636 | \item[setting\_dec] -- Decrement the subsequently specified setting (e.g | 634 | \item[setting\_dec] -- Decrement the subsequently specified setting (e.g |
637 | \config{\%T(0,0, setting\_dec, volume)} decreases the volume by one step). | 635 | \config{\%T(0,0, setting\_dec, volume)} decreases the volume by one step). |
638 | \end{description} | 636 | \end{description} |
637 | Any (or muliple) of the following options can be used after the action is specified | ||
638 | \subsection{Options} | ||
639 | \begin{description} | ||
640 | \item[repeat_press] -- This region will trigger mulitple times when held (i.e for seeking) | ||
641 | \item[long_press] -- This region will trigger once after it is held for a long press | ||
642 | \item[reverse_bar] -- Reverse the bars touch direction (i.e seek right to left) | ||
643 | \item[allow_while_locked] -- Allows the region to be pressable when the | ||
644 | skin is locked by the lock touch action | ||
645 | \end{description} | ||
639 | 646 | ||
640 | \section{Last Touchscreen Press} | 647 | \section{Last Touchscreen Press} |
641 | \begin{tagmap} | 648 | \begin{tagmap} |
diff --git a/wps/cabbiev2.240x400x16.wps b/wps/cabbiev2.240x400x16.wps index 65b14804fa..72c77ec14f 100644 --- a/wps/cabbiev2.240x400x16.wps +++ b/wps/cabbiev2.240x400x16.wps | |||
@@ -50,7 +50,7 @@ | |||
50 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> | 50 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> |
51 | 51 | ||
52 | %T(206,0,24,24,play) | 52 | %T(206,0,24,24,play) |
53 | %T(206,0,24,24,&stop) | 53 | %T(206,0,24,24,stop, repeat) |
54 | %T(182,0,18,92,repmode) | 54 | %T(182,0,18,92,repmode) |
55 | %T(139,0,37,23,shuffle) | 55 | %T(139,0,37,23,shuffle) |
56 | %T(98,0,33,23,volume) | 56 | %T(98,0,33,23,volume) |
@@ -69,8 +69,8 @@ | |||
69 | %T(39,5,24,24,pitch) | 69 | %T(39,5,24,24,pitch) |
70 | %T(58,0,24,24,contextmenu) | 70 | %T(58,0,24,24,contextmenu) |
71 | %T(86,0,24,24,quickscreen) | 71 | %T(86,0,24,24,quickscreen) |
72 | %T(115,0,24,23,&rwd) | 72 | %T(115,0,24,23,rwd, repeat) |
73 | %T(144,0,24,23,&ffwd) | 73 | %T(144,0,24,23,ffwd, repeat) |
74 | %T(115,0,24,23,prev) | 74 | %T(115,0,24,23,prev) |
75 | %T(144,0,24,23,next) | 75 | %T(144,0,24,23,next) |
76 | 76 | ||
diff --git a/wps/cabbiev2.320x240x16.mrobe500.wps b/wps/cabbiev2.320x240x16.mrobe500.wps index 0d9e2cc0a2..0496418082 100644 --- a/wps/cabbiev2.320x240x16.mrobe500.wps +++ b/wps/cabbiev2.320x240x16.mrobe500.wps | |||
@@ -68,8 +68,8 @@ | |||
68 | %T(50,5,24,24,pitch) | 68 | %T(50,5,24,24,pitch) |
69 | %T(80,5,24,24,contextmenu) | 69 | %T(80,5,24,24,contextmenu) |
70 | %T(110,5,24,24,quickscreen) | 70 | %T(110,5,24,24,quickscreen) |
71 | %T(150,5,24,24,&rwd) | 71 | %T(150,5,24,24,rwd, repeat) |
72 | %T(175,5,24,24,&ffwd) | 72 | %T(175,5,24,24,ffwd, repeat) |
73 | %T(150,5,24,24,prev) | 73 | %T(150,5,24,24,prev) |
74 | %T(175,5,24,24,next) | 74 | %T(175,5,24,24,next) |
75 | %Vl(u,0,74,-,30,1) | 75 | %Vl(u,0,74,-,30,1) |
diff --git a/wps/cabbiev2.320x480x16.wps b/wps/cabbiev2.320x480x16.wps index 8bc4475a8e..3000d1a02d 100644 --- a/wps/cabbiev2.320x480x16.wps +++ b/wps/cabbiev2.320x480x16.wps | |||
@@ -80,7 +80,7 @@ | |||
80 | # playmode | 80 | # playmode |
81 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> | 81 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> |
82 | %T(273,66,45,50,play) | 82 | %T(273,66,45,50,play) |
83 | %T(273,66,45,50,&stop) | 83 | %T(273,66,45,50,stop, repeat) |
84 | 84 | ||
85 | # | 85 | # |
86 | # popup osd menu | 86 | # popup osd menu |
@@ -96,7 +96,7 @@ | |||
96 | # | 96 | # |
97 | %V(0,420,90,58,-) | 97 | %V(0,420,90,58,-) |
98 | %xd(H)%xd(I) | 98 | %xd(H)%xd(I) |
99 | %T(0,0,40,58,&rwd) | 99 | %T(0,0,40,58,rwd, repeat) |
100 | %T(0,0,40,58,prev) | 100 | %T(0,0,40,58,prev) |
101 | %T(50,0,40,58,&ffwd) | 101 | %T(50,0,40,58,ffwd, repeat) |
102 | %T(50,0,40,58,next) | 102 | %T(50,0,40,58,next) |
diff --git a/wps/cabbiev2.480x800x16.wps b/wps/cabbiev2.480x800x16.wps index 43e3ae3350..ee051adb52 100644 --- a/wps/cabbiev2.480x800x16.wps +++ b/wps/cabbiev2.480x800x16.wps | |||
@@ -81,7 +81,7 @@ | |||
81 | # playmode | 81 | # playmode |
82 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> | 82 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> |
83 | %T(400,119,70,75,play) | 83 | %T(400,119,70,75,play) |
84 | %T(400,119,70,75,&stop) | 84 | %T(400,119,70,75,stop, repeat) |
85 | 85 | ||
86 | # | 86 | # |
87 | # popup osd menu | 87 | # popup osd menu |
@@ -97,7 +97,7 @@ | |||
97 | # | 97 | # |
98 | %V(0,720,150,75,-) | 98 | %V(0,720,150,75,-) |
99 | %xd(H)%xd(I) | 99 | %xd(H)%xd(I) |
100 | %T(0,0,70,75,&rwd) | 100 | %T(0,0,70,75,rwd, repeat) |
101 | %T(0,0,70,75,prev) | 101 | %T(0,0,70,75,prev) |
102 | %T(70,0,70,75,&ffwd) | 102 | %T(70,0,70,75,ffwd, repeat) |
103 | %T(70,0,70,75,next) | 103 | %T(70,0,70,75,next) |
diff --git a/wps/cabbiev2.800x480x16.wps b/wps/cabbiev2.800x480x16.wps index 0a9df79417..4f302caaf2 100644 --- a/wps/cabbiev2.800x480x16.wps +++ b/wps/cabbiev2.800x480x16.wps | |||
@@ -77,7 +77,7 @@ | |||
77 | %xl(F,playmode-800x480x16.bmp,0,0,5) | 77 | %xl(F,playmode-800x480x16.bmp,0,0,5) |
78 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> | 78 | %?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)> |
79 | %T(0,0,70,70,play) | 79 | %T(0,0,70,70,play) |
80 | %T(0,0,70,70,&stop) | 80 | %T(0,0,70,70,stop, repeat) |
81 | 81 | ||
82 | # | 82 | # |
83 | # popup osd menu | 83 | # popup osd menu |
@@ -96,7 +96,7 @@ | |||
96 | %xl(H,rew-800x480x16.bmp,0,5) | 96 | %xl(H,rew-800x480x16.bmp,0,5) |
97 | %xl(I,ff-800x480x16.bmp,80,5) | 97 | %xl(I,ff-800x480x16.bmp,80,5) |
98 | %xd(H)%xd(I) | 98 | %xd(H)%xd(I) |
99 | %T(0,0,70,75,&rwd) | 99 | %T(0,0,70,75,rwd, repeat) |
100 | %T(0,0,70,75,prev) | 100 | %T(0,0,70,75,prev) |
101 | %T(80,0,70,75,&ffwd) | 101 | %T(80,0,70,75,ffwd, repeat) |
102 | %T(80,0,70,75,next) | 102 | %T(80,0,70,75,next) |