diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-03 12:30:40 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-03 12:30:40 +0000 |
commit | ea664e06476cb572bab2eadbb9c060902a95a34a (patch) | |
tree | e76c631343fcc744a24f7f244bf3d3bb73c8192c /apps/gui | |
parent | 6be91cdc8b90184cf6ee623358222c1268f31c25 (diff) | |
download | rockbox-ea664e06476cb572bab2eadbb9c060902a95a34a.tar.gz rockbox-ea664e06476cb572bab2eadbb9c060902a95a34a.zip |
Viewported quickscreen (take 2 :D) (FS#8553)
- no customization support
- no top item
- much better use of the screen
- deprecates 20 odd lang strings (the QS can now use the regular lang strings and user font)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17315 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps.c | 1 | ||||
-rw-r--r-- | apps/gui/option_select.c | 104 | ||||
-rw-r--r-- | apps/gui/option_select.h | 6 | ||||
-rw-r--r-- | apps/gui/quickscreen.c | 361 | ||||
-rw-r--r-- | apps/gui/quickscreen.h | 47 |
5 files changed, 330 insertions, 189 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 0520357002..2e72813d73 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include "ata_idle_notify.h" | 57 | #include "ata_idle_notify.h" |
58 | #include "root_menu.h" | 58 | #include "root_menu.h" |
59 | #include "backdrop.h" | 59 | #include "backdrop.h" |
60 | #include "quickscreen.h" | ||
60 | 61 | ||
61 | /* currently only on wps_state is needed */ | 62 | /* currently only on wps_state is needed */ |
62 | struct wps_state wps_state; | 63 | struct wps_state wps_state; |
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index c6136ebf17..43b5fa6ea1 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -60,7 +60,7 @@ static const char *unit_strings[] = | |||
60 | /* these two vars are needed so arbitrary values can be added to the | 60 | /* these two vars are needed so arbitrary values can be added to the |
61 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ | 61 | TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ |
62 | static int table_setting_oldval = 0, table_setting_array_position = 0; | 62 | static int table_setting_oldval = 0, table_setting_array_position = 0; |
63 | static char *option_get_valuestring(struct settings_list *setting, | 63 | char *option_get_valuestring(struct settings_list *setting, |
64 | char *buffer, int buf_len, | 64 | char *buffer, int buf_len, |
65 | intptr_t temp_var) | 65 | intptr_t temp_var) |
66 | { | 66 | { |
@@ -210,56 +210,37 @@ static int option_talk(int selected_item, void * data) | |||
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | #if 0 | ||
214 | int option_select_next_val(struct settings_list *setting, | ||
215 | intptr_t temp_var) | ||
216 | { | ||
217 | int val = 0; | ||
218 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | ||
219 | { | ||
220 | val = (bool)temp_var ? 0 : 1; | ||
221 | } | ||
222 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | ||
223 | { | ||
224 | struct int_setting *info = setting->int_setting; | ||
225 | val = (int)temp_var + info->step; | ||
226 | if (val > info->max) | ||
227 | val = info->min; | ||
228 | } | ||
229 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) | ||
230 | { | ||
231 | int setting_id = setting->sound_setting->setting; | ||
232 | int steps = sound_steps(setting_id); | ||
233 | int min = sound_min(setting_id); | ||
234 | int max = sound_max(setting_id); | ||
235 | val = (int)temp_var + steps; | ||
236 | if (val > max) | ||
237 | val = min; | ||
238 | } | ||
239 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | ||
240 | { | ||
241 | struct choice_setting *info = setting->choice_setting; | ||
242 | val = (int)temp_var; | ||
243 | if (val > info->count) | ||
244 | val = 0; | ||
245 | } | ||
246 | return val; | ||
247 | } | ||
248 | 213 | ||
249 | int option_select_prev_val(struct settings_list *setting, | 214 | #ifdef HAVE_QUICKSCREEN /* only the quickscreen uses this so far */ |
250 | intptr_t temp_var) | 215 | void option_select_next_val(struct settings_list *setting, |
216 | bool previous, bool apply) | ||
251 | { | 217 | { |
252 | int val = 0; | 218 | int val = 0; |
219 | int *value = setting->setting; | ||
253 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 220 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) |
254 | { | 221 | { |
255 | val = (bool)temp_var ? 0 : 1; | 222 | *(bool*)value = !*(bool*)value; |
223 | if (apply && setting->bool_setting->option_callback) | ||
224 | setting->bool_setting->option_callback(*(bool*)value); | ||
225 | return; | ||
256 | } | 226 | } |
257 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | 227 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) |
258 | { | 228 | { |
259 | struct int_setting *info = setting->int_setting; | 229 | struct int_setting *info = (struct int_setting *)setting->int_setting; |
260 | val = (int)temp_var - info->step; | 230 | if (!previous) |
261 | if (val < info->min) | 231 | { |
262 | val = info->max; | 232 | val = *value + info->step; |
233 | if (val > info->max) | ||
234 | val = info->min; | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | val = *value - info->step; | ||
239 | if (val < info->min) | ||
240 | val = info->max; | ||
241 | } | ||
242 | if (apply && info->option_callback) | ||
243 | info->option_callback(*(int*)value); | ||
263 | } | 244 | } |
264 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) | 245 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) |
265 | { | 246 | { |
@@ -267,18 +248,39 @@ int option_select_prev_val(struct settings_list *setting, | |||
267 | int steps = sound_steps(setting_id); | 248 | int steps = sound_steps(setting_id); |
268 | int min = sound_min(setting_id); | 249 | int min = sound_min(setting_id); |
269 | int max = sound_max(setting_id); | 250 | int max = sound_max(setting_id); |
270 | val = (int)temp_var -+ steps; | 251 | if (!previous) |
271 | if (val < min) | 252 | { |
272 | val = max; | 253 | val = *value + steps; |
254 | if (val >= max) | ||
255 | val = min; | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | val = *value - steps; | ||
260 | if (val < min) | ||
261 | val = max; | ||
262 | } | ||
273 | } | 263 | } |
274 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | 264 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) |
275 | { | 265 | { |
276 | struct choice_setting *info = setting->choice_setting; | 266 | struct choice_setting *info = (struct choice_setting *)setting->choice_setting; |
277 | val = (int)temp_var; | 267 | val = *value + 1; |
278 | if (val < 0) | 268 | if (!previous) |
279 | val = info->count - 1; | 269 | { |
270 | val = *value + 1; | ||
271 | if (val >= info->count) | ||
272 | val = 0; | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | val = *value - 1; | ||
277 | if (val < 0) | ||
278 | val = info->count-1; | ||
279 | } | ||
280 | if (apply && info->option_callback) | ||
281 | info->option_callback(*(int*)value); | ||
280 | } | 282 | } |
281 | return val; | 283 | *value = val; |
282 | } | 284 | } |
283 | #endif | 285 | #endif |
284 | 286 | ||
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index bb609346a3..8b43af1e5a 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h | |||
@@ -69,4 +69,10 @@ extern void option_select_next(struct option_select * opt); | |||
69 | extern void option_select_prev(struct option_select * opt); | 69 | extern void option_select_prev(struct option_select * opt); |
70 | 70 | ||
71 | 71 | ||
72 | |||
73 | void option_select_next_val(struct settings_list *setting, | ||
74 | bool previous, bool apply); | ||
75 | char *option_get_valuestring(struct settings_list *setting, | ||
76 | char *buffer, int buf_len, | ||
77 | intptr_t temp_var); | ||
72 | #endif /* _GUI_OPTION_SELECT_H_ */ | 78 | #endif /* _GUI_OPTION_SELECT_H_ */ |
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index c2da5879fe..8668e9b085 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2005 by Kevin Ferrare | 10 | * Copyright (C) 2008 by Jonathan Gordon |
11 | * | 11 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 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. | 13 | * See the file COPYING in the source tree root for full license agreement. |
@@ -17,11 +17,9 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "quickscreen.h" | ||
21 | |||
22 | #ifdef HAVE_QUICKSCREEN | ||
23 | 20 | ||
24 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include "config.h" | ||
25 | #include "system.h" | 23 | #include "system.h" |
26 | #include "icons.h" | 24 | #include "icons.h" |
27 | #include "textarea.h" | 25 | #include "textarea.h" |
@@ -30,109 +28,199 @@ | |||
30 | #include "misc.h" | 28 | #include "misc.h" |
31 | #include "statusbar.h" | 29 | #include "statusbar.h" |
32 | #include "action.h" | 30 | #include "action.h" |
31 | #include "settings_list.h" | ||
32 | #include "lang.h" | ||
33 | #include "playlist.h" | ||
34 | #include "dsp.h" | ||
35 | #include "viewport.h" | ||
36 | #include "audio.h" | ||
37 | #include "quickscreen.h" | ||
33 | 38 | ||
34 | void gui_quickscreen_init(struct gui_quickscreen * qs, | 39 | static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT]; |
35 | struct option_select *left_option, | 40 | static struct viewport vp_icons[NB_SCREENS]; |
36 | struct option_select *bottom_option, | 41 | /* vp_icons will be used like this: |
37 | struct option_select *right_option, | 42 | the side icons will be aligned to the top of this vp and to their sides |
38 | quickscreen_callback callback) | 43 | the bottom icon wil be aligned center and at the bottom of this vp */ |
39 | { | ||
40 | qs->left_option=left_option; | ||
41 | qs->bottom_option=bottom_option; | ||
42 | qs->right_option=right_option; | ||
43 | qs->callback=callback; | ||
44 | } | ||
45 | 44 | ||
46 | /* | 45 | #define MIN_LINES 4 |
47 | * Draws the quickscreen on a given screen | 46 | #define MAX_NEEDED_LINES 8 |
48 | * - qs : the quickscreen | 47 | #define CENTER_MARGIN 10 /* pixels between the 2 center items minimum */ |
49 | * - display : the screen to draw on | 48 | #define CENTER_ICONAREA_WIDTH (CENTER_MARGIN+8*2) |
50 | */ | 49 | |
51 | static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display) | 50 | static void quickscreen_fix_viewports(struct gui_quickscreen *qs, |
51 | struct screen *display, | ||
52 | struct viewport *parent) | ||
52 | { | 53 | { |
53 | const unsigned char *option; | 54 | int char_height, i, screen = display->screen_type; |
54 | const unsigned char *title; | 55 | int left_width, right_width, bottom_lines = 3; |
55 | int w, font_h; | 56 | unsigned char *s; |
56 | bool statusbar = global_settings.statusbar; | 57 | int nb_lines = viewport_get_nb_lines(parent); |
57 | #ifdef HAS_BUTTONBAR | 58 | char_height = parent->height/nb_lines; |
58 | display->has_buttonbar=false; | 59 | |
59 | #endif | 60 | vp_icons[screen] = *parent; |
60 | gui_textarea_clear(display); | 61 | |
61 | if (display->height / display->char_height < 7) /* we need at leats 7 lines */ | 62 | vps[screen][QUICKSCREEN_BOTTOM] = *parent; |
63 | if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */ | ||
64 | bottom_lines = 1; | ||
65 | else | ||
66 | bottom_lines = 2; | ||
67 | vps[screen][QUICKSCREEN_BOTTOM].height = bottom_lines*char_height; | ||
68 | vps[screen][QUICKSCREEN_BOTTOM].y = parent->y + parent->height - bottom_lines*char_height; | ||
69 | if (nb_lines >= MAX_NEEDED_LINES) | ||
62 | { | 70 | { |
63 | display->setfont(FONT_SYSFIXED); | 71 | vps[screen][QUICKSCREEN_BOTTOM].y -= char_height; |
64 | } | 72 | } |
65 | display->getstringsize("A", NULL, &font_h); | 73 | |
66 | 74 | /* adjust the left/right items widths to fit the screen nicely */ | |
67 | /* do these calculations once */ | 75 | s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); |
68 | const unsigned int puts_center = display->height/2/font_h; | 76 | left_width = display->getstringsize(s, NULL, NULL); |
69 | const unsigned int puts_bottom = display->height/font_h; | 77 | s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); |
70 | const unsigned int putsxy_center = display->height/2; | 78 | right_width = display->getstringsize(s, NULL, NULL); |
71 | const unsigned int putsxy_bottom = display->height; | 79 | nb_lines -= bottom_lines; |
72 | 80 | ||
73 | /* Displays the first line of text */ | 81 | vps[screen][QUICKSCREEN_LEFT] = *parent; |
74 | option=(unsigned char *)option_select_get_text(qs->left_option); | 82 | vps[screen][QUICKSCREEN_RIGHT] = *parent; |
75 | title=(unsigned char *)qs->left_option->title; | 83 | vps[screen][QUICKSCREEN_LEFT].x = parent->x; |
76 | display->puts_scroll(2, puts_center-4+!statusbar, title); | 84 | if (nb_lines <= MIN_LINES) |
77 | display->puts_scroll(2, puts_center-3+!statusbar, option); | 85 | i = 0; |
78 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, | 86 | else |
79 | putsxy_center-(font_h*3), 7, 8); | 87 | i = nb_lines/2; |
80 | 88 | vps[screen][QUICKSCREEN_LEFT].y = parent->y + (i*char_height); | |
81 | /* Displays the second line of text */ | 89 | vps[screen][QUICKSCREEN_RIGHT].y = parent->y + (i*char_height); |
82 | option=(unsigned char *)option_select_get_text(qs->right_option); | 90 | if (nb_lines >= 3) |
83 | title=(unsigned char *)qs->right_option->title; | 91 | i = 3*char_height; |
84 | display->getstringsize(title, &w, NULL); | 92 | else |
85 | if(w > display->width - 8) | 93 | i = nb_lines*char_height; |
94 | |||
95 | vps[screen][QUICKSCREEN_LEFT].height = i; | ||
96 | vps[screen][QUICKSCREEN_RIGHT].height = i; | ||
97 | vp_icons[screen].y = vps[screen][QUICKSCREEN_LEFT].y + (char_height/2); | ||
98 | vp_icons[screen].height = vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; | ||
99 | |||
100 | if (left_width + right_width > display->width - CENTER_MARGIN) /* scrolling needed */ | ||
86 | { | 101 | { |
87 | display->puts_scroll(2, puts_center-2+!statusbar, title); | 102 | int width = (parent->width - CENTER_ICONAREA_WIDTH)/2; |
88 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1, | 103 | vps[screen][QUICKSCREEN_LEFT].width = width; |
89 | putsxy_center-font_h, 7, 8); | 104 | vps[screen][QUICKSCREEN_RIGHT].width = width; |
105 | vps[screen][QUICKSCREEN_RIGHT].x = parent->x+parent->width - width; | ||
106 | vp_icons[screen].x = parent->x + width; | ||
107 | vp_icons[screen].width = CENTER_ICONAREA_WIDTH; | ||
90 | } | 108 | } |
91 | else | 109 | else |
92 | { | 110 | { |
93 | display->putsxy(display->width - w - 12, putsxy_center-font_h, title); | 111 | int width, pad = 0; |
94 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | 112 | if (left_width > right_width) |
95 | display->width - 8, putsxy_center-font_h, 7, 8); | 113 | width = left_width; |
114 | else | ||
115 | width = right_width; | ||
116 | width += CENTER_MARGIN; | ||
117 | if (width*2 < parent->width/2) | ||
118 | { | ||
119 | width += parent->width/6; | ||
120 | /* add some padding on the edges */ | ||
121 | pad = CENTER_MARGIN; | ||
122 | } | ||
123 | vps[screen][QUICKSCREEN_LEFT].width = width; | ||
124 | vps[screen][QUICKSCREEN_RIGHT].width = width; | ||
125 | vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width; | ||
126 | vp_icons[screen].x = parent->x + width; | ||
127 | if (pad) | ||
128 | { | ||
129 | vp_icons[screen].x += pad; | ||
130 | vps[screen][QUICKSCREEN_LEFT].x += pad; | ||
131 | vps[screen][QUICKSCREEN_RIGHT].x -= pad; | ||
132 | /* need to add the pad to the bottom to make it all centered nicely */ | ||
133 | vps[screen][QUICKSCREEN_BOTTOM].x += pad; | ||
134 | vps[screen][QUICKSCREEN_BOTTOM].width -= pad; | ||
135 | } | ||
136 | vp_icons[screen].width = vps[screen][QUICKSCREEN_RIGHT].x - width; | ||
137 | |||
96 | } | 138 | } |
97 | display->getstringsize(option, &w, NULL); | 139 | } |
98 | if(w > display->width) | ||
99 | display->puts_scroll(0, puts_center-1+!statusbar, option); | ||
100 | else | ||
101 | display->putsxy(display->width -w-12, putsxy_center, option); | ||
102 | |||
103 | /* Displays the third line of text */ | ||
104 | option=(unsigned char *)option_select_get_text(qs->bottom_option); | ||
105 | title=(unsigned char *)qs->bottom_option->title; | ||
106 | |||
107 | display->getstringsize(title, &w, NULL); | ||
108 | if(w > display->width) | ||
109 | display->puts_scroll(0, puts_bottom-4+!statusbar, title); | ||
110 | else | ||
111 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*3), title); | ||
112 | 140 | ||
113 | display->getstringsize(option, &w, NULL); | 141 | static void quickscreen_draw_text(char *s, int item, bool title, |
114 | if(w > display->width) | 142 | struct screen *display, struct viewport *vp) |
115 | display->puts_scroll(0, puts_bottom-3+!statusbar, option); | 143 | { |
144 | int nb_lines = viewport_get_nb_lines(vp); | ||
145 | int w, h, line = 0, x=0; | ||
146 | display->getstringsize(s, &w, &h); | ||
147 | |||
148 | if (nb_lines > 1 && !title) | ||
149 | line = 1; | ||
150 | switch (item) | ||
151 | { | ||
152 | case QUICKSCREEN_BOTTOM: | ||
153 | x = (vp->width - w)/2; | ||
154 | break; | ||
155 | case QUICKSCREEN_LEFT: | ||
156 | x = 0; | ||
157 | break; | ||
158 | case QUICKSCREEN_RIGHT: | ||
159 | x = vp->width - w; | ||
160 | break; | ||
161 | } | ||
162 | if (w>vp->width) | ||
163 | display->puts_scroll(0,line,s); | ||
116 | else | 164 | else |
117 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*2), option); | 165 | display->putsxy(x, line*h, s); |
118 | display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], display->width/2-4, | ||
119 | putsxy_bottom-font_h, 7, 8); | ||
120 | |||
121 | gui_textarea_update(display); | ||
122 | display->setfont(FONT_UI); | ||
123 | } | 166 | } |
124 | 167 | ||
125 | /* | 168 | static void gui_quickscreen_draw(struct gui_quickscreen *qs, |
126 | * Draws the quickscreen on all available screens | 169 | struct screen *display, |
127 | * - qs : the quickscreen | 170 | struct viewport *parent) |
128 | */ | ||
129 | static void gui_syncquickscreen_draw(struct gui_quickscreen * qs) | ||
130 | { | 171 | { |
131 | int i; | 172 | int i; |
132 | FOR_NB_SCREENS(i) | 173 | char buf[MAX_PATH]; |
133 | gui_quickscreen_draw(qs, &screens[i]); | 174 | unsigned char *title, *value; |
175 | void *setting; | ||
176 | int temp; | ||
177 | display->set_viewport(parent); | ||
178 | display->clear_viewport(); | ||
179 | for (i=0; i<QUICKSCREEN_ITEM_COUNT; i++) | ||
180 | { | ||
181 | |||
182 | if (!qs->items[i]) | ||
183 | continue; | ||
184 | display->set_viewport(&vps[display->screen_type][i]); | ||
185 | display->scroll_stop(&vps[display->screen_type][i]); | ||
186 | |||
187 | title = P2STR(ID2P(qs->items[i]->lang_id)); | ||
188 | setting = qs->items[i]->setting; | ||
189 | if ((qs->items[i]->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | ||
190 | temp = *(bool*)setting?1:0; | ||
191 | else | ||
192 | temp = *(int*)setting; | ||
193 | value = option_get_valuestring((struct settings_list*)qs->items[i], buf, MAX_PATH, temp); | ||
194 | |||
195 | if (vps[display->screen_type][i].height < display->char_height*2) | ||
196 | { | ||
197 | char text[MAX_PATH]; | ||
198 | snprintf(text, MAX_PATH, "%s: %s", title, value); | ||
199 | quickscreen_draw_text(text, i, true, display, &vps[display->screen_type][i]); | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | quickscreen_draw_text(title, i, true, display, &vps[display->screen_type][i]); | ||
204 | quickscreen_draw_text(value, i, false, display, &vps[display->screen_type][i]); | ||
205 | } | ||
206 | display->update_viewport(); | ||
207 | } | ||
208 | /* draw the icons */ | ||
209 | display->set_viewport(&vp_icons[display->screen_type]); | ||
210 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | ||
211 | vp_icons[display->screen_type].width - 8, 0, 7, 8); | ||
212 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 0, 0, 7, 8); | ||
213 | display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], | ||
214 | (vp_icons[display->screen_type].width/2) - 4, | ||
215 | vp_icons[display->screen_type].height - 7, 7, 8); | ||
216 | display->update_viewport(); | ||
217 | |||
218 | display->set_viewport(parent); | ||
219 | display->update_viewport(); | ||
220 | display->set_viewport(NULL); | ||
134 | } | 221 | } |
135 | 222 | ||
223 | |||
136 | /* | 224 | /* |
137 | * Does the actions associated to the given button if any | 225 | * Does the actions associated to the given button if any |
138 | * - qs : the quickscreen | 226 | * - qs : the quickscreen |
@@ -141,48 +229,60 @@ static void gui_syncquickscreen_draw(struct gui_quickscreen * qs) | |||
141 | */ | 229 | */ |
142 | static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) | 230 | static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) |
143 | { | 231 | { |
144 | 232 | int item; | |
145 | switch(button) | 233 | switch(button) |
146 | { | 234 | { |
147 | case ACTION_QS_LEFT: | 235 | case ACTION_QS_LEFT: |
148 | option_select_next(qs->left_option); | 236 | item = QUICKSCREEN_LEFT; |
149 | return(true); | 237 | break; |
150 | 238 | ||
151 | case ACTION_QS_DOWN: | 239 | case ACTION_QS_DOWN: |
152 | option_select_next(qs->bottom_option); | 240 | case ACTION_QS_DOWNINV: |
153 | return(true); | 241 | item = QUICKSCREEN_BOTTOM; |
242 | break; | ||
154 | 243 | ||
155 | case ACTION_QS_RIGHT: | 244 | case ACTION_QS_RIGHT: |
156 | option_select_next(qs->right_option); | 245 | item = QUICKSCREEN_RIGHT; |
157 | return(true); | 246 | break; |
158 | 247 | ||
159 | case ACTION_QS_DOWNINV: | 248 | default: |
160 | option_select_prev(qs->bottom_option); | 249 | return false; |
161 | return(true); | ||
162 | } | 250 | } |
163 | return(false); | 251 | option_select_next_val((struct settings_list *)qs->items[item], false, true); |
252 | return true; | ||
164 | } | 253 | } |
165 | 254 | ||
166 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | 255 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) |
167 | { | 256 | { |
168 | int button; | 257 | int button, i; |
258 | struct viewport vp[NB_SCREENS]; | ||
259 | bool changed = false; | ||
169 | /* To quit we need either : | 260 | /* To quit we need either : |
170 | * - a second press on the button that made us enter | 261 | * - a second press on the button that made us enter |
171 | * - an action taken while pressing the enter button, | 262 | * - an action taken while pressing the enter button, |
172 | * then release the enter button*/ | 263 | * then release the enter button*/ |
173 | bool can_quit=false; | 264 | bool can_quit=false; |
174 | gui_syncquickscreen_draw(qs); | ||
175 | gui_syncstatusbar_draw(&statusbars, true); | 265 | gui_syncstatusbar_draw(&statusbars, true); |
266 | FOR_NB_SCREENS(i) | ||
267 | { | ||
268 | screens[i].set_viewport(NULL); | ||
269 | screens[i].stop_scroll(); | ||
270 | viewport_set_defaults(&vp[i], i); | ||
271 | quickscreen_fix_viewports(qs, &screens[i], &vp[i]); | ||
272 | gui_quickscreen_draw(qs, &screens[i], &vp[i]); | ||
273 | } | ||
176 | while (true) { | 274 | while (true) { |
177 | button = get_action(CONTEXT_QUICKSCREEN,TIMEOUT_BLOCK); | 275 | button = get_action(CONTEXT_QUICKSCREEN,TIMEOUT_BLOCK); |
178 | if(default_event_handler(button) == SYS_USB_CONNECTED) | 276 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
179 | return(true); | 277 | return(true); |
180 | if(gui_quickscreen_do_button(qs, button)) | 278 | if(gui_quickscreen_do_button(qs, button)) |
181 | { | 279 | { |
280 | changed = true; | ||
182 | can_quit=true; | 281 | can_quit=true; |
183 | if(qs->callback) | 282 | FOR_NB_SCREENS(i) |
283 | gui_quickscreen_draw(qs, &screens[i], &vp[i]); | ||
284 | if (qs->callback) | ||
184 | qs->callback(qs); | 285 | qs->callback(qs); |
185 | gui_syncquickscreen_draw(qs); | ||
186 | } | 286 | } |
187 | else if(button==button_enter) | 287 | else if(button==button_enter) |
188 | can_quit=true; | 288 | can_quit=true; |
@@ -195,8 +295,57 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | |||
195 | 295 | ||
196 | gui_syncstatusbar_draw(&statusbars, false); | 296 | gui_syncstatusbar_draw(&statusbars, false); |
197 | } | 297 | } |
198 | return false; | 298 | return changed; |
299 | } | ||
300 | |||
301 | bool quick_screen_quick(int button_enter) | ||
302 | { | ||
303 | struct gui_quickscreen qs; | ||
304 | bool oldshuffle = global_settings.playlist_shuffle; | ||
305 | int oldrepeat = global_settings.repeat_mode; | ||
306 | qs.items[QUICKSCREEN_LEFT] = find_setting(&global_settings.playlist_shuffle, NULL); | ||
307 | qs.items[QUICKSCREEN_RIGHT] = find_setting(&global_settings.repeat_mode, NULL); | ||
308 | qs.items[QUICKSCREEN_BOTTOM] = find_setting(&global_settings.dirfilter, NULL); | ||
309 | qs.callback = NULL; | ||
310 | if (gui_syncquickscreen_run(&qs, button_enter)) | ||
311 | { | ||
312 | settings_save(); | ||
313 | settings_apply(false); | ||
314 | /* make sure repeat/shuffle/any other nasty ones get updated */ | ||
315 | if ( oldrepeat != global_settings.repeat_mode && | ||
316 | (audio_status() & AUDIO_STATUS_PLAY) ) | ||
317 | { | ||
318 | audio_flush_and_reload_tracks(); | ||
319 | } | ||
320 | if (oldshuffle != global_settings.playlist_shuffle | ||
321 | && audio_status() & AUDIO_STATUS_PLAY) | ||
322 | { | ||
323 | #if CONFIG_CODEC == SWCODEC | ||
324 | dsp_set_replaygain(); | ||
325 | #endif | ||
326 | if (global_settings.playlist_shuffle) | ||
327 | playlist_randomise(NULL, current_tick, true); | ||
328 | else | ||
329 | playlist_sort(NULL, true); | ||
330 | } | ||
331 | } | ||
332 | return(0); | ||
199 | } | 333 | } |
200 | 334 | ||
201 | #endif /* HAVE_QUICKSCREEN */ | 335 | #ifdef BUTTON_F3 |
336 | bool quick_screen_f3(int button_enter) | ||
337 | { | ||
338 | struct gui_quickscreen qs; | ||
339 | qs.items[QUICKSCREEN_LEFT] = find_setting(&global_settings.scrollbar, NULL); | ||
340 | qs.items[QUICKSCREEN_RIGHT] = find_setting(&global_settings.statusbar, NULL); | ||
341 | qs.items[QUICKSCREEN_BOTTOM] = find_setting(&global_settings.flip_display, NULL); | ||
342 | qs.callback = NULL; | ||
343 | if (gui_syncquickscreen_run(&qs, button_enter)) | ||
344 | { | ||
345 | settings_save(); | ||
346 | settings_apply(false); | ||
347 | } | ||
348 | return(0); | ||
349 | } | ||
350 | #endif /* BUTTON_F3 */ | ||
202 | 351 | ||
diff --git a/apps/gui/quickscreen.h b/apps/gui/quickscreen.h index 179d619883..47361bd472 100644 --- a/apps/gui/quickscreen.h +++ b/apps/gui/quickscreen.h | |||
@@ -27,45 +27,28 @@ | |||
27 | #include "option_select.h" | 27 | #include "option_select.h" |
28 | #include "screen_access.h" | 28 | #include "screen_access.h" |
29 | 29 | ||
30 | struct gui_quickscreen; | 30 | enum QUICKSCREEN_ITEM { |
31 | /* | 31 | QUICKSCREEN_LEFT = 0, |
32 | * Callback function called each time the quickscreen gets modified | 32 | QUICKSCREEN_RIGHT, |
33 | * - qs : the quickscreen that did the modification | 33 | QUICKSCREEN_BOTTOM, |
34 | */ | 34 | QUICKSCREEN_ITEM_COUNT, |
35 | typedef void (quickscreen_callback)(struct gui_quickscreen * qs); | 35 | }; |
36 | 36 | ||
37 | struct gui_quickscreen | 37 | struct gui_quickscreen |
38 | { | 38 | { |
39 | struct option_select *left_option; | 39 | const struct settings_list *items[QUICKSCREEN_ITEM_COUNT]; |
40 | struct option_select *bottom_option; | 40 | void (*callback)(struct gui_quickscreen * qs); /* called after a |
41 | struct option_select *right_option; | 41 | item is changed */ |
42 | quickscreen_callback *callback; | ||
43 | }; | 42 | }; |
44 | 43 | ||
45 | /* | 44 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter); |
46 | * Initializes a quickscreen | 45 | |
47 | * - qs : the quickscreen | ||
48 | * - left_option, bottom_option, right_option : a list of choices | ||
49 | * for each option | ||
50 | * - left_right_title : the 2nd line of the title | ||
51 | * on the left and on the right | ||
52 | * - callback : a callback function called each time the quickscreen | ||
53 | * gets modified | ||
54 | */ | ||
55 | void gui_quickscreen_init(struct gui_quickscreen * qs, | ||
56 | struct option_select *left_option, | ||
57 | struct option_select *bottom_option, | ||
58 | struct option_select *right_option, | ||
59 | quickscreen_callback *callback); | ||
60 | 46 | ||
47 | #ifdef BUTTON_F3 | ||
48 | extern bool quick_screen_f3(int button_enter); | ||
49 | #endif | ||
50 | extern bool quick_screen_quick(int button_enter); | ||
61 | 51 | ||
62 | /* | ||
63 | * Runs the quickscreen on all available screens, if button_enter is released, quits | ||
64 | * - qs : the quickscreen | ||
65 | * - button_enter : button pressed at the same time the quickscreen is displayed | ||
66 | * returns : true if usb was connected, false otherwise | ||
67 | */ | ||
68 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter); | ||
69 | 52 | ||
70 | #endif /*_GUI_QUICK_SCREEN_H_*/ | 53 | #endif /*_GUI_QUICK_SCREEN_H_*/ |
71 | #endif /* HAVE_QUICKSCREEN */ | 54 | #endif /* HAVE_QUICKSCREEN */ |