diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-11-27 15:48:28 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-11-27 15:48:28 -0500 |
commit | 5954a2fd4854522364893480c98a5ae25e2fb7eb (patch) | |
tree | aef82b709f969b3631d2db6efcbc8b5b53043849 | |
parent | cb478d9d3fd477758f8dd570cf11547ba64c8dd1 (diff) | |
download | rockbox-5954a2fd48.tar.gz rockbox-5954a2fd48.zip |
runtime info add type to clear time dialog switch to simple_list
its nice to know which item you are clearing
simplelist does most of the background stuff for us
Change-Id: Ia2a2a92cecbb38d92297705ca1015aba2f81f18f
-rw-r--r-- | apps/screens.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/apps/screens.c b/apps/screens.c index fe851ad04c..e9c8cb6bf6 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -861,8 +861,13 @@ static const char* runtime_get_data(int selected_item, void* data, long t; switch (selected_item) { - case 0: return str(LANG_RUNNING_TIME); - case 1: t = global_status.runtime; break; + case 0:return str(LANG_RUNNING_TIME); + case 1: { + global_status.runtime += ((current_tick - lasttime) / HZ); + lasttime = current_tick; + t = global_status.runtime; + break; + } case 2: return str(LANG_TOP_TIME); case 3: t = global_status.topruntime; break; default: @@ -876,57 +881,52 @@ static const char* runtime_get_data(int selected_item, void* data, static int runtime_speak_data(int selected_item, void* data) { - (void) data; - talk_ids(false, - (selected_item < 2) ? LANG_RUNNING_TIME : LANG_TOP_TIME, + (void)data; + talk_ids(false,(selected_item < 2) ? LANG_RUNNING_TIME : LANG_TOP_TIME, TALK_ID((selected_item < 2) ? global_status.runtime - : global_status.topruntime, UNIT_TIME)); + : global_status.topruntime, UNIT_TIME)); return 0; } - -int view_runtime(void) +static int runtime_info_cb(int action, struct gui_synclist *lists) { - static const char *lines[]={ID2P(LANG_CLEAR_TIME)}; - static const struct text_message message={lines, 1}; - bool say_runtime = true; + static const char *lines[]={ ID2P(LANG_RUNNING_TIME), ID2P(LANG_CLEAR_TIME), + ID2P(LANG_TOP_TIME), ID2P(LANG_CLEAR_TIME)}; - struct gui_synclist lists; - int action; - gui_synclist_init(&lists, runtime_get_data, NULL, false, 2, NULL); - gui_synclist_set_title(&lists, str(LANG_RUNNING_TIME), NOICON); - if(global_settings.talk_menu) - gui_synclist_set_voice_callback(&lists, runtime_speak_data); - gui_synclist_set_nb_items(&lists, 4); + if (action == ACTION_NONE) + return ACTION_REDRAW; - while(1) - { - global_status.runtime += ((current_tick - lasttime) / HZ); + if(action == ACTION_STD_OK) { + int selected = (gui_synclist_get_sel_pos(lists)); + + const struct text_message message={lines + selected, 2}; - lasttime = current_tick; - if (say_runtime) + if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) { - gui_synclist_speak_item(&lists); - say_runtime = false; + if (selected == 0) + global_status.runtime = 0; + else /*selected == 2*/ + global_status.topruntime = 0; + gui_synclist_speak_item(lists); } - gui_synclist_draw(&lists); - list_do_action(CONTEXT_STD, HZ, &lists, &action); - if(action == ACTION_STD_CANCEL) - break; - if(action == ACTION_STD_OK) { - if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) - { - if (!(gui_synclist_get_sel_pos(&lists)/2)) - global_status.runtime = 0; - else - global_status.topruntime = 0; - say_runtime = true; - } - } - if(default_event_handler(action) == SYS_USB_CONNECTED) - return 1; + action = ACTION_REDRAW; } - return 0; + return action; +} + +int view_runtime(void) +{ + struct simplelist_info info; + + simplelist_info_init(&info, NULL, 2, NULL); + info.get_name = runtime_get_data; + info.action_callback = runtime_info_cb; + info.timeout = HZ; + info.selection_size = 2; + if(global_settings.talk_menu) + info.get_talk = runtime_speak_data; + info.scroll_all = true; + return simplelist_show_list(&info); } #ifdef HAVE_TOUCHSCREEN |