summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/SOURCES6
-rw-r--r--apps/gui/gwps-common.c2
-rw-r--r--apps/gui/gwps.c4
-rw-r--r--apps/gui/gwps.h1
-rw-r--r--apps/gui/option_select.c102
-rw-r--r--apps/gui/option_select.h119
-rw-r--r--apps/gui/quickscreen.c179
-rw-r--r--apps/gui/quickscreen.h114
-rw-r--r--apps/gui/select.c78
-rw-r--r--apps/gui/select.h33
-rw-r--r--apps/gui/statusbar.h5
-rw-r--r--apps/screen_access.c7
-rw-r--r--apps/screen_access.h3
-rw-r--r--apps/screens.c420
-rw-r--r--apps/screens.h14
-rw-r--r--apps/tree.c7
-rw-r--r--apps/tree.h1
17 files changed, 719 insertions, 376 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index a93e7cf4ff..c4eee62714 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -32,14 +32,16 @@ filetree.c
32 32
33screen_access.c 33screen_access.c
34gui/buttonbar.c 34gui/buttonbar.c
35gui/gwps.c
36gui/gwps-common.c
35gui/icon.c 37gui/icon.c
36gui/list.c 38gui/list.c
39gui/option_select.c
40gui/quickscreen.c
37gui/scrollbar.c 41gui/scrollbar.c
38gui/select.c 42gui/select.c
39gui/splash.c 43gui/splash.c
40gui/statusbar.c 44gui/statusbar.c
41gui/gwps.c
42gui/gwps-common.c
43gui/textarea.c 45gui/textarea.c
44gui/yesno.c 46gui/yesno.c
45 47
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 16f3a6f2cc..4eee5f7ba1 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -61,7 +61,7 @@ static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force)
61{ 61{
62 bool draw = global_settings.statusbar; 62 bool draw = global_settings.statusbar;
63 if(wps->data->wps_sb_tag 63 if(wps->data->wps_sb_tag
64 && gui_wps->data->show_sb_on_wps) 64 && wps->data->show_sb_on_wps)
65 draw = true; 65 draw = true;
66 else if(wps->data->wps_sb_tag) 66 else if(wps->data->wps_sb_tag)
67 draw = false; 67 draw = false;
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index a93750770f..52340e6547 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -509,7 +509,7 @@ long gui_wps_show(void)
509#ifdef WPS_RC_QUICK 509#ifdef WPS_RC_QUICK
510 case WPS_RC_QUICK: 510 case WPS_RC_QUICK:
511#endif 511#endif
512 if (quick_screen(CONTEXT_WPS, WPS_QUICK)) 512 if (quick_screen_quick())
513 return SYS_USB_CONNECTED; 513 return SYS_USB_CONNECTED;
514 restore = true; 514 restore = true;
515 lastbutton = 0; 515 lastbutton = 0;
@@ -518,7 +518,7 @@ long gui_wps_show(void)
518 /* screen settings */ 518 /* screen settings */
519#ifdef BUTTON_F3 519#ifdef BUTTON_F3
520 case BUTTON_F3: 520 case BUTTON_F3:
521 if (quick_screen(CONTEXT_WPS, BUTTON_F3)) 521 if (quick_screen_f3())
522 return SYS_USB_CONNECTED; 522 return SYS_USB_CONNECTED;
523 restore = true; 523 restore = true;
524 break; 524 break;
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index dfae7c34e2..66199bcfc4 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -68,6 +68,7 @@
68#define WPS_RC_BROWSE (BUTTON_RC_MENU | BUTTON_REL) 68#define WPS_RC_BROWSE (BUTTON_RC_MENU | BUTTON_REL)
69#define WPS_RC_BROWSE_PRE BUTTON_RC_MENU 69#define WPS_RC_BROWSE_PRE BUTTON_RC_MENU
70#define WPS_RC_CONTEXT (BUTTON_RC_MENU | BUTTON_REPEAT) 70#define WPS_RC_CONTEXT (BUTTON_RC_MENU | BUTTON_REPEAT)
71#define WPS_RC_QUICK (BUTTON_RC_MODE | BUTTON_REPEAT)
71 72
72#elif CONFIG_KEYPAD == RECORDER_PAD 73#elif CONFIG_KEYPAD == RECORDER_PAD
73#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL) 74#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
new file mode 100644
index 0000000000..0e169617c4
--- /dev/null
+++ b/apps/gui/option_select.c
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "option_select.h"
21#include "sprintf.h"
22#include "kernel.h"
23#include "lang.h"
24
25void option_select_init_numeric(struct option_select * opt,
26 const char * title,
27 int init_value,
28 int min_value,
29 int max_value,
30 int step,
31 const char * unit,
32 option_formatter *formatter)
33{
34 opt->title=title;
35 opt->min_value=min_value;
36 opt->max_value=max_value+1;
37 opt->option=init_value;
38 opt->step=step;
39 opt->extra_string=unit;
40 opt->formatter=formatter;
41 opt->items=NULL;
42 opt->limit_loop=false;
43}
44
45void option_select_init_items(struct option_select * opt,
46 const char * title,
47 int selected,
48 const struct opt_items * items,
49 int nb_items)
50{
51 opt->title=title;
52 opt->min_value=0;
53 opt->max_value=nb_items;
54 opt->option=selected;
55 opt->step=1;
56 opt->formatter=NULL;
57 opt->items=items;
58 opt->limit_loop=false;
59}
60
61void option_select_next(struct option_select * opt)
62{
63 if(opt->option + opt->step >= opt->max_value)
64 {
65 if(!opt->limit_loop)
66 {
67 if(opt->option==opt->max_value-1)
68 opt->option=opt->min_value;
69 else
70 opt->option=opt->max_value-1;
71 }
72 }
73 else
74 opt->option+=opt->step;
75}
76
77void option_select_prev(struct option_select * opt)
78{
79 if(opt->option - opt->step < opt->min_value)
80 {
81 if(!opt->limit_loop)
82 {
83 if(opt->option==opt->min_value)
84 opt->option=opt->max_value-1;
85 else
86 opt->option=opt->min_value;
87 }
88 }
89 else
90 opt->option-=opt->step;
91}
92
93const char * option_select_get_text(struct option_select * opt, char * buffer)
94{
95 if(opt->items)
96 return(P2STR(opt->items[opt->option].string));
97 if(!opt->formatter)
98 snprintf(buffer, sizeof buffer,"%d %s", opt->option, opt->extra_string);
99 else
100 opt->formatter(buffer, sizeof buffer, opt->option, opt->extra_string);
101 return(buffer);
102}
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
new file mode 100644
index 0000000000..c6a5e196f0
--- /dev/null
+++ b/apps/gui/option_select.h
@@ -0,0 +1,119 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _GUI_OPTION_SELECT_H_
21#define _GUI_OPTION_SELECT_H_
22#include "settings.h"
23
24typedef void option_formatter(char* dest, int dest_length,
25 int variable, const char* unit);
26
27struct option_select
28{
29 const char * title;
30 int min_value;
31 int max_value;
32 int step;
33 int option;
34 const char * extra_string;
35 /* In the case the option is a number */
36 option_formatter *formatter;
37 const struct opt_items * items;
38 bool limit_loop;
39};
40
41/*
42 * Initializes an option containing a numeric values
43 * - title : the title of the option
44 * - init_value : the initial value the number will be
45 * - min_value, max_value : bounds to the value
46 * - step : the ammount you want to add / withdraw to the initial number
47 * each time a key is pressed
48 * - unit : the unit in which the value is (ex "s", "bytes", ...)
49 * - formatter : a callback function that generates a string
50 * from the number it gets
51 */
52extern void option_select_init_numeric(struct option_select * opt,
53 const char * title,
54 int init_value,
55 int min_value,
56 int max_value,
57 int step,
58 const char * unit,
59 option_formatter *formatter);
60
61/*
62 * Initializes an option containing a list of choices
63 * - title : the title of the option
64 * - selected : the initially selected item
65 * - items : the list of items, defined in settings.h
66 * - nb_items : the number of items in the 'items' list
67 */
68extern void option_select_init_items(struct option_select * opt,
69 const char * title,
70 int selected,
71 const struct opt_items * items,
72 int nb_items);
73
74/*
75 * Gets the selected option
76 * - opt : the option struct
77 * - buffer : a buffer to eventually format the option
78 * Returns the selected option
79 */
80extern const char * option_select_get_text(struct option_select * opt, char * buffer);
81
82/*
83 * Selects the next value
84 * - opt : the option struct
85 */
86extern void option_select_next(struct option_select * opt);
87
88/*
89 * Selects the previous value
90 * - opt : the option struct
91 */
92extern void option_select_prev(struct option_select * opt);
93
94/*
95 * Returns the selected number
96 * - opt : the option struct
97 */
98#define option_select_get_selected(_opt) \
99 (_opt)->option
100
101/*
102 * Returns the title
103 * - opt : the option struct
104 */
105#define option_select_get_title(_opt) \
106 (_opt)->title
107
108/*
109 * Tells the option selector wether it should stop when reaching the min/max value
110 * or should continue (by going to max/min)
111 * - opt : the option struct
112 * - scroll :
113 * - true : stops when reaching min/max
114 * - false : continues to go to max/min when reaching min/max
115 */
116#define option_select_limit_loop(_opt, loop) \
117 (_opt)->limit_loop=loop
118
119#endif /* _GUI_OPTION_SELECT_H_ */
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
new file mode 100644
index 0000000000..760c1bdb00
--- /dev/null
+++ b/apps/gui/quickscreen.c
@@ -0,0 +1,179 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "quickscreen.h"
21#ifdef HAS_QUICKSCREEN
22
23#include "icons.h"
24#include "textarea.h"
25#include "font.h"
26#include "kernel.h"
27#include "misc.h"
28#include "statusbar.h"
29
30void gui_quickscreen_init(struct gui_quickscreen * qs,
31 struct option_select *left_option,
32 struct option_select *bottom_option,
33 struct option_select *right_option,
34 char * left_right_title,
35 quickscreen_callback callback)
36{
37 qs->left_option=left_option;
38 qs->bottom_option=bottom_option;
39 qs->right_option=right_option;
40 qs->left_right_title=left_right_title;
41 qs->callback=callback;
42}
43
44void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display)
45{
46 int w,h;
47 char buffer[30];
48 const char * option;
49 const char * title;
50#ifdef HAS_BUTTONBAR
51 display->has_buttonbar=false;
52#endif
53 gui_textarea_clear(display);
54 display->getstringsize("M",&w,&h);
55 /* Displays the icons */
56 display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
57 display->width/2 - 16,
58 display->height/2 - 4, 7, 8);
59 display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
60 display->width/2 - 3,
61 display->height - h*3, 7, 8);
62 display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
63 display->width/2 + 8,
64 display->height/2 - 4, 7, 8);
65 display->setfont(FONT_SYSFIXED);
66
67 /* Displays the left's text */
68 title=option_select_get_title(qs->left_option);
69 option=option_select_get_text(qs->left_option, buffer);
70 display->putsxy(0, display->height/2 - h*2, title);
71 display->putsxy(0, display->height/2 - h, qs->left_right_title);
72 display->putsxy(0, display->height/2, option);
73
74 /* Displays the bottom's text */
75 title=option_select_get_title(qs->bottom_option);
76 option=option_select_get_text(qs->bottom_option, buffer);
77 display->getstringsize(title, &w, &h);
78 display->putsxy((display->width-w)/2, display->height - h*2, title);
79 display->getstringsize(option, &w, &h);
80 display->putsxy((display->width-w)/2, display->height - h, option);
81
82 /* Displays the right's text */
83 title=option_select_get_title(qs->right_option);
84 option=option_select_get_text(qs->right_option, buffer);
85 display->getstringsize(title,&w,&h);
86 display->putsxy(display->width - w, display->height/2 - h*2, title);
87 display->getstringsize(qs->left_right_title,&w,&h);
88 display->putsxy(display->width - w, display->height/2 - h, qs->left_right_title);
89 display->getstringsize(option,&w,&h);
90 display->putsxy(display->width - w, display->height/2, option);
91
92 gui_textarea_update(display);
93 lcd_setfont(FONT_UI);
94}
95
96void gui_syncquickscreen_draw(struct gui_quickscreen * qs)
97{
98 int i;
99 FOR_NB_SCREENS(i)
100 gui_quickscreen_draw(qs, &screens[i]);
101}
102
103bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
104{
105 switch(button)
106 {
107 case QUICKSCREEN_LEFT :
108 case QUICKSCREEN_LEFT | BUTTON_REPEAT :
109#ifdef QUICKSCREEN_RC_LEFT
110 case QUICKSCREEN_RC_LEFT :
111 case QUICKSCREEN_RC_LEFT | BUTTON_REPEAT :
112#endif
113 option_select_next(qs->left_option);
114 return(true);
115
116 case QUICKSCREEN_BOTTOM :
117 case QUICKSCREEN_BOTTOM | BUTTON_REPEAT :
118#ifdef QUICKSCREEN_RC_BOTTOM
119 case QUICKSCREEN_RC_BOTTOM :
120 case QUICKSCREEN_RC_BOTTOM | BUTTON_REPEAT :
121#endif
122 option_select_next(qs->bottom_option);
123 return(true);
124
125 case QUICKSCREEN_RIGHT :
126 case QUICKSCREEN_RIGHT | BUTTON_REPEAT :
127#ifdef QUICKSCREEN_RC_RIGHT
128 case QUICKSCREEN_RC_RIGHT :
129 case QUICKSCREEN_RC_RIGHT | BUTTON_REPEAT :
130#endif
131 option_select_next(qs->right_option);
132 return(true);
133
134 case QUICKSCREEN_BOTTOM_INV :
135 case QUICKSCREEN_BOTTOM_INV | BUTTON_REPEAT :
136#ifdef QUICKSCREEN_RC_BOTTOM_INV
137 case QUICKSCREEN_RC_BOTTOM_INV :
138 case QUICKSCREEN_RC_BOTTOM_INV | BUTTON_REPEAT :
139#endif
140 option_select_prev(qs->bottom_option);
141 return(true);
142 }
143 return(false);
144}
145
146bool gui_syncquickscreen_run(struct gui_quickscreen * qs)
147{
148 int key;
149 gui_syncquickscreen_draw(qs);
150 while (true) {
151 key = button_get(true);
152 if(default_event_handler(key) == SYS_USB_CONNECTED)
153 return(true);
154 if(gui_quickscreen_do_button(qs, key))
155 {
156 if(qs->callback)
157 qs->callback(qs);
158 gui_syncquickscreen_draw(qs);
159 }
160 else if(key==QUICKSCREEN_QUIT
161#ifdef QUICKSCREEN_QUIT
162 || key==QUICKSCREEN_QUIT
163#endif
164#ifdef QUICKSCREEN_QUIT2
165 || key==QUICKSCREEN_QUIT2
166#endif
167#if QUICKSCREEN_RC_QUIT
168 || key==QUICKSCREEN_RC_QUIT
169#endif
170 )
171 {
172 return(false);
173 }
174 gui_syncstatusbar_draw(&statusbars, false);
175 }
176}
177
178#endif /* HAS_QUICKSCREEN */
179
diff --git a/apps/gui/quickscreen.h b/apps/gui/quickscreen.h
new file mode 100644
index 0000000000..09a0390d93
--- /dev/null
+++ b/apps/gui/quickscreen.h
@@ -0,0 +1,114 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "button.h"
20#include "config.h"
21#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\
22 (CONFIG_KEYPAD == IRIVER_H300_PAD)
23
24#ifndef _GUI_QUICKSCREEN_H_
25#define _GUI_QUICKSCREEN_H_
26
27#define HAS_QUICKSCREEN
28
29#include "option_select.h"
30#include "screen_access.h"
31
32#define QUICKSCREEN_LEFT BUTTON_LEFT
33#define QUICKSCREEN_BOTTOM BUTTON_DOWN
34#define QUICKSCREEN_BOTTOM_INV BUTTON_UP
35#define QUICKSCREEN_RIGHT BUTTON_RIGHT
36
37#if CONFIG_KEYPAD == RECORDER_PAD
38#define QUICKSCREEN_QUIT BUTTON_F2
39#define QUICKSCREEN_QUIT2 BUTTON_F3
40#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
41#define QUICKSCREEN_QUIT BUTTON_MODE
42#define QUICKSCREEN_QUIT2 BUTTON_OFF
43#define QUICKSCREEN_RC_QUIT BUTTON_RC_MODE
44#ifdef CONFIG_REMOTE_KEYPAD
45#define QUICKSCREEN_RC_LEFT BUTTON_RC_REW
46#define QUICKSCREEN_RC_BOTTOM BUTTON_RC_VOL_DOWN
47#define QUICKSCREEN_RC_BOTTOM_INV BUTTON_RC_VOL_UP
48#define QUICKSCREEN_RC_RIGHT BUTTON_RC_FF
49#endif
50
51#endif
52
53struct gui_quickscreen;
54/*
55 * Callback function called each time the quickscreen gets modified
56 * - qs : the quickscreen that did the modification
57 */
58typedef void (quickscreen_callback)(struct gui_quickscreen * qs);
59
60struct gui_quickscreen
61{
62 struct option_select *left_option;
63 struct option_select *bottom_option;
64 struct option_select *right_option;
65 char * left_right_title;
66 quickscreen_callback *callback;
67};
68
69/*
70 * Initializes a quickscreen
71 * - qs : the quickscreen
72 * - left_option, bottom_option, right_option : a list of choices
73 * for each option
74 * - left_right_title : the 2nd line of the title
75 * on the left and on the right
76 * - callback : a callback function called each time the quickscreen
77 * gets modified
78 */
79void gui_quickscreen_init(struct gui_quickscreen * qs,
80 struct option_select *left_option,
81 struct option_select *bottom_option,
82 struct option_select *right_option,
83 char * left_right_title,
84 quickscreen_callback *callback);
85/*
86 * Draws the quickscreen on a given screen
87 * - qs : the quickscreen
88 * - display : the screen to draw on
89 */
90void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display);
91
92/*
93 * Does the actions associated to the given button if any
94 * - qs : the quickscreen
95 * - button : the key we are going to analyse
96 * returns : true if the button corresponded to an action, false otherwise
97 */
98bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button);
99
100/*
101 * Draws the quickscreen on all available screens
102 * - qs : the quickscreen
103 */
104void gui_syncquickscreen_draw(struct gui_quickscreen * qs);
105
106/*
107 * Runs the quickscreen on all available screens
108 * - qs : the quickscreen
109 * returns : true if usb was connected, false otherwise
110 */
111bool gui_syncquickscreen_run(struct gui_quickscreen * qs);
112
113#endif /*_GUI_QUICK_SCREEN_H_*/
114#endif /* CONFIG_KEYPAD */
diff --git a/apps/gui/select.c b/apps/gui/select.c
index 5cde812a2f..b632177fd7 100644
--- a/apps/gui/select.c
+++ b/apps/gui/select.c
@@ -21,9 +21,9 @@
21 21
22#include "lang.h" 22#include "lang.h"
23#include "textarea.h" 23#include "textarea.h"
24#include "sprintf.h"
25#include "kernel.h"
26#include "screen_access.h" 24#include "screen_access.h"
25#include "kernel.h"
26
27 27
28void gui_select_init_numeric(struct gui_select * select, 28void gui_select_init_numeric(struct gui_select * select,
29 const char * title, 29 const char * title,
@@ -32,23 +32,12 @@ void gui_select_init_numeric(struct gui_select * select,
32 int max_value, 32 int max_value,
33 int step, 33 int step,
34 const char * unit, 34 const char * unit,
35 void (*formatter)(char* dest, 35 option_formatter *formatter)
36 int dest_length,
37 int variable,
38 const char* unit)
39 )
40{ 36{
41 select->canceled=false; 37 select->canceled=false;
42 select->validated=false; 38 select->validated=false;
43 select->title=title; 39 option_select_init_numeric(&select->options, title, init_value,
44 select->min_value=min_value; 40 min_value, max_value, step, unit, formatter);
45 select->max_value=max_value+1;
46 select->option=init_value;
47 select->step=step;
48 select->extra_string=unit;
49 select->formatter=formatter;
50 select->items=NULL;
51 select->limit_loop=false;
52} 41}
53 42
54void gui_select_init_items(struct gui_select * select, 43void gui_select_init_items(struct gui_select * select,
@@ -59,69 +48,22 @@ void gui_select_init_items(struct gui_select * select,
59{ 48{
60 select->canceled=false; 49 select->canceled=false;
61 select->validated=false; 50 select->validated=false;
62 select->title=title; 51 option_select_init_items(&select->options, title, selected, items, nb_items);
63 select->min_value=0;
64 select->max_value=nb_items;
65 select->option=selected;
66 select->step=1;
67 select->formatter=NULL;
68 select->items=items;
69 select->limit_loop=false;
70}
71
72void gui_select_next(struct gui_select * select)
73{
74 if(select->option + select->step >= select->max_value)
75 {
76 if(!select->limit_loop)
77 {
78 if(select->option==select->max_value-1)
79 select->option=select->min_value;
80 else
81 select->option=select->max_value-1;
82 }
83 }
84 else
85 select->option+=select->step;
86}
87
88void gui_select_prev(struct gui_select * select)
89{
90 if(select->option - select->step < select->min_value)
91 {
92 if(!select->limit_loop)
93 {
94 if(select->option==select->min_value)
95 select->option=select->max_value-1;
96 else
97 select->option=select->min_value;
98 }
99 }
100 else
101 select->option-=select->step;
102} 52}
103 53
104void gui_select_draw(struct gui_select * select, struct screen * display) 54void gui_select_draw(struct gui_select * select, struct screen * display)
105{ 55{
56 char buffer[30];
57 const char * selected=option_select_get_text(&(select->options), buffer);
106#ifdef HAVE_LCD_BITMAP 58#ifdef HAVE_LCD_BITMAP
107 screen_set_xmargin(display, 0); 59 screen_set_xmargin(display, 0);
108#endif 60#endif
109 gui_textarea_clear(display); 61 gui_textarea_clear(display);
110 display->puts_scroll(0, 0, select->title); 62 display->puts_scroll(0, 0, option_select_get_title(&(select->options)));
111 63
112 if(gui_select_is_canceled(select)) 64 if(gui_select_is_canceled(select))
113 display->puts_scroll(0, 0, str(LANG_MENU_SETTING_CANCEL)); 65 display->puts_scroll(0, 0, str(LANG_MENU_SETTING_CANCEL));
114 if(select->items) 66 display->puts_scroll(0, 1, selected);
115 display->puts_scroll(0, 1, P2STR(select->items[select->option].string));
116 else
117 {
118 char buffer[30];
119 if(!select->formatter)
120 snprintf(buffer, sizeof buffer,"%d %s", select->option, select->extra_string);
121 else
122 select->formatter(buffer, sizeof buffer, select->option, select->extra_string);
123 display->puts_scroll(0, 1, buffer);
124 }
125 gui_textarea_update(display); 67 gui_textarea_update(display);
126} 68}
127 69
diff --git a/apps/gui/select.h b/apps/gui/select.h
index bc14af4a24..2799d80043 100644
--- a/apps/gui/select.h
+++ b/apps/gui/select.h
@@ -21,6 +21,7 @@
21#define _GUI_SELECT_H_ 21#define _GUI_SELECT_H_
22#include "screen_access.h" 22#include "screen_access.h"
23#include "settings.h" 23#include "settings.h"
24#include "option_select.h"
24 25
25#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 26#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
26 (CONFIG_KEYPAD == IRIVER_H300_PAD) 27 (CONFIG_KEYPAD == IRIVER_H300_PAD)
@@ -83,19 +84,7 @@ struct gui_select
83{ 84{
84 bool canceled; 85 bool canceled;
85 bool validated; 86 bool validated;
86 const char * title; 87 struct option_select options;
87 int min_value;
88 int max_value;
89 int step;
90 int option;
91 const char * extra_string;
92 /* In the case the option is a number */
93 void (*formatter)(char* dest,
94 int dest_length,
95 int variable,
96 const char* unit);
97 const struct opt_items * items;
98 bool limit_loop;
99}; 88};
100 89
101/* 90/*
@@ -116,10 +105,7 @@ extern void gui_select_init_numeric(struct gui_select * select,
116 int max_value, 105 int max_value,
117 int step, 106 int step,
118 const char * unit, 107 const char * unit,
119 void (*formatter)(char* dest, 108 option_formatter *formatter);
120 int dest_length,
121 int variable,
122 const char* unit));
123 109
124 110
125/* 111/*
@@ -140,13 +126,15 @@ extern void gui_select_init_items(struct gui_select * select,
140 * Selects the next value 126 * Selects the next value
141 * - select : the select struct 127 * - select : the select struct
142 */ 128 */
143extern void gui_select_next(struct gui_select * select); 129#define gui_select_next(select) \
130 option_select_next(&(select->options))
144 131
145/* 132/*
146 * Selects the previous value 133 * Selects the previous value
147 * - select : the select struct 134 * - select : the select struct
148 */ 135 */
149extern void gui_select_prev(struct gui_select * select); 136#define gui_select_prev(select) \
137 option_select_prev(&(select->options))
150 138
151/* 139/*
152 * Draws the select on the given screen 140 * Draws the select on the given screen
@@ -159,9 +147,8 @@ extern void gui_select_draw(struct gui_select * select, struct screen * display)
159 * Returns the selected value 147 * Returns the selected value
160 * - select : the select struct 148 * - select : the select struct
161 */ 149 */
162#define gui_select_get_selected(select) \ 150#define gui_select_get_selected(_sel_) \
163 (select)->option 151 option_select_get_selected(&((_sel_)->options))
164
165/* 152/*
166 * Cancels the select 153 * Cancels the select
167 * - select : the select struct 154 * - select : the select struct
@@ -199,7 +186,7 @@ extern void gui_select_draw(struct gui_select * select, struct screen * display)
199 * - false : continues to go to max/min when reaching min/max 186 * - false : continues to go to max/min when reaching min/max
200 */ 187 */
201#define gui_select_limit_loop(select, loop) \ 188#define gui_select_limit_loop(select, loop) \
202 (select)->limit_loop=loop 189 option_select_limit_loop(&((select)->options), loop)
203 190
204/* 191/*
205 * Draws the select on all the screens 192 * Draws the select on all the screens
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index e7fe92eaf9..816205e2b4 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -85,8 +85,9 @@ extern void gui_statusbar_init(struct gui_statusbar * bar);
85 * - bar : the statusbar structure 85 * - bar : the statusbar structure
86 * - display : the screen to attach 86 * - display : the screen to attach
87 */ 87 */
88#define gui_statusbar_set_screen(gui_statusbar, screen) \ 88#define gui_statusbar_set_screen(gui_statusbar, _display) \
89 (gui_statusbar)->display = screen 89 (gui_statusbar)->display = (_display);
90
90 91
91/* 92/*
92 * Draws the status bar on the attached screen 93 * Draws the status bar on the attached screen
diff --git a/apps/screen_access.c b/apps/screen_access.c
index db64e27199..9ea33ba25f 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -19,6 +19,7 @@
19 19
20#include <lcd.h> 20#include <lcd.h>
21#include <lcd-remote.h> 21#include <lcd-remote.h>
22#include "backlight.h"
22#include <font.h> 23#include <font.h>
23#include <button.h> 24#include <button.h>
24#include <sprintf.h> 25#include <sprintf.h>
@@ -67,7 +68,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
67 screen->scroll_step=&lcd_remote_scroll_step; 68 screen->scroll_step=&lcd_remote_scroll_step;
68 screen->puts_scroll_style=&lcd_remote_puts_scroll_style; 69 screen->puts_scroll_style=&lcd_remote_puts_scroll_style;
69 screen->invertscroll=&lcd_remote_invertscroll; 70 screen->invertscroll=&lcd_remote_invertscroll;
70#endif /* 1 */ 71#endif /* LCD_REMOTE_DEPTH > 1 */
71 72
72#if 0 /* no charcell remote LCDs so far */ 73#if 0 /* no charcell remote LCDs so far */
73 screen->width=11; 74 screen->width=11;
@@ -89,6 +90,8 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
89 screen->clear_display=&lcd_remote_clear_display; 90 screen->clear_display=&lcd_remote_clear_display;
90 screen->update=&lcd_remote_update; 91 screen->update=&lcd_remote_update;
91 screen->puts=&lcd_remote_puts; 92 screen->puts=&lcd_remote_puts;
93 screen->backlight_on=&remote_backlight_on;
94 screen->backlight_off=&remote_backlight_off;
92 break; 95 break;
93#endif /* HAVE_REMOTE_LCD */ 96#endif /* HAVE_REMOTE_LCD */
94 97
@@ -151,6 +154,8 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
151 screen->update=&lcd_update; 154 screen->update=&lcd_update;
152#endif 155#endif
153 screen->puts=&lcd_puts; 156 screen->puts=&lcd_puts;
157 screen->backlight_on=&backlight_on;
158 screen->backlight_off=&backlight_off;
154 break; 159 break;
155 } 160 }
156 screen->screen_type=screen_type; 161 screen->screen_type=screen_type;
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 7f235a2480..430d5ab661 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -103,7 +103,8 @@ struct screen
103#if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) || defined(SIMULATOR) 103#if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) || defined(SIMULATOR)
104 void (*update)(void); 104 void (*update)(void);
105#endif 105#endif
106 106 void (*backlight_on)(void);
107 void (*backlight_off)(void);
107 void (*puts)(int x, int y, const unsigned char *str); 108 void (*puts)(int x, int y, const unsigned char *str);
108}; 109};
109 110
diff --git a/apps/screens.c b/apps/screens.c
index acfcd01dbe..eea06785cb 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -49,6 +49,8 @@
49#include "gwps-common.h" 49#include "gwps-common.h"
50#include "splash.h" 50#include "splash.h"
51#include "statusbar.h" 51#include "statusbar.h"
52#include "screen_access.h"
53#include "quickscreen.h"
52 54
53#if defined(HAVE_LCD_BITMAP) 55#if defined(HAVE_LCD_BITMAP)
54#include "widgets.h" 56#include "widgets.h"
@@ -101,25 +103,25 @@ static const unsigned char usb_logo[] = {
101}; 103};
102#endif 104#endif
103 105
104void usb_display_info(void) 106void usb_display_info(struct screen * display)
105{ 107{
106 lcd_clear_display(); 108 display->clear_display();
107 109
108#ifdef HAVE_LCD_BITMAP 110#ifdef HAVE_LCD_BITMAP
109 /* Center bitmap on screen */ 111 /* Center bitmap on screen */
110 lcd_mono_bitmap(usb_logo, LCD_WIDTH/2-BMPWIDTH_usb_logo/2, 112 display->mono_bitmap(usb_logo,
111 LCD_HEIGHT/2-BMPHEIGHT_usb_logo/2, BMPWIDTH_usb_logo, 113 display->width/2-BMPWIDTH_usb_logo/2,
112 BMPHEIGHT_usb_logo); 114 display->height/2-BMPHEIGHT_usb_logo/2,
113 gui_syncstatusbar_draw(&statusbars, true); 115 BMPWIDTH_usb_logo,
114 lcd_update(); 116 BMPHEIGHT_usb_logo);
117 display->update();
115#else 118#else
116 lcd_double_height(false); 119 display->double_height(false);
117 lcd_puts(0, 0, "[USB Mode]"); 120 display->puts(0, 0, "[USB Mode]");
118 status_set_param(false); 121#ifdef SIMULATOR
119 status_set_audio(false); 122 display->update();
120 status_set_usb(true); 123#endif /* SIMULATOR */
121 gui_syncstatusbar_draw(&statusbars, false); 124#endif /* HAVE_LCD_BITMAP */
122#endif
123} 125}
124 126
125void usb_screen(void) 127void usb_screen(void)
@@ -127,28 +129,35 @@ void usb_screen(void)
127#ifdef USB_NONE 129#ifdef USB_NONE
128 /* nothing here! */ 130 /* nothing here! */
129#else 131#else
130#ifndef SIMULATOR 132 int i;
131 backlight_on(); 133 FOR_NB_SCREENS(i) {
134 screens[i].backlight_on();
135 usb_display_info(&screens[i]);
136 }
137#ifdef HAVE_LCD_CHARCELLS
138 status_set_param(false);
139 status_set_audio(false);
140 status_set_usb(true);
141#endif /* HAVE_LCD_BITMAP */
142 gui_syncstatusbar_draw(&statusbars, true);
143#ifdef SIMULATOR
144 while (button_get(true) & BUTTON_REL);
145#else
132 usb_acknowledge(SYS_USB_CONNECTED_ACK); 146 usb_acknowledge(SYS_USB_CONNECTED_ACK);
133 usb_display_info();
134 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { 147 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
135 if(usb_inserted()) { 148 if(usb_inserted()) {
136
137#ifdef HAVE_MMC /* USB-MMC bridge can report activity */ 149#ifdef HAVE_MMC /* USB-MMC bridge can report activity */
138
139 led(mmc_usb_active(HZ)); 150 led(mmc_usb_active(HZ));
140 151#endif /* HAVE_MMC */
141#endif
142
143 gui_syncstatusbar_draw(&statusbars, false); 152 gui_syncstatusbar_draw(&statusbars, false);
144 } 153 }
145 } 154 }
155#endif /* SIMULATOR */
146#ifdef HAVE_LCD_CHARCELLS 156#ifdef HAVE_LCD_CHARCELLS
147 status_set_usb(false); 157 status_set_usb(false);
148#endif 158#endif /* HAVE_LCD_CHARCELLS */
149 159 FOR_NB_SCREENS(i)
150 backlight_on(); 160 screens[i].backlight_on();
151#endif
152#endif /* USB_NONE */ 161#endif /* USB_NONE */
153} 162}
154 163
@@ -157,7 +166,8 @@ int mmc_remove_request(void)
157{ 166{
158 struct event ev; 167 struct event ev;
159 168
160 lcd_clear_display(); 169 FOR_NB_SCREENS(i)
170 screens[i].clear_display();
161 gui_syncsplash(1, true, str(LANG_REMOVE_MMC)); 171 gui_syncsplash(1, true, str(LANG_REMOVE_MMC));
162 if (global_settings.talk_menu) 172 if (global_settings.talk_menu)
163 talk_id(LANG_REMOVE_MMC, false); 173 talk_id(LANG_REMOVE_MMC, false);
@@ -520,257 +530,137 @@ int pitch_screen(void)
520 530
521#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\ 531#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\
522 (CONFIG_KEYPAD == IRIVER_H300_PAD) 532 (CONFIG_KEYPAD == IRIVER_H300_PAD)
523bool quick_screen(int context, int button) 533#define bool_to_int(b)\
524{ 534 b?1:0
525 bool exit = false; 535#define int_to_bool(i)\
526 bool used = false; 536 i==0?false:true
527 int w, h, key;
528 char buf[32];
529 int oldrepeat = global_settings.repeat_mode;
530 537
531 /* just to stop compiler warning */ 538void quick_screen_quick_apply(struct gui_quickscreen *qs)
532 context = context; 539{
533 lcd_setfont(FONT_SYSFIXED); 540 global_settings.playlist_shuffle=int_to_bool(option_select_get_selected(qs->left_option));
534 541 global_settings.dirfilter=option_select_get_selected(qs->bottom_option);
535 lcd_getstringsize("A",&w,&h); 542 global_settings.repeat_mode=option_select_get_selected(qs->right_option);
536 543}
537 while (!exit) {
538 char* ptr=NULL;
539
540 lcd_clear_display();
541
542 switch(button)
543 {
544#if CONFIG_KEYPAD == RECORDER_PAD
545 case SCREENS_QUICK:
546#endif
547#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
548 case SCREENS_QUICK | BUTTON_REPEAT:
549#endif
550 /* Shuffle mode */
551 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
552 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
553 lcd_putsxy(0, LCD_HEIGHT/2,
554 global_settings.playlist_shuffle ?
555 str(LANG_ON) : str(LANG_OFF));
556
557 /* Directory Filter */
558 switch ( global_settings.dirfilter ) {
559 case SHOW_ALL:
560 ptr = str(LANG_FILTER_ALL);
561 break;
562
563 case SHOW_SUPPORTED:
564 ptr = str(LANG_FILTER_SUPPORTED);
565 break;
566
567 case SHOW_MUSIC:
568 ptr = str(LANG_FILTER_MUSIC);
569 break;
570
571 case SHOW_PLAYLIST:
572 ptr = str(LANG_FILTER_PLAYLIST);
573 break;
574
575 case SHOW_ID3DB:
576 ptr = str(LANG_FILTER_ID3DB);
577 break;
578 }
579
580 snprintf(buf, sizeof buf, "%s:", str(LANG_FILTER));
581 lcd_getstringsize(buf,&w,&h);
582 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
583 lcd_getstringsize(ptr,&w,&h);
584 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
585
586 /* Repeat Mode */
587 switch ( global_settings.repeat_mode ) {
588 case REPEAT_OFF:
589 ptr = str(LANG_OFF);
590 break;
591
592 case REPEAT_ALL:
593 ptr = str(LANG_REPEAT_ALL);
594 break;
595
596 case REPEAT_ONE:
597 ptr = str(LANG_REPEAT_ONE);
598 break;
599
600 case REPEAT_SHUFFLE:
601 ptr = str(LANG_SHUFFLE);
602 break;
603 544
545bool quick_screen_quick(void)
546{
547 bool res, oldrepeat;
548 struct option_select left_option;
549 struct option_select bottom_option;
550 struct option_select right_option;
551 struct opt_items left_items[] = {
552 [0]={ STR(LANG_OFF) },
553 [1]={ STR(LANG_ON) }
554 };
555 struct opt_items bottom_items[] = {
556 [SHOW_ALL]={ STR(LANG_FILTER_ALL) },
557 [SHOW_SUPPORTED]={ STR(LANG_FILTER_SUPPORTED) },
558 [SHOW_MUSIC]={ STR(LANG_FILTER_MUSIC) },
559 [SHOW_PLAYLIST]={ STR(LANG_FILTER_PLAYLIST) },
560 [SHOW_ID3DB]={ STR(LANG_FILTER_ID3DB) }
561 };
562 struct opt_items right_items[] = {
563 [REPEAT_OFF]={ STR(LANG_OFF) },
564 [REPEAT_ALL]={ STR(LANG_REPEAT_ALL) },
565 [REPEAT_ONE]={ STR(LANG_REPEAT_ONE) },
566 [REPEAT_SHUFFLE]={ STR(LANG_SHUFFLE) },
604#ifdef AB_REPEAT_ENABLE 567#ifdef AB_REPEAT_ENABLE
605 case REPEAT_AB: 568 [REPEAT_AB]={ STR(LANG_REPEAT_AB) }
606 ptr = str(LANG_REPEAT_AB);
607 break;
608#endif 569#endif
609 } 570 };
610 571 struct gui_quickscreen qs;
611 lcd_getstringsize(str(LANG_REPEAT),&w,&h); 572
612 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, str(LANG_REPEAT)); 573 option_select_init_items(&left_option,
613 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); 574 str(LANG_SHUFFLE),
614 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); 575 bool_to_int(global_settings.playlist_shuffle),
615 break; 576 left_items,
616#ifdef BUTTON_F3 577 2);
617 case BUTTON_F3: 578 option_select_init_items(&bottom_option,
618 /* Scrollbar */ 579 str(LANG_FILTER),
619 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL)); 580 global_settings.dirfilter,
620 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); 581 bottom_items,
621 lcd_putsxy(0, LCD_HEIGHT/2, 582 sizeof(bottom_items)/sizeof(struct opt_items));
622 global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF)); 583 option_select_init_items(&right_option,
623 584 str(LANG_REPEAT),
624 /* Status bar */ 585 global_settings.repeat_mode,
625 ptr = str(LANG_F3_STATUS); 586 right_items,
626 lcd_getstringsize(ptr,&w,&h); 587 sizeof(right_items)/sizeof(struct opt_items));
627 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr); 588
628 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); 589 gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option,
629 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, 590 str(LANG_F2_MODE), &quick_screen_quick_apply);
630 global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF)); 591 oldrepeat=global_settings.repeat_mode;
631 592 res=gui_syncquickscreen_run(&qs);
632 /* Flip */ 593 if(!res)
633 ptr = str(LANG_FLIP_DISPLAY); 594 {
634 lcd_getstringsize(ptr,&w,&h); 595 if ( oldrepeat != global_settings.repeat_mode &&
635 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, str(LANG_FLIP_DISPLAY)); 596 (audio_status() & AUDIO_STATUS_PLAY) )
636 ptr = global_settings.flip_display ? 597 audio_flush_and_reload_tracks();
637 str(LANG_SET_BOOL_YES) : str(LANG_SET_BOOL_NO); 598 if(global_settings.playlist_shuffle
638 lcd_getstringsize(ptr,&w,&h); 599 && audio_status() & AUDIO_STATUS_PLAY)
639 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); 600 {
640 break;
641#endif
642 }
643
644 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
645 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
646 lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
647 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
648 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
649 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
650
651 lcd_update();
652 key = button_get(true);
653
654 /*
655 * This is a temporary kludge so that the F2 & F3 menus operate in exactly
656 * the same manner up until the full F2/F3 configurable menus are complete
657 */
658
659 if( key == BUTTON_LEFT || key == BUTTON_RIGHT || key == BUTTON_DOWN || key == ( BUTTON_LEFT | BUTTON_REPEAT ) || key == ( BUTTON_RIGHT | BUTTON_REPEAT ) || key == ( BUTTON_DOWN | BUTTON_REPEAT ) )
660 key = button | key;
661
662 switch (key) {
663 case SCREENS_QUICK | BUTTON_LEFT:
664 case SCREENS_QUICK | BUTTON_LEFT | BUTTON_REPEAT:
665 global_settings.playlist_shuffle =
666 !global_settings.playlist_shuffle;
667
668 if(audio_status() & AUDIO_STATUS_PLAY)
669 {
670#if CONFIG_CODEC == SWCODEC 601#if CONFIG_CODEC == SWCODEC
671 dsp_set_replaygain(true); 602 dsp_set_replaygain(true);
672#endif
673
674 if (global_settings.playlist_shuffle)
675 playlist_randomise(NULL, current_tick, true);
676 else
677 playlist_sort(NULL, true);
678 }
679 used = true;
680 break;
681
682 case SCREENS_QUICK | BUTTON_DOWN:
683 case SCREENS_QUICK | BUTTON_DOWN | BUTTON_REPEAT:
684 global_settings.dirfilter++;
685 if ( global_settings.dirfilter >= NUM_FILTER_MODES )
686 global_settings.dirfilter = 0;
687 used = true;
688 break;
689
690 case SCREENS_QUICK | BUTTON_RIGHT:
691 case SCREENS_QUICK | BUTTON_RIGHT | BUTTON_REPEAT:
692 global_settings.repeat_mode++;
693 if ( global_settings.repeat_mode >= NUM_REPEAT_MODES )
694 global_settings.repeat_mode = 0;
695 used = true;
696 break;
697
698#ifdef BUTTON_F3
699 case BUTTON_F3 | BUTTON_LEFT:
700 case BUTTON_F3 | BUTTON_LEFT | BUTTON_REPEAT:
701 global_settings.scrollbar = !global_settings.scrollbar;
702 used = true;
703 break;
704
705 case BUTTON_F3 | BUTTON_RIGHT:
706 case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT:
707 global_settings.statusbar = !global_settings.statusbar;
708 used = true;
709 break;
710
711 case BUTTON_F3 | BUTTON_DOWN:
712 case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT:
713 case BUTTON_F3 | BUTTON_UP:
714 case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT:
715 global_settings.flip_display = !global_settings.flip_display;
716 button_set_flip(global_settings.flip_display);
717 lcd_set_flip(global_settings.flip_display);
718 used = true;
719 break;
720
721 case BUTTON_F3 | BUTTON_REL:
722#endif 603#endif
723 case SCREENS_QUICK | BUTTON_REL: 604 if (global_settings.playlist_shuffle)
724 605 playlist_randomise(NULL, current_tick, true);
725 if( used ) 606 else
726 exit = true; 607 playlist_sort(NULL, true);
727
728 used = true;
729
730 break;
731
732 case BUTTON_OFF | BUTTON_REL:
733 lcd_setfont(FONT_UI);
734 return false;
735
736 default:
737 if(default_event_handler(key) == SYS_USB_CONNECTED)
738 return true;
739 break;
740 } 608 }
609 settings_save();
741 } 610 }
611 return(res);
612}
742 613
743 settings_save(); 614void quick_screen_f3_apply(struct gui_quickscreen *qs)
744 615{
745 switch( button ) 616 global_settings.scrollbar=int_to_bool(option_select_get_selected(qs->left_option));
746 {
747#if CONFIG_KEYPAD == RECORDER_PAD
748 case SCREENS_QUICK:
749#endif
750#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
751 case SCREENS_QUICK | BUTTON_REPEAT:
752#endif
753
754 if ( oldrepeat != global_settings.repeat_mode &&
755 (audio_status() & AUDIO_STATUS_PLAY) )
756 audio_flush_and_reload_tracks();
757 617
758 break; 618 global_settings.flip_display=int_to_bool(option_select_get_selected(qs->bottom_option));
759#ifdef BUTTON_F3 619 button_set_flip(global_settings.flip_display);
760 case BUTTON_F3: 620 lcd_set_flip(global_settings.flip_display);
761 621
762 if (global_settings.statusbar) 622 global_settings.statusbar=int_to_bool(option_select_get_selected(qs->right_option));
763 lcd_setmargins(0, STATUSBAR_HEIGHT); 623 gui_syncstatusbar_draw(&statusbars, true);
764 else 624}
765 lcd_setmargins(0, 0);
766
767 break;
768#endif
769 }
770 625
771 lcd_setfont(FONT_UI); 626bool quick_screen_f3(void)
627{
628 bool res;
629 struct option_select left_option;
630 struct option_select bottom_option;
631 struct option_select right_option;
632 struct opt_items onoff_items[] = {
633 [0]={ STR(LANG_OFF) },
634 [1]={ STR(LANG_ON) }
635 };
636 struct opt_items yesno_items[] = {
637 [0]={ STR(LANG_SET_BOOL_NO) },
638 [1]={ STR(LANG_SET_BOOL_YES) }
639 };
772 640
773 return false; 641 struct gui_quickscreen qs;
642
643 option_select_init_items(&left_option,
644 str(LANG_F3_SCROLL),
645 bool_to_int(global_settings.scrollbar),
646 onoff_items,
647 2);
648 option_select_init_items(&bottom_option,
649 str(LANG_FLIP_DISPLAY),
650 bool_to_int(global_settings.flip_display),
651 yesno_items,
652 2);
653 option_select_init_items(&right_option,
654 str(LANG_F3_STATUS),
655 bool_to_int(global_settings.statusbar),
656 onoff_items,
657 2);
658 gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option,
659 str(LANG_F3_BAR), &quick_screen_f3_apply);
660 res=gui_syncquickscreen_run(&qs);
661 if(!res)
662 settings_save();
663 return(res);
774} 664}
775#endif 665#endif
776 666
diff --git a/apps/screens.h b/apps/screens.h
index 60a1537e99..3de66582ee 100644
--- a/apps/screens.h
+++ b/apps/screens.h
@@ -22,7 +22,9 @@
22#include "config.h" 22#include "config.h"
23#include "timefuncs.h" 23#include "timefuncs.h"
24 24
25void usb_display_info(void); 25struct screen;
26
27void usb_display_info(struct screen * display);
26void usb_screen(void); 28void usb_screen(void);
27int charging_screen(void); 29int charging_screen(void);
28void charging_splash(void); 30void charging_splash(void);
@@ -33,15 +35,9 @@ int mmc_remove_request(void);
33 35
34#if CONFIG_KEYPAD == RECORDER_PAD 36#if CONFIG_KEYPAD == RECORDER_PAD
35int pitch_screen(void); 37int pitch_screen(void);
36bool quick_screen(const int, const int); 38extern bool quick_screen_f3(void);
37#define SCREENS_QUICK BUTTON_F2
38#endif
39
40#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
41bool quick_screen(const int, const int);
42#define SCREENS_QUICK BUTTON_MODE
43 /* Long press already detected so not needed here */
44#endif 39#endif
40extern bool quick_screen_quick(void);
45 41
46#ifdef HAVE_RTC 42#ifdef HAVE_RTC
47bool set_time_screen(const char* string, struct tm *tm); 43bool set_time_screen(const char* string, struct tm *tm);
diff --git a/apps/tree.c b/apps/tree.c
index bed4fb28fc..33b482b3d7 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -712,10 +712,13 @@ static bool dirbrowse(void)
712 712
713#ifdef TREE_QUICK 713#ifdef TREE_QUICK
714 case TREE_QUICK: 714 case TREE_QUICK:
715#ifdef TREE_RC_QUICK
716 case TREE_RC_QUICK:
717#endif
715 /* don't enter f2 from plugin browser */ 718 /* don't enter f2 from plugin browser */
716 if (*tc.dirfilter < NUM_FILTER_MODES) 719 if (*tc.dirfilter < NUM_FILTER_MODES)
717 { 720 {
718 if (quick_screen(curr_context, TREE_QUICK)) 721 if (quick_screen_quick())
719 reload_dir = true; 722 reload_dir = true;
720 restore = true; 723 restore = true;
721 724
@@ -730,7 +733,7 @@ static bool dirbrowse(void)
730 /* don't enter f3 from plugin browser */ 733 /* don't enter f3 from plugin browser */
731 if (*tc.dirfilter < NUM_FILTER_MODES) 734 if (*tc.dirfilter < NUM_FILTER_MODES)
732 { 735 {
733 if (quick_screen(curr_context, BUTTON_F3)) 736 if (quick_screen_f3())
734 reload_dir = true; 737 reload_dir = true;
735 restore = true; 738 restore = true;
736 } 739 }
diff --git a/apps/tree.h b/apps/tree.h
index 74b33fa635..d0da72643e 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -59,6 +59,7 @@
59#define TREE_RC_WPS (BUTTON_RC_ON | BUTTON_REL) 59#define TREE_RC_WPS (BUTTON_RC_ON | BUTTON_REL)
60#define TREE_RC_WPS_PRE BUTTON_RC_ON 60#define TREE_RC_WPS_PRE BUTTON_RC_ON
61#define TREE_RC_CONTEXT (BUTTON_RC_ON | BUTTON_REPEAT) 61#define TREE_RC_CONTEXT (BUTTON_RC_ON | BUTTON_REPEAT)
62#define TREE_RC_QUICK (BUTTON_RC_MODE | BUTTON_REPEAT)
62 63
63#elif CONFIG_KEYPAD == RECORDER_PAD 64#elif CONFIG_KEYPAD == RECORDER_PAD
64#define TREE_NEXT BUTTON_DOWN 65#define TREE_NEXT BUTTON_DOWN