summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c28
-rw-r--r--apps/gui/list.h10
-rw-r--r--apps/gui/option_select.c24
-rw-r--r--apps/gui/skin_engine/skin_engine.c10
-rw-r--r--apps/gui/skin_engine/skin_tokens.c58
-rw-r--r--apps/gui/usb_screen.c11
-rw-r--r--apps/gui/wps.c4
7 files changed, 104 insertions, 41 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 85046ead54..c119c4f193 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -51,6 +51,7 @@ void list_draw(struct screen *display, struct gui_synclist *list);
51 51
52static long last_dirty_tick; 52static long last_dirty_tick;
53static struct viewport parent[NB_SCREENS]; 53static struct viewport parent[NB_SCREENS];
54static struct gui_synclist *current_lists;
54 55
55static bool list_is_dirty(struct gui_synclist *list) 56static bool list_is_dirty(struct gui_synclist *list)
56{ 57{
@@ -160,7 +161,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
160 gui_list->nb_items = 0; 161 gui_list->nb_items = 0;
161 gui_list->selected_item = 0; 162 gui_list->selected_item = 0;
162 gui_synclist_init_display_settings(gui_list); 163 gui_synclist_init_display_settings(gui_list);
163
164#ifdef HAVE_TOUCHSCREEN 164#ifdef HAVE_TOUCHSCREEN
165 gui_list->y_pos = 0; 165 gui_list->y_pos = 0;
166#endif 166#endif
@@ -586,16 +586,19 @@ bool gui_synclist_keyclick_callback(int action, void* data)
586 * loop. 586 * loop.
587 * 587 *
588 * The GUI_EVENT_NEED_UI_UPDATE event is registered for in list_do_action_timeout() 588 * The GUI_EVENT_NEED_UI_UPDATE event is registered for in list_do_action_timeout()
589 * and unregistered in gui_synclict_do_button(). This is done because 589 * as a oneshot and current_lists updated. later current_lists is set to NULL
590 * if something is using the list UI they *must* be calling those 590 * in gui_synclist_do_button() effectively disabling the callback.
591* This is done because if something is using the list UI they *must* be calling those
591 * two functions in the correct order or the list wont work. 592 * two functions in the correct order or the list wont work.
592 */ 593 */
593static struct gui_synclist *current_lists; 594
594static bool ui_update_event_registered = false; 595static void _lists_uiviewport_update_callback(unsigned short id,
595static void _lists_uiviewport_update_callback(unsigned short id, void *data) 596 void *data, void *userdata)
596{ 597{
597 (void)id; 598 (void)id;
598 (void)data; 599 (void)data;
600 (void)userdata;
601
599 if (current_lists) 602 if (current_lists)
600 gui_synclist_draw(current_lists); 603 gui_synclist_draw(current_lists);
601} 604}
@@ -697,6 +700,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
697 case ACTION_TREE_PGRIGHT: 700 case ACTION_TREE_PGRIGHT:
698 gui_synclist_scroll_right(lists); 701 gui_synclist_scroll_right(lists);
699 gui_synclist_draw(lists); 702 gui_synclist_draw(lists);
703 yield();
700 return true; 704 return true;
701 case ACTION_TREE_ROOT_INIT: 705 case ACTION_TREE_ROOT_INIT:
702 /* After this button press ACTION_TREE_PGLEFT is allowed 706 /* After this button press ACTION_TREE_PGLEFT is allowed
@@ -724,6 +728,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
724 gui_synclist_draw(lists); 728 gui_synclist_draw(lists);
725 pgleft_allow_cancel = false; /* stop ACTION_TREE_PAGE_LEFT 729 pgleft_allow_cancel = false; /* stop ACTION_TREE_PAGE_LEFT
726 skipping to root */ 730 skipping to root */
731 yield();
727 return true; 732 return true;
728/* for pgup / pgdown, we are obliged to have a different behaviour depending 733/* for pgup / pgdown, we are obliged to have a different behaviour depending
729 * on the screen for which the user pressed the key since for example, remote 734 * on the screen for which the user pressed the key since for example, remote
@@ -769,13 +774,8 @@ int list_do_action_timeout(struct gui_synclist *lists, int timeout)
769/* Returns the lowest of timeout or the delay until a postponed 774/* Returns the lowest of timeout or the delay until a postponed
770 scheduled announcement is due (if any). */ 775 scheduled announcement is due (if any). */
771{ 776{
772 if (lists != current_lists) 777 add_event_ex(GUI_EVENT_NEED_UI_UPDATE, true, _lists_uiviewport_update_callback, NULL);
773 { 778 current_lists = lists;
774 if (!ui_update_event_registered)
775 ui_update_event_registered =
776 add_event(GUI_EVENT_NEED_UI_UPDATE, _lists_uiviewport_update_callback);
777 current_lists = lists;
778 }
779 if(lists->scheduled_talk_tick) 779 if(lists->scheduled_talk_tick)
780 { 780 {
781 long delay = lists->scheduled_talk_tick -current_tick +1; 781 long delay = lists->scheduled_talk_tick -current_tick +1;
@@ -944,7 +944,9 @@ bool simplelist_show_list(struct simplelist_info *info)
944 old_line_count = simplelist_line_count; 944 old_line_count = simplelist_line_count;
945 } 945 }
946 else if(default_event_handler(action) == SYS_USB_CONNECTED) 946 else if(default_event_handler(action) == SYS_USB_CONNECTED)
947 {
947 return true; 948 return true;
949 }
948 } 950 }
949 talk_shutup(); 951 talk_shutup();
950 952
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 40a27d1061..1060a3edde 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -134,7 +134,7 @@ struct list_selection_color
134 unsigned bg_color; 134 unsigned bg_color;
135 /* To enable: 135 /* To enable:
136 * call gui_synclist_set_sel_color(gui_synclist*, list_selection_color*) 136 * call gui_synclist_set_sel_color(gui_synclist*, list_selection_color*)
137 * If using the default viewport you should call 137 * If using the default viewport you should call
138 * gui_synclist_set_sel_color(gui_synclist*, NULL) when finished */ 138 * gui_synclist_set_sel_color(gui_synclist*, NULL) when finished */
139}; 139};
140#endif 140#endif
@@ -264,8 +264,8 @@ extern bool list_do_action(int context, int timeout,
264 264
265 265
266/** Simplelist implementation. 266/** Simplelist implementation.
267 USe this if you dont need to reimplement the list code, 267 USe this if you dont need to reimplement the list code,
268 and just need to show a list 268 and just need to show a list
269 **/ 269 **/
270 270
271struct simplelist_info { 271struct simplelist_info {
@@ -282,7 +282,7 @@ struct simplelist_info {
282 was exited with ACTION_STD_CANCEL */ 282 was exited with ACTION_STD_CANCEL */
283 int (*action_callback)(int action, struct gui_synclist *lists); /* can be NULL */ 283 int (*action_callback)(int action, struct gui_synclist *lists); /* can be NULL */
284 /* action_callback notes: 284 /* action_callback notes:
285 action == the action pressed by the user 285 action == the action pressed by the user
286 _after_ gui_synclist_do_button returns. 286 _after_ gui_synclist_do_button returns.
287 lists == the lists struct so the callback can get selection and count etc. */ 287 lists == the lists struct so the callback can get selection and count etc. */
288 enum themable_icons title_icon; 288 enum themable_icons title_icon;
@@ -312,7 +312,7 @@ void simplelist_set_line_count(int lines);
312/* get the current amount of lines shown */ 312/* get the current amount of lines shown */
313int simplelist_get_line_count(void); 313int simplelist_get_line_count(void);
314/* add a line in the list. */ 314/* add a line in the list. */
315void simplelist_addline(const char *fmt, ...); 315void simplelist_addline(const char *fmt, ...) ATTRIBUTE_PRINTF(1,2);
316 316
317/* setup the info struct. members not setup in this function need to be assigned manually 317/* setup the info struct. members not setup in this function need to be assigned manually
318 members set in this function: 318 members set in this function:
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 1ce7fd5026..65f2a0491d 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -219,10 +219,15 @@ static int option_talk(int selected_item, void * data)
219void option_select_next_val(const struct settings_list *setting, 219void option_select_next_val(const struct settings_list *setting,
220 bool previous, bool apply) 220 bool previous, bool apply)
221{ 221{
222 bool repeated = get_action_statuscode(NULL) & ACTION_REPEAT;
223
222 int val = 0; 224 int val = 0;
223 int *value = setting->setting; 225 int *value = setting->setting;
224 if (HASFLAG(setting, F_BOOL_SETTING)) 226 if (HASFLAG(setting, F_BOOL_SETTING))
225 { 227 {
228 if (repeated)
229 return;
230
226 *(bool*)value = !*(bool*)value; 231 *(bool*)value = !*(bool*)value;
227 if (apply && setting->bool_setting->option_callback) 232 if (apply && setting->bool_setting->option_callback)
228 setting->bool_setting->option_callback(*(bool*)value); 233 setting->bool_setting->option_callback(*(bool*)value);
@@ -236,13 +241,13 @@ void option_select_next_val(const struct settings_list *setting,
236 { 241 {
237 val = *value + info->step; 242 val = *value + info->step;
238 if (neg_step ? (val < info->max) : (val > info->max)) 243 if (neg_step ? (val < info->max) : (val > info->max))
239 val = info->min; 244 val = repeated ? *value : info->min;
240 } 245 }
241 else 246 else
242 { 247 {
243 val = *value - info->step; 248 val = *value - info->step;
244 if (neg_step ? (val > info->min) : (val < info->min)) 249 if (neg_step ? (val > info->min) : (val < info->min))
245 val = info->max; 250 val = repeated ? *value : info->max;
246 } 251 }
247 *value = val; 252 *value = val;
248 if (apply && info->option_callback) 253 if (apply && info->option_callback)
@@ -258,13 +263,13 @@ void option_select_next_val(const struct settings_list *setting,
258 { 263 {
259 val = *value + steps; 264 val = *value + steps;
260 if (val >= max) 265 if (val >= max)
261 val = min; 266 val = repeated ? *value : min;
262 } 267 }
263 else 268 else
264 { 269 {
265 val = *value - steps; 270 val = *value - steps;
266 if (val < min) 271 if (val < min)
267 val = max; 272 val = repeated ? *value : max;
268 } 273 }
269 *value = val; 274 *value = val;
270 if (apply) 275 if (apply)
@@ -277,13 +282,13 @@ void option_select_next_val(const struct settings_list *setting,
277 { 282 {
278 val = *value + 1; 283 val = *value + 1;
279 if (val >= info->count) 284 if (val >= info->count)
280 val = 0; 285 val = repeated ? *value : 0;
281 } 286 }
282 else 287 else
283 { 288 {
284 val = *value - 1; 289 val = *value - 1;
285 if (val < 0) 290 if (val < 0)
286 val = info->count-1; 291 val = repeated ? *value : info->count-1;
287 } 292 }
288 *value = val; 293 *value = val;
289 if (apply && info->option_callback) 294 if (apply && info->option_callback)
@@ -300,7 +305,11 @@ void option_select_next_val(const struct settings_list *setting,
300 (settings->flags&F_ALLOW_ARBITRARY_VALS && 305 (settings->flags&F_ALLOW_ARBITRARY_VALS &&
301 *value < tbl_info->values[i])) 306 *value < tbl_info->values[i]))
302 { 307 {
303 val = tbl_info->values[(i+add)%tbl_info->count]; 308 int index = (i+add)%tbl_info->count;
309 if (repeated && ((i == 0 && previous) || (!previous && i == tbl_info->count -1)))
310 val = *value;
311 else
312 val = tbl_info->values[index];
304 break; 313 break;
305 } 314 }
306 } 315 }
@@ -504,7 +513,6 @@ bool option_screen(const struct settings_list *setting,
504 title = P2STR(option_title); 513 title = P2STR(option_title);
505 514
506 gui_synclist_set_title(&lists, title, Icon_Questionmark); 515 gui_synclist_set_title(&lists, title, Icon_Questionmark);
507 gui_synclist_set_icon_callback(&lists, NULL);
508 if(global_settings.talk_menu) 516 if(global_settings.talk_menu)
509 gui_synclist_set_voice_callback(&lists, option_talk); 517 gui_synclist_set_voice_callback(&lists, option_talk);
510 518
diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c
index c007ed35d4..e11102ffe5 100644
--- a/apps/gui/skin_engine/skin_engine.c
+++ b/apps/gui/skin_engine/skin_engine.c
@@ -352,13 +352,13 @@ bool dbg_skin_engine(void)
352 struct skin_stats *stats = skin_get_stats(i, j); 352 struct skin_stats *stats = skin_get_stats(i, j);
353 if (stats->buflib_handles) 353 if (stats->buflib_handles)
354 { 354 {
355 simplelist_addline("Skin ID: %d, %d allocations", 355 simplelist_addline("Skin ID: %d, %zd allocations",
356 i, stats->buflib_handles); 356 i, stats->buflib_handles);
357 simplelist_addline("\tskin: %d bytes", 357 simplelist_addline("\tskin: %zd bytes",
358 stats->tree_size); 358 stats->tree_size);
359 simplelist_addline("\tImages: %d bytes", 359 simplelist_addline("\tImages: %zd bytes",
360 stats->images_size); 360 stats->images_size);
361 simplelist_addline("\tTotal: %d bytes", 361 simplelist_addline("\tTotal: %zd bytes",
362 stats->tree_size + stats->images_size); 362 stats->tree_size + stats->images_size);
363 total += stats->tree_size + stats->images_size; 363 total += stats->tree_size + stats->images_size;
364 } 364 }
@@ -375,7 +375,7 @@ bool dbg_skin_engine(void)
375 path += path_prefix_len; 375 path += path_prefix_len;
376 simplelist_addline("%s", path); 376 simplelist_addline("%s", path);
377 simplelist_addline("\tref_count: %d", ref_count); 377 simplelist_addline("\tref_count: %d", ref_count);
378 simplelist_addline("\tsize: %d", bytes); 378 simplelist_addline("\tsize: %zd", bytes);
379 total += bytes; 379 total += bytes;
380 } 380 }
381 } 381 }
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 42c56f7203..4bd1ffea31 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -66,6 +66,7 @@
66#include "fixedpoint.h" 66#include "fixedpoint.h"
67#endif 67#endif
68#include "list.h" 68#include "list.h"
69#include "option_select.h"
69#include "wps.h" 70#include "wps.h"
70 71
71#define NOINLINE __attribute__ ((noinline)) 72#define NOINLINE __attribute__ ((noinline))
@@ -73,7 +74,7 @@
73static const char* get_codectype(const struct mp3entry* id3) 74static const char* get_codectype(const struct mp3entry* id3)
74{ 75{
75 if (id3 && id3->codectype < AFMT_NUM_CODECS) { 76 if (id3 && id3->codectype < AFMT_NUM_CODECS) {
76 return audio_formats[id3->codectype].label; 77 return get_codec_string(id3->codectype);
77 } else { 78 } else {
78 return NULL; 79 return NULL;
79 } 80 }
@@ -555,20 +556,29 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
555 pid3 = state->nid3; 556 pid3 = state->nid3;
556 else 557 else
557 { 558 {
558 static char filename_buf[MAX_PATH + 1]; 559 static struct mp3entry tempid3; /* Note: path gets passed to outside fns */
559 fname = playlist_peek(offset, filename_buf, sizeof(filename_buf)); 560 memset(&tempid3, 0, sizeof(struct mp3entry));
561 /*static char filename_buf[MAX_PATH + 1];removed g#5926 */
562 fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path));
560 *filename = (char*)fname; 563 *filename = (char*)fname;
561 static struct mp3entry tempid3; 564
562 if ( 565 if (
563#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 566#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
564 tagcache_fill_tags(&tempid3, fname) || 567 tagcache_fill_tags(&tempid3, NULL) ||
565#endif 568#endif
566 audio_peek_track(&tempid3, offset) 569 audio_peek_track(&tempid3, offset)
567 ) 570 )
568 { 571 {
569 pid3 = &tempid3; 572 pid3 = &tempid3;
570 } 573 }
574 else /* failed */
575 {
576 /* ensure *filename gets the path, audio_peek_track() cleared it */
577 fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path));
578 *filename = (char*)fname;
579 }
571 } 580 }
581
572 return pid3; 582 return pid3;
573} 583}
574 584
@@ -658,6 +668,23 @@ static const char* NOINLINE get_lif_token_value(struct gui_wps *gwps,
658 return NULL; 668 return NULL;
659} 669}
660 670
671#ifdef HAVE_QUICKSCREEN
672static const char* get_qs_token_value(enum quickscreen_item item, bool data_token,
673 char *buf, int buf_size)
674{
675 const struct settings_list *qs_setting = global_settings.qs_items[item];
676
677 if (qs_setting == NULL)
678 return "ERR";
679
680 if (data_token)
681 return option_get_valuestring(qs_setting, buf, buf_size,
682 option_value_as_int(qs_setting));
683
684 return P2STR(ID2P(qs_setting->lang_id));
685}
686#endif
687
661/* Return the tags value as text. buf should be used as temp storage if needed. 688/* Return the tags value as text. buf should be used as temp storage if needed.
662 689
663 intval is used with conditionals/enums: when this function is called, 690 intval is used with conditionals/enums: when this function is called,
@@ -692,8 +719,6 @@ const char *get_token_value(struct gui_wps *gwps,
692 return NULL; 719 return NULL;
693 720
694 id3 = get_mp3entry_from_offset(token->next? 1: offset, &filename); 721 id3 = get_mp3entry_from_offset(token->next? 1: offset, &filename);
695 if (id3)
696 filename = id3->path;
697 722
698#if CONFIG_RTC 723#if CONFIG_RTC
699 struct tm* tm = NULL; 724 struct tm* tm = NULL;
@@ -1374,6 +1399,25 @@ const char *get_token_value(struct gui_wps *gwps,
1374 return NULL; 1399 return NULL;
1375#endif 1400#endif
1376 1401
1402#ifdef HAVE_QUICKSCREEN
1403 case SKIN_TOKEN_TOP_QUICKSETTING_NAME:
1404 return get_qs_token_value(QUICKSCREEN_TOP, false, buf, buf_size);
1405 case SKIN_TOKEN_TOP_QUICKSETTING_VALUE:
1406 return get_qs_token_value(QUICKSCREEN_TOP, true, buf, buf_size);
1407 case SKIN_TOKEN_RIGHT_QUICKSETTING_NAME:
1408 return get_qs_token_value(QUICKSCREEN_RIGHT, false, buf, buf_size);
1409 case SKIN_TOKEN_RIGHT_QUICKSETTING_VALUE:
1410 return get_qs_token_value(QUICKSCREEN_RIGHT, true, buf, buf_size);
1411 case SKIN_TOKEN_BOTTOM_QUICKSETTING_NAME:
1412 return get_qs_token_value(QUICKSCREEN_BOTTOM, false, buf, buf_size);
1413 case SKIN_TOKEN_BOTTOM_QUICKSETTING_VALUE:
1414 return get_qs_token_value(QUICKSCREEN_BOTTOM, true, buf, buf_size);
1415 case SKIN_TOKEN_LEFT_QUICKSETTING_NAME:
1416 return get_qs_token_value(QUICKSCREEN_LEFT, false, buf, buf_size);
1417 case SKIN_TOKEN_LEFT_QUICKSETTING_VALUE:
1418 return get_qs_token_value(QUICKSCREEN_LEFT, true, buf, buf_size);
1419#endif
1420
1377 case SKIN_TOKEN_SETTING: 1421 case SKIN_TOKEN_SETTING:
1378 { 1422 {
1379 const struct settings_list *s = token->value.xdata; 1423 const struct settings_list *s = token->value.xdata;
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index fb59f820b6..8a3510ea15 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -243,7 +243,13 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
243 243
244void gui_usb_screen_run(bool early_usb) 244void gui_usb_screen_run(bool early_usb)
245{ 245{
246 (void) early_usb; 246#ifdef SIMULATOR /* the sim allows toggling USB fast enough to overflow viewportmanagers stack */
247 static bool in_usb_screen = false;
248 if (in_usb_screen)
249 return;
250 in_usb_screen = true;
251#endif
252
247 struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; 253 struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS];
248#if defined HAVE_TOUCHSCREEN 254#if defined HAVE_TOUCHSCREEN
249 enum touchscreen_mode old_mode = touchscreen_get_mode(); 255 enum touchscreen_mode old_mode = touchscreen_get_mode();
@@ -334,4 +340,7 @@ void gui_usb_screen_run(bool early_usb)
334 } 340 }
335 341
336 pop_current_activity(); 342 pop_current_activity();
343#ifdef SIMULATOR
344 in_usb_screen = false;
345#endif
337} 346}
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 0de805bd02..82b0394a53 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -806,7 +806,7 @@ long gui_wps_show(void)
806 theme_enabled = false; 806 theme_enabled = false;
807 gwps_leave_wps(theme_enabled); 807 gwps_leave_wps(theme_enabled);
808 onplay(state->id3->path, 808 onplay(state->id3->path,
809 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 809 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION);
810 if (!audio_status()) 810 if (!audio_status())
811 { 811 {
812 /* re-enable theme since we're returning to SBS */ 812 /* re-enable theme since we're returning to SBS */
@@ -823,7 +823,7 @@ long gui_wps_show(void)
823 { 823 {
824 gwps_leave_wps(true); 824 gwps_leave_wps(true);
825 int retval = onplay(state->id3->path, 825 int retval = onplay(state->id3->path,
826 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 826 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey, ONPLAY_NO_CUSTOMACTION);
827 /* if music is stopped in the context menu we want to exit the wps */ 827 /* if music is stopped in the context menu we want to exit the wps */
828 if (retval == ONPLAY_MAINMENU 828 if (retval == ONPLAY_MAINMENU
829 || !audio_status()) 829 || !audio_status())