diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-11-16 09:38:15 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-11-16 09:38:15 +0000 |
commit | 76d2dd9c0ed0c4f105c4cdd18f1c110cfcb4d9d5 (patch) | |
tree | 23b7d234e8b9c4199025427fda7d0a1128cd7d27 /apps/gui | |
parent | db5965ff9e615d6eadcf7819d2518f7944bc35c6 (diff) | |
download | rockbox-76d2dd9c0ed0c4f105c4cdd18f1c110cfcb4d9d5.tar.gz rockbox-76d2dd9c0ed0c4f105c4cdd18f1c110cfcb4d9d5.zip |
FS#9477 - new WPS tag (%mo) which lets the WPS have different "modes" which are changed with the usual "back to browser" button (This button is ONLY stolen if the WPS you use uses this tag.
an example use:
%?mo<one|two|three>
meaning that when the WPS is first opened "one" will be displayed, pressing select will change it to showing two, pressing it again will show three, and once more will go back to showing one. The text there could be any wps tags (conditional viewports for example...)
There is no real limit on the amount of modes, but remember that if you create a WPS which uses this tag more than once that every use HAS to have the same amount of choices or bad things will happen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19110 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 10 | ||||
-rw-r--r-- | apps/gui/gwps.c | 27 | ||||
-rw-r--r-- | apps/gui/gwps.h | 7 | ||||
-rw-r--r-- | apps/gui/wps_debug.c | 3 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 14 |
5 files changed, 53 insertions, 8 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index a81b8555f7..e40aa772cb 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -1394,6 +1394,16 @@ static const char *get_token_value(struct gui_wps *gwps, | |||
1394 | token->value.i)) | 1394 | token->value.i)) |
1395 | return "v"; | 1395 | return "v"; |
1396 | return NULL; | 1396 | return NULL; |
1397 | case WPS_TOKEN_VIEWMODE: | ||
1398 | if (intval) | ||
1399 | { | ||
1400 | if (data->current_mode > limit) | ||
1401 | data->current_mode = 1; | ||
1402 | *intval = data->current_mode; | ||
1403 | } | ||
1404 | snprintf(buf, buf_size, "%d", data->current_mode); | ||
1405 | return buf; | ||
1406 | |||
1397 | default: | 1407 | default: |
1398 | return NULL; | 1408 | return NULL; |
1399 | } | 1409 | } |
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 9b6d6b5558..bac5032440 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -136,7 +136,7 @@ long gui_wps_show(void) | |||
136 | bool update_track = false; | 136 | bool update_track = false; |
137 | int i; | 137 | int i; |
138 | long last_left = 0, last_right = 0; | 138 | long last_left = 0, last_right = 0; |
139 | 139 | bool isremote = false; | |
140 | wps_state_init(); | 140 | wps_state_init(); |
141 | 141 | ||
142 | #ifdef HAVE_LCD_CHARCELLS | 142 | #ifdef HAVE_LCD_CHARCELLS |
@@ -234,7 +234,10 @@ long gui_wps_show(void) | |||
234 | #else | 234 | #else |
235 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); | 235 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); |
236 | #endif | 236 | #endif |
237 | 237 | #if NB_SCREENS > 1 | |
238 | isremote = get_action_statuscode(NULL)&ACTION_REMOTE; | ||
239 | #endif | ||
240 | |||
238 | /* Exit if audio has stopped playing. This can happen if using the | 241 | /* Exit if audio has stopped playing. This can happen if using the |
239 | sleep timer with the charger plugged or if starting a recording | 242 | sleep timer with the charger plugged or if starting a recording |
240 | from F1 */ | 243 | from F1 */ |
@@ -292,13 +295,23 @@ long gui_wps_show(void) | |||
292 | break; | 295 | break; |
293 | 296 | ||
294 | case ACTION_WPS_BROWSE: | 297 | case ACTION_WPS_BROWSE: |
298 | if (gui_wps[isremote?1:0].data->current_mode > -1) | ||
299 | { | ||
300 | /* will get set to 0 eventually again in wps_parser.c */ | ||
301 | gui_wps[isremote?1:0].data->current_mode = | ||
302 | gui_wps[isremote?1:0].data->current_mode+1; | ||
303 | restore = true; | ||
304 | } | ||
305 | else | ||
306 | { | ||
295 | #ifdef HAVE_LCD_CHARCELLS | 307 | #ifdef HAVE_LCD_CHARCELLS |
296 | status_set_record(false); | 308 | status_set_record(false); |
297 | status_set_audio(false); | 309 | status_set_audio(false); |
298 | #endif | 310 | #endif |
299 | FOR_NB_SCREENS(i) | 311 | FOR_NB_SCREENS(i) |
300 | gui_wps[i].display->stop_scroll(); | 312 | gui_wps[i].display->stop_scroll(); |
301 | return GO_TO_PREVIOUS_BROWSER; | 313 | return GO_TO_PREVIOUS_BROWSER; |
314 | } | ||
302 | break; | 315 | break; |
303 | 316 | ||
304 | /* play/pause */ | 317 | /* play/pause */ |
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index 6a4849c347..a414ca3986 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -295,7 +295,10 @@ enum wps_token_type { | |||
295 | WPS_VIEWPORT_ENABLE, | 295 | WPS_VIEWPORT_ENABLE, |
296 | 296 | ||
297 | /* buttons */ | 297 | /* buttons */ |
298 | WPS_TOKEN_BUTTON_VOLUME | 298 | WPS_TOKEN_BUTTON_VOLUME, |
299 | |||
300 | WPS_TOKEN_VIEWMODE | ||
301 | |||
299 | }; | 302 | }; |
300 | 303 | ||
301 | struct wps_token { | 304 | struct wps_token { |
@@ -429,6 +432,8 @@ struct wps_data | |||
429 | 432 | ||
430 | /* tick the volume button was last pressed */ | 433 | /* tick the volume button was last pressed */ |
431 | unsigned int button_time_volume; | 434 | unsigned int button_time_volume; |
435 | /* the current mode (used with %mo tag), -1 means modes not being used */ | ||
436 | char current_mode; | ||
432 | }; | 437 | }; |
433 | 438 | ||
434 | /* initial setup of wps_data */ | 439 | /* initial setup of wps_data */ |
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index 5a18218a52..ad595e305a 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c | |||
@@ -435,6 +435,9 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data, | |||
435 | snprintf(buf, bufsize, "Volume button timeout:%d", | 435 | snprintf(buf, bufsize, "Volume button timeout:%d", |
436 | token->value.i); | 436 | token->value.i); |
437 | break; | 437 | break; |
438 | case WPS_TOKEN_VIEWMODE: | ||
439 | snprintf(buf, bufsize, "viewmode"); | ||
440 | break; | ||
438 | default: | 441 | default: |
439 | snprintf(buf, bufsize, "FIXME (code: %d)", | 442 | snprintf(buf, bufsize, "FIXME (code: %d)", |
440 | token->type); | 443 | token->type); |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 1b845c9f8a..f421a0c8d4 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -162,6 +162,8 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
162 | static int parse_albumart_conditional(const char *wps_bufptr, | 162 | static int parse_albumart_conditional(const char *wps_bufptr, |
163 | struct wps_token *token, struct wps_data *wps_data); | 163 | struct wps_token *token, struct wps_data *wps_data); |
164 | #endif /* HAVE_ALBUMART */ | 164 | #endif /* HAVE_ALBUMART */ |
165 | static int parse_viewmode(const char *wps_bufptr, | ||
166 | struct wps_token *token, struct wps_data *wps_data); | ||
165 | 167 | ||
166 | #ifdef CONFIG_RTC | 168 | #ifdef CONFIG_RTC |
167 | #define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC | 169 | #define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC |
@@ -281,6 +283,8 @@ static const struct wps_tag all_tags[] = { | |||
281 | { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL }, | 283 | { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL }, |
282 | { WPS_TOKEN_BUTTON_VOLUME, "mv", WPS_REFRESH_DYNAMIC, | 284 | { WPS_TOKEN_BUTTON_VOLUME, "mv", WPS_REFRESH_DYNAMIC, |
283 | parse_timeout }, | 285 | parse_timeout }, |
286 | { WPS_TOKEN_VIEWMODE, "mo", WPS_REFRESH_STATIC, | ||
287 | parse_viewmode }, | ||
284 | 288 | ||
285 | #ifdef HAVE_LCD_BITMAP | 289 | #ifdef HAVE_LCD_BITMAP |
286 | { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL }, | 290 | { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL }, |
@@ -1142,6 +1146,15 @@ static int parse_albumart_conditional(const char *wps_bufptr, | |||
1142 | }; | 1146 | }; |
1143 | #endif /* HAVE_ALBUMART */ | 1147 | #endif /* HAVE_ALBUMART */ |
1144 | 1148 | ||
1149 | static int parse_viewmode(const char *wps_bufptr, | ||
1150 | struct wps_token *token, | ||
1151 | struct wps_data *wps_data) | ||
1152 | { | ||
1153 | (void)wps_bufptr; (void)token; | ||
1154 | wps_data->current_mode = 1; | ||
1155 | /* are we going to add parameters? */ | ||
1156 | return 0; | ||
1157 | } | ||
1145 | /* Parse a generic token from the given string. Return the length read */ | 1158 | /* Parse a generic token from the given string. Return the length read */ |
1146 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) | 1159 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) |
1147 | { | 1160 | { |
@@ -1476,6 +1489,7 @@ void wps_data_init(struct wps_data *wps_data) | |||
1476 | wps_data->full_line_progressbar = false; | 1489 | wps_data->full_line_progressbar = false; |
1477 | #endif | 1490 | #endif |
1478 | wps_data->button_time_volume = 0; | 1491 | wps_data->button_time_volume = 0; |
1492 | wps_data->current_mode = -1; | ||
1479 | wps_data->wps_loaded = false; | 1493 | wps_data->wps_loaded = false; |
1480 | } | 1494 | } |
1481 | 1495 | ||