summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps.c149
-rw-r--r--apps/gui/gwps.h3
-rw-r--r--apps/gui/viewport.c3
3 files changed, 62 insertions, 93 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index d928bc3e64..4dc463be35 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -65,6 +65,25 @@
65#include "viewport.h" 65#include "viewport.h"
66#include "pcmbuf.h" 66#include "pcmbuf.h"
67 67
68#define GWPS_INSTANT_RESTORE 0
69
70static void gwps_leave_wps(void)
71{
72 int oldbars = VP_SB_HIDE_ALL;
73
74 if (global_settings.statusbar)
75 oldbars = VP_SB_ALLSCREENS;
76
77 viewportmanager_set_statusbar(oldbars);
78#if LCD_DEPTH > 1
79 show_main_backdrop();
80#endif
81#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
82 show_remote_main_backdrop();
83#endif
84}
85
86static int wpsbars;
68/* currently only one wps_state is needed */ 87/* currently only one wps_state is needed */
69struct wps_state wps_state; 88struct wps_state wps_state;
70struct gui_wps gui_wps[NB_SCREENS]; 89struct gui_wps gui_wps[NB_SCREENS];
@@ -147,38 +166,47 @@ static void play_hop(int direction)
147#endif 166#endif
148} 167}
149 168
150static int fix_wps_bars(void) 169void gwps_fix_statusbars(void)
151{ 170{
152#ifdef HAVE_LCD_BITMAP 171#ifdef HAVE_LCD_BITMAP
153 int i; 172 int i;
154 int wpsbars = VP_SB_HIDE_ALL; 173 wpsbars = VP_SB_HIDE_ALL;
155 FOR_NB_SCREENS(i) 174 FOR_NB_SCREENS(i)
156 { 175 {
157 bool draw = global_settings.statusbar; 176 bool draw = false;
158 if (gui_wps[i].data->wps_sb_tag) 177 if (gui_wps[i].data->wps_sb_tag)
159 draw = gui_wps[i].data->show_sb_on_wps; 178 draw = gui_wps[i].data->show_sb_on_wps;
160 if (draw) 179 if (draw)
161 wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i)); 180 wpsbars |= (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
162 } 181 }
163 return wpsbars;
164#else 182#else
165 return VP_SB_ALLSCREENS; 183 wpsbars = VP_SB_ALLSCREENS;
166#endif 184#endif
167} 185}
168 186
187
188/* The WPS can be left in two ways:
189 * a) call a function, which draws over the wps. In this case, the wps
190 * will be still active (i.e. the below function didn't return)
191 * b) return with a value evaluated by root_menu.c, in this case the wps
192 * is really left, and root_menu will handle the next screen
193 *
194 * In either way, call gwps_leave_wps(), in order to restore the correct
195 * "main screen" backdrops and statusbars
196 */
169long gui_wps_show(void) 197long gui_wps_show(void)
170{ 198{
171 long button = 0; 199 long button = 0;
172 bool restore = false; 200 bool restore = false;
173 long restoretimer = 0; /* timer to delay screen redraw temporarily */ 201 long restoretimer = GWPS_INSTANT_RESTORE; /* timer to delay screen redraw temporarily */
174 bool exit = false; 202 bool exit = false;
175 bool bookmark = false; 203 bool bookmark = false;
176 bool update_track = false; 204 bool update_track = false;
177 int i; 205 int i;
178 long last_left = 0, last_right = 0; 206 long last_left = 0, last_right = 0;
179 int wpsbars, oldbars;
180 207
181 wps_state_init(); 208 wps_state_init();
209 gwps_fix_statusbars();
182 210
183#ifdef HAVE_LCD_CHARCELLS 211#ifdef HAVE_LCD_CHARCELLS
184 status_set_audio(true); 212 status_set_audio(true);
@@ -197,8 +225,6 @@ long gui_wps_show(void)
197 ab_repeat_init(); 225 ab_repeat_init();
198 ab_reset_markers(); 226 ab_reset_markers();
199#endif 227#endif
200
201 oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
202 if(audio_status() & AUDIO_STATUS_PLAY) 228 if(audio_status() & AUDIO_STATUS_PLAY)
203 { 229 {
204 wps_state.id3 = audio_current_track(); 230 wps_state.id3 = audio_current_track();
@@ -210,8 +236,6 @@ long gui_wps_show(void)
210 236
211 restore = true; 237 restore = true;
212 } 238 }
213 wpsbars = fix_wps_bars();
214 viewportmanager_set_statusbar(wpsbars);
215 239
216 while ( 1 ) 240 while ( 1 )
217 { 241 {
@@ -270,12 +294,11 @@ long gui_wps_show(void)
270 294
271 /* The peak meter is disabled 295 /* The peak meter is disabled
272 -> no additional screen updates needed */ 296 -> no additional screen updates needed */
273 else { 297 else
298#endif
299 {
274 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); 300 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
275 } 301 }
276#else
277 button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5);
278#endif
279 302
280 /* Exit if audio has stopped playing. This can happen if using the 303 /* Exit if audio has stopped playing. This can happen if using the
281 sleep timer with the charger plugged or if starting a recording 304 sleep timer with the charger plugged or if starting a recording
@@ -310,28 +333,14 @@ long gui_wps_show(void)
310 { 333 {
311 case ACTION_WPS_CONTEXT: 334 case ACTION_WPS_CONTEXT:
312 { 335 {
313#if LCD_DEPTH > 1 336 gwps_leave_wps();
314 show_main_backdrop();
315#endif
316#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
317 show_remote_main_backdrop();
318#endif
319 viewportmanager_set_statusbar(oldbars);
320 /* if music is stopped in the context menu we want to exit the wps */ 337 /* if music is stopped in the context menu we want to exit the wps */
321 if (onplay(wps_state.id3->path, 338 if (onplay(wps_state.id3->path,
322 FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU 339 FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU
323 || !audio_status()) 340 || !audio_status())
324 return GO_TO_ROOT; 341 return GO_TO_ROOT;
325 viewportmanager_set_statusbar(wpsbars);
326 /* track might have changed */ 342 /* track might have changed */
327 update_track = true; 343 update_track = true;
328
329#if LCD_DEPTH > 1
330 show_wps_backdrop();
331#endif
332#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
333 show_remote_wps_backdrop();
334#endif
335 restore = true; 344 restore = true;
336 } 345 }
337 break; 346 break;
@@ -577,23 +586,9 @@ long gui_wps_show(void)
577#ifdef HAVE_QUICKSCREEN 586#ifdef HAVE_QUICKSCREEN
578 case ACTION_WPS_QUICKSCREEN: 587 case ACTION_WPS_QUICKSCREEN:
579 { 588 {
580 viewportmanager_set_statusbar(oldbars); 589 gwps_leave_wps();
581#if LCD_DEPTH > 1
582 show_main_backdrop();
583#endif
584#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
585 show_remote_main_backdrop();
586#endif
587 if (quick_screen_quick(button)) 590 if (quick_screen_quick(button))
588 return SYS_USB_CONNECTED; 591 return SYS_USB_CONNECTED;
589 wpsbars = fix_wps_bars();
590 viewportmanager_set_statusbar(wpsbars);
591#if LCD_DEPTH > 1
592 show_wps_backdrop();
593#endif
594#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
595 show_remote_wps_backdrop();
596#endif
597 restore = true; 592 restore = true;
598 } 593 }
599 break; 594 break;
@@ -603,18 +598,10 @@ long gui_wps_show(void)
603#ifdef BUTTON_F3 598#ifdef BUTTON_F3
604 case ACTION_F3: 599 case ACTION_F3:
605 { 600 {
606 viewportmanager_set_statusbar(oldbars); 601 gwps_leave_wps();
607#if LCD_DEPTH > 1
608 show_main_backdrop();
609#endif
610#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
611 show_remote_main_backdrop();
612#endif
613 if (quick_screen_f3(BUTTON_F3)) 602 if (quick_screen_f3(BUTTON_F3))
614 return SYS_USB_CONNECTED; 603 return SYS_USB_CONNECTED;
615 restore = true; 604 restore = true;
616 wpsbars = fix_wps_bars();
617 viewportmanager_set_statusbar(wpsbars);
618 } 605 }
619 break; 606 break;
620#endif /* BUTTON_F3 */ 607#endif /* BUTTON_F3 */
@@ -623,23 +610,10 @@ long gui_wps_show(void)
623#ifdef HAVE_PITCHSCREEN 610#ifdef HAVE_PITCHSCREEN
624 case ACTION_WPS_PITCHSCREEN: 611 case ACTION_WPS_PITCHSCREEN:
625 { 612 {
626 viewportmanager_set_statusbar(oldbars); 613 gwps_leave_wps();
627#if LCD_DEPTH > 1
628 show_main_backdrop();
629#endif
630#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
631 show_remote_main_backdrop();
632#endif
633 if (1 == gui_syncpitchscreen_run()) 614 if (1 == gui_syncpitchscreen_run())
634 return SYS_USB_CONNECTED; 615 return SYS_USB_CONNECTED;
635#if LCD_DEPTH > 1
636 show_wps_backdrop();
637#endif
638#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
639 show_remote_wps_backdrop();
640#endif
641 restore = true; 616 restore = true;
642 viewportmanager_set_statusbar(wpsbars);
643 } 617 }
644 break; 618 break;
645#endif /* HAVE_PITCHSCREEN */ 619#endif /* HAVE_PITCHSCREEN */
@@ -665,22 +639,9 @@ long gui_wps_show(void)
665 639
666 case ACTION_WPS_ID3SCREEN: 640 case ACTION_WPS_ID3SCREEN:
667 { 641 {
668 viewportmanager_set_statusbar(oldbars); 642 gwps_leave_wps();
669#if LCD_DEPTH > 1
670 show_main_backdrop();
671#endif
672#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
673 show_remote_main_backdrop();
674#endif
675 browse_id3(); 643 browse_id3();
676#if LCD_DEPTH > 1
677 show_wps_backdrop();
678#endif
679#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
680 show_remote_wps_backdrop();
681#endif
682 restore = true; 644 restore = true;
683 viewportmanager_set_statusbar(wpsbars);
684 } 645 }
685 break; 646 break;
686 647
@@ -697,13 +658,7 @@ long gui_wps_show(void)
697 break; 658 break;
698#endif 659#endif
699 case SYS_POWEROFF: 660 case SYS_POWEROFF:
700 viewportmanager_set_statusbar(oldbars); 661 gwps_leave_wps();
701#if LCD_DEPTH > 1
702 show_main_backdrop();
703#endif
704#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
705 show_remote_main_backdrop();
706#endif
707 default_event_handler(SYS_POWEROFF); 662 default_event_handler(SYS_POWEROFF);
708 break; 663 break;
709 664
@@ -725,18 +680,26 @@ long gui_wps_show(void)
725 } 680 }
726 681
727 if (restore && 682 if (restore &&
728 ((restoretimer == 0) || 683 ((restoretimer == GWPS_INSTANT_RESTORE) ||
729 (restoretimer < current_tick))) 684 TIME_AFTER(restore, current_tick)))
730 { 685 {
686 /* restore wps backrops and statusbars */
687#if LCD_DEPTH > 1
688 show_wps_backdrop();
689#endif
690#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
691 show_remote_wps_backdrop();
692#endif
693 viewportmanager_set_statusbar(wpsbars);
731 restore = false; 694 restore = false;
732 restoretimer = 0; 695 restoretimer = GWPS_INSTANT_RESTORE;
733 if (gui_wps_display()) { 696 if (gui_wps_display()) {
734 exit = true; 697 exit = true;
735 } 698 }
736 } 699 }
737 700
738 if (exit) { 701 if (exit) {
739 viewportmanager_set_statusbar(oldbars); 702 gwps_leave_wps();
740#ifdef HAVE_LCD_CHARCELLS 703#ifdef HAVE_LCD_CHARCELLS
741 status_set_record(false); 704 status_set_record(false);
742 status_set_audio(false); 705 status_set_audio(false);
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index ecf39ef774..70725df40b 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -440,6 +440,9 @@ bool wps_data_load(struct wps_data *wps_data,
440 const char *buf, 440 const char *buf,
441 bool isfile); 441 bool isfile);
442 442
443/* Sets up the statusbars for the wps and each screen */
444void gwps_fix_statusbars(void);
445
443/* Returns the index of the subline in the subline array 446/* Returns the index of the subline in the subline array
444 line - 0-based line number 447 line - 0-based line number
445 subline - 0-based subline number within the line 448 subline - 0-based subline number within the line
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 480c37a044..bc1ce8e9d3 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -34,6 +34,7 @@
34#include "statusbar.h" 34#include "statusbar.h"
35#include "screen_access.h" 35#include "screen_access.h"
36#include "appevents.h" 36#include "appevents.h"
37#include "gwps.h"
37 38
38static int statusbar_enabled = 0; 39static int statusbar_enabled = 0;
39 40
@@ -123,6 +124,8 @@ void viewportmanager_draw_statusbars(void* data)
123{ 124{
124 (void)data; 125 (void)data;
125 int i; 126 int i;
127
128 gwps_fix_statusbars();
126 FOR_NB_SCREENS(i) 129 FOR_NB_SCREENS(i)
127 { 130 {
128 if (showing_bars(i)) 131 if (showing_bars(i))