diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps.c | 1 | ||||
-rw-r--r-- | apps/gui/option_select.c | 63 | ||||
-rw-r--r-- | apps/gui/option_select.h | 5 | ||||
-rw-r--r-- | apps/gui/quickscreen.c | 334 | ||||
-rw-r--r-- | apps/gui/quickscreen.h | 49 |
5 files changed, 276 insertions, 176 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index ad9fce7a8f..e75c16aa07 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include "cuesheet.h" | 56 | #include "cuesheet.h" |
57 | #include "ata_idle_notify.h" | 57 | #include "ata_idle_notify.h" |
58 | #include "root_menu.h" | 58 | #include "root_menu.h" |
59 | #include "quickscreen.h" | ||
59 | 60 | ||
60 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) | 61 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) |
61 | #include "backdrop.h" | 62 | #include "backdrop.h" |
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index cb5b6eee36..b4b1b716bb 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,19 +210,20 @@ static int option_talk(int selected_item, void * data) | |||
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | #if 0 | 213 | |
214 | int option_select_next_val(struct settings_list *setting, | 214 | void option_select_next_val(struct settings_list *setting) |
215 | intptr_t temp_var) | ||
216 | { | 215 | { |
217 | int val = 0; | 216 | int val = 0; |
217 | int *value = setting->setting; | ||
218 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 218 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) |
219 | { | 219 | { |
220 | val = (bool)temp_var ? 0 : 1; | 220 | *(bool*)value = !*(bool*)value; |
221 | return; | ||
221 | } | 222 | } |
222 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | 223 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) |
223 | { | 224 | { |
224 | struct int_setting *info = setting->int_setting; | 225 | struct int_setting *info = (struct int_setting *)setting->int_setting; |
225 | val = (int)temp_var + info->step; | 226 | val = *value + info->step; |
226 | if (val > info->max) | 227 | if (val > info->max) |
227 | val = info->min; | 228 | val = info->min; |
228 | } | 229 | } |
@@ -232,55 +233,19 @@ int option_select_next_val(struct settings_list *setting, | |||
232 | int steps = sound_steps(setting_id); | 233 | int steps = sound_steps(setting_id); |
233 | int min = sound_min(setting_id); | 234 | int min = sound_min(setting_id); |
234 | int max = sound_max(setting_id); | 235 | int max = sound_max(setting_id); |
235 | val = (int)temp_var + steps; | 236 | val = *value + steps; |
236 | if (val > max) | 237 | if (val >= max) |
237 | val = min; | 238 | val = min; |
238 | } | 239 | } |
239 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | 240 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) |
240 | { | 241 | { |
241 | struct choice_setting *info = setting->choice_setting; | 242 | struct choice_setting *info = (struct choice_setting *)setting->choice_setting; |
242 | val = (int)temp_var; | 243 | val = *value + 1; |
243 | if (val > info->count) | 244 | if (val >= info->count) |
244 | val = 0; | 245 | val = 0; |
245 | } | 246 | } |
246 | return val; | 247 | *value = val; |
247 | } | ||
248 | |||
249 | int option_select_prev_val(struct settings_list *setting, | ||
250 | intptr_t temp_var) | ||
251 | { | ||
252 | int val = 0; | ||
253 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | ||
254 | { | ||
255 | val = (bool)temp_var ? 0 : 1; | ||
256 | } | ||
257 | else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) | ||
258 | { | ||
259 | struct int_setting *info = setting->int_setting; | ||
260 | val = (int)temp_var - info->step; | ||
261 | if (val < info->min) | ||
262 | val = info->max; | ||
263 | } | ||
264 | else if ((setting->flags & F_T_SOUND) == F_T_SOUND) | ||
265 | { | ||
266 | int setting_id = setting->sound_setting->setting; | ||
267 | int steps = sound_steps(setting_id); | ||
268 | int min = sound_min(setting_id); | ||
269 | int max = sound_max(setting_id); | ||
270 | val = (int)temp_var -+ steps; | ||
271 | if (val < min) | ||
272 | val = max; | ||
273 | } | ||
274 | else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) | ||
275 | { | ||
276 | struct choice_setting *info = setting->choice_setting; | ||
277 | val = (int)temp_var; | ||
278 | if (val < 0) | ||
279 | val = info->count - 1; | ||
280 | } | ||
281 | return val; | ||
282 | } | 248 | } |
283 | #endif | ||
284 | 249 | ||
285 | static int selection_to_val(struct settings_list *setting, int selection) | 250 | static int selection_to_val(struct settings_list *setting, int selection) |
286 | { | 251 | { |
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index e46570f303..63299bc599 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h | |||
@@ -65,4 +65,9 @@ extern void option_select_next(struct option_select * opt); | |||
65 | */ | 65 | */ |
66 | extern void option_select_prev(struct option_select * opt); | 66 | extern void option_select_prev(struct option_select * opt); |
67 | 67 | ||
68 | |||
69 | void option_select_next_val(struct settings_list *setting); | ||
70 | char *option_get_valuestring(struct settings_list *setting, | ||
71 | char *buffer, int buf_len, | ||
72 | intptr_t temp_var); | ||
68 | #endif /* _GUI_OPTION_SELECT_H_ */ | 73 | #endif /* _GUI_OPTION_SELECT_H_ */ |
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index c2da5879fe..f0eafb7299 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. |
@@ -30,109 +30,198 @@ | |||
30 | #include "misc.h" | 30 | #include "misc.h" |
31 | #include "statusbar.h" | 31 | #include "statusbar.h" |
32 | #include "action.h" | 32 | #include "action.h" |
33 | #include "settings_list.h" | ||
34 | #include "lang.h" | ||
35 | #include "option_select.h" | ||
33 | 36 | ||
34 | void gui_quickscreen_init(struct gui_quickscreen * qs, | 37 | static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT]; |
35 | struct option_select *left_option, | ||
36 | struct option_select *bottom_option, | ||
37 | struct option_select *right_option, | ||
38 | quickscreen_callback callback) | ||
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 | 38 | ||
46 | /* | 39 | static void quickscreen_fix_viewports(struct gui_quickscreen *qs, |
47 | * Draws the quickscreen on a given screen | 40 | struct screen *display, |
48 | * - qs : the quickscreen | 41 | struct viewport *parent) |
49 | * - display : the screen to draw on | ||
50 | */ | ||
51 | static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display) | ||
52 | { | 42 | { |
53 | const unsigned char *option; | 43 | int height, i, count=0, top; |
54 | const unsigned char *title; | 44 | int nb_lines = parent->height/display->char_height; |
55 | int w, font_h; | 45 | bool single_line_bottom = false; |
56 | bool statusbar = global_settings.statusbar; | 46 | |
57 | #ifdef HAS_BUTTONBAR | 47 | for(i=0; i<QUICKSCREEN_ITEM_COUNT; i++) |
58 | display->has_buttonbar=false; | ||
59 | #endif | ||
60 | gui_textarea_clear(display); | ||
61 | if (display->height / display->char_height < 7) /* we need at leats 7 lines */ | ||
62 | { | 48 | { |
63 | display->setfont(FONT_SYSFIXED); | 49 | if (qs->items[i]) |
50 | count++; | ||
51 | vps[display->screen_type][i] = *parent; | ||
64 | } | 52 | } |
65 | display->getstringsize("A", NULL, &font_h); | 53 | |
66 | 54 | /* special handling when there is only enough room for 2 items. | |
67 | /* do these calculations once */ | 55 | discard the top and bottom items, so only show the 2 side ones */ |
68 | const unsigned int puts_center = display->height/2/font_h; | 56 | if (nb_lines < 4) |
69 | const unsigned int puts_bottom = display->height/font_h; | ||
70 | const unsigned int putsxy_center = display->height/2; | ||
71 | const unsigned int putsxy_bottom = display->height; | ||
72 | |||
73 | /* Displays the first line of text */ | ||
74 | option=(unsigned char *)option_select_get_text(qs->left_option); | ||
75 | title=(unsigned char *)qs->left_option->title; | ||
76 | display->puts_scroll(2, puts_center-4+!statusbar, title); | ||
77 | display->puts_scroll(2, puts_center-3+!statusbar, option); | ||
78 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, | ||
79 | putsxy_center-(font_h*3), 7, 8); | ||
80 | |||
81 | /* Displays the second line of text */ | ||
82 | option=(unsigned char *)option_select_get_text(qs->right_option); | ||
83 | title=(unsigned char *)qs->right_option->title; | ||
84 | display->getstringsize(title, &w, NULL); | ||
85 | if(w > display->width - 8) | ||
86 | { | 57 | { |
87 | display->puts_scroll(2, puts_center-2+!statusbar, title); | 58 | qs->items[QUICKSCREEN_TOP] = NULL; |
88 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1, | 59 | qs->items[QUICKSCREEN_BOTTOM] = NULL; |
89 | putsxy_center-font_h, 7, 8); | 60 | vps[display->screen_type][QUICKSCREEN_RIGHT].y = parent->y; |
61 | vps[display->screen_type][QUICKSCREEN_LEFT].height = parent->height/2; | ||
62 | vps[display->screen_type][QUICKSCREEN_RIGHT].y = parent->y+parent->height/2; | ||
63 | vps[display->screen_type][QUICKSCREEN_RIGHT].height = parent->height/2; | ||
64 | return; | ||
90 | } | 65 | } |
91 | else | 66 | else if (nb_lines < 5 && count == 4) /* drop the top item */ |
92 | { | 67 | { |
93 | display->putsxy(display->width - w - 12, putsxy_center-font_h, title); | 68 | qs->items[QUICKSCREEN_TOP] = NULL; |
94 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | 69 | single_line_bottom = true; |
95 | display->width - 8, putsxy_center-font_h, 7, 8); | 70 | } |
71 | |||
72 | height = display->char_height*2; | ||
73 | if (nb_lines > 8 || | ||
74 | (nb_lines > 5 && qs->items[QUICKSCREEN_TOP] == NULL)) | ||
75 | height += display->char_height; | ||
76 | /* Top item */ | ||
77 | if (qs->items[QUICKSCREEN_TOP]) | ||
78 | { | ||
79 | vps[display->screen_type][QUICKSCREEN_TOP].y = parent->y; | ||
80 | vps[display->screen_type][QUICKSCREEN_TOP].height = height; | ||
96 | } | 81 | } |
97 | display->getstringsize(option, &w, NULL); | ||
98 | if(w > display->width) | ||
99 | display->puts_scroll(0, puts_center-1+!statusbar, option); | ||
100 | else | 82 | else |
101 | display->putsxy(display->width -w-12, putsxy_center, option); | 83 | { |
102 | 84 | vps[display->screen_type][QUICKSCREEN_TOP].height = 0; | |
103 | /* Displays the third line of text */ | 85 | } |
104 | option=(unsigned char *)option_select_get_text(qs->bottom_option); | 86 | /* bottom item */ |
105 | title=(unsigned char *)qs->bottom_option->title; | 87 | if (qs->items[QUICKSCREEN_BOTTOM]) |
106 | 88 | { | |
107 | display->getstringsize(title, &w, NULL); | 89 | if (single_line_bottom) |
108 | if(w > display->width) | 90 | height = display->char_height; |
109 | display->puts_scroll(0, puts_bottom-4+!statusbar, title); | 91 | vps[display->screen_type][QUICKSCREEN_BOTTOM].y = parent->y+parent->height - height; |
92 | vps[display->screen_type][QUICKSCREEN_BOTTOM].height = height; | ||
93 | } | ||
110 | else | 94 | else |
111 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*3), title); | 95 | { |
96 | vps[display->screen_type][QUICKSCREEN_BOTTOM].height = 0; | ||
97 | } | ||
98 | |||
99 | /* side items */ | ||
100 | height = parent->height - | ||
101 | vps[display->screen_type][QUICKSCREEN_BOTTOM].height - | ||
102 | vps[display->screen_type][QUICKSCREEN_TOP].height ; | ||
103 | top = parent->y+vps[display->screen_type][QUICKSCREEN_TOP].height; | ||
104 | vps[display->screen_type][QUICKSCREEN_LEFT].y = top; | ||
105 | vps[display->screen_type][QUICKSCREEN_RIGHT].y = top; | ||
106 | vps[display->screen_type][QUICKSCREEN_LEFT].height = height; | ||
107 | vps[display->screen_type][QUICKSCREEN_RIGHT].height = height; | ||
108 | |||
109 | vps[display->screen_type][QUICKSCREEN_RIGHT].x = parent->x+parent->width/2; | ||
110 | |||
111 | vps[display->screen_type][QUICKSCREEN_LEFT].width = parent->width/2; | ||
112 | vps[display->screen_type][QUICKSCREEN_RIGHT].width = parent->width/2; | ||
113 | } | ||
112 | 114 | ||
113 | display->getstringsize(option, &w, NULL); | 115 | static void quickscreen_draw_text(char *s, int item, bool title, |
114 | if(w > display->width) | 116 | struct screen *display, struct viewport *vp) |
115 | display->puts_scroll(0, puts_bottom-3+!statusbar, option); | 117 | { |
118 | int nb_lines = vp->height/display->char_height; | ||
119 | int w, line = 0, x=0; | ||
120 | display->getstringsize(s, &w, NULL); | ||
121 | switch (item) | ||
122 | { | ||
123 | case QUICKSCREEN_TOP: | ||
124 | if (nb_lines > 2) | ||
125 | { | ||
126 | if (title) | ||
127 | { | ||
128 | display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], | ||
129 | (vp->width/2)-4, 0, 7, 8); | ||
130 | line = 1; | ||
131 | } | ||
132 | else | ||
133 | line = 2; | ||
134 | } | ||
135 | else | ||
136 | line = title?0:1; | ||
137 | x = (vp->width - w)/2; | ||
138 | break; | ||
139 | case QUICKSCREEN_BOTTOM: | ||
140 | if (title && nb_lines > 2 && item == QUICKSCREEN_BOTTOM) | ||
141 | { | ||
142 | display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], | ||
143 | (vp->width/2)-4, vp->height-8, 7, 8); | ||
144 | } | ||
145 | line = title?0:1; | ||
146 | x = (vp->width - w)/2; | ||
147 | break; | ||
148 | case QUICKSCREEN_LEFT: | ||
149 | if (nb_lines > 1) | ||
150 | { | ||
151 | line = nb_lines/2; | ||
152 | if (title) | ||
153 | line--; | ||
154 | } | ||
155 | else | ||
156 | line = 0; | ||
157 | if (title) | ||
158 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, | ||
159 | line*display->char_height+display->char_height/2, 7, 8); | ||
160 | x = 12; | ||
161 | break; | ||
162 | case QUICKSCREEN_RIGHT: | ||
163 | line = nb_lines/2; | ||
164 | if (title == false) | ||
165 | line++; | ||
166 | if (title) | ||
167 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | ||
168 | vp->width - 8, | ||
169 | line*display->char_height+display->char_height/2, 7, 8); | ||
170 | x = vp->width - w - 12; | ||
171 | break; | ||
172 | } | ||
173 | if (w>vp->width) | ||
174 | display->puts_scroll(0,line,s); | ||
116 | else | 175 | else |
117 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*2), option); | 176 | display->putsxy(x, line*display->char_height, 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 | } | 177 | } |
124 | 178 | ||
125 | /* | 179 | static void gui_quickscreen_draw(struct gui_quickscreen *qs, |
126 | * Draws the quickscreen on all available screens | 180 | struct screen *display, |
127 | * - qs : the quickscreen | 181 | struct viewport *parent) |
128 | */ | ||
129 | static void gui_syncquickscreen_draw(struct gui_quickscreen * qs) | ||
130 | { | 182 | { |
131 | int i; | 183 | int i; |
132 | FOR_NB_SCREENS(i) | 184 | char buf[MAX_PATH]; |
133 | gui_quickscreen_draw(qs, &screens[i]); | 185 | unsigned char *title, *value; |
186 | void *setting; | ||
187 | int temp; | ||
188 | display->set_viewport(parent); | ||
189 | display->clear_viewport(); | ||
190 | for (i=0; i<QUICKSCREEN_ITEM_COUNT; i++) | ||
191 | { | ||
192 | |||
193 | if (!qs->items[i]) | ||
194 | continue; | ||
195 | display->set_viewport(&vps[display->screen_type][i]); | ||
196 | display->scroll_stop(&vps[display->screen_type][i]); | ||
197 | |||
198 | title = P2STR(ID2P(qs->items[i]->lang_id)); | ||
199 | setting = qs->items[i]->setting; | ||
200 | if (qs->items[i]->flags&F_T_BOOL) | ||
201 | temp = *(bool*)setting?1:0; | ||
202 | else | ||
203 | temp = *(int*)setting; | ||
204 | value = option_get_valuestring((struct settings_list*)qs->items[i], buf, MAX_PATH, temp); | ||
205 | |||
206 | if (vps[display->screen_type][i].height < display->char_height*2) | ||
207 | { | ||
208 | char text[MAX_PATH]; | ||
209 | snprintf(text, MAX_PATH, "%s: %s", title, value); | ||
210 | quickscreen_draw_text(text, i, true, display, &vps[display->screen_type][i]); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | quickscreen_draw_text(title, i, true, display, &vps[display->screen_type][i]); | ||
215 | quickscreen_draw_text(value, i, false, display, &vps[display->screen_type][i]); | ||
216 | } | ||
217 | display->update_viewport(); | ||
218 | } | ||
219 | display->set_viewport(parent); | ||
220 | display->update_viewport(); | ||
221 | display->set_viewport(NULL); | ||
134 | } | 222 | } |
135 | 223 | ||
224 | |||
136 | /* | 225 | /* |
137 | * Does the actions associated to the given button if any | 226 | * Does the actions associated to the given button if any |
138 | * - qs : the quickscreen | 227 | * - qs : the quickscreen |
@@ -141,23 +230,26 @@ static void gui_syncquickscreen_draw(struct gui_quickscreen * qs) | |||
141 | */ | 230 | */ |
142 | static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) | 231 | static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) |
143 | { | 232 | { |
144 | |||
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 | if (qs->items[QUICKSCREEN_LEFT]) |
237 | option_select_next_val((struct settings_list *)qs->items[QUICKSCREEN_LEFT]); | ||
149 | return(true); | 238 | return(true); |
150 | 239 | ||
151 | case ACTION_QS_DOWN: | 240 | case ACTION_QS_DOWN: |
152 | option_select_next(qs->bottom_option); | 241 | if (qs->items[QUICKSCREEN_BOTTOM]) |
242 | option_select_next_val((struct settings_list *)qs->items[QUICKSCREEN_BOTTOM]); | ||
153 | return(true); | 243 | return(true); |
154 | 244 | ||
155 | case ACTION_QS_RIGHT: | 245 | case ACTION_QS_RIGHT: |
156 | option_select_next(qs->right_option); | 246 | if (qs->items[QUICKSCREEN_RIGHT]) |
247 | option_select_next_val((struct settings_list *)qs->items[QUICKSCREEN_RIGHT]); | ||
157 | return(true); | 248 | return(true); |
158 | 249 | ||
159 | case ACTION_QS_DOWNINV: | 250 | case ACTION_QS_DOWNINV: |
160 | option_select_prev(qs->bottom_option); | 251 | if (qs->items[QUICKSCREEN_TOP]) |
252 | option_select_next_val((struct settings_list *)qs->items[QUICKSCREEN_TOP]); | ||
161 | return(true); | 253 | return(true); |
162 | } | 254 | } |
163 | return(false); | 255 | return(false); |
@@ -165,24 +257,48 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) | |||
165 | 257 | ||
166 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | 258 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) |
167 | { | 259 | { |
168 | int button; | 260 | int button, i; |
261 | bool changed = false; | ||
262 | struct viewport vp[NB_SCREENS]; | ||
169 | /* To quit we need either : | 263 | /* To quit we need either : |
170 | * - a second press on the button that made us enter | 264 | * - a second press on the button that made us enter |
171 | * - an action taken while pressing the enter button, | 265 | * - an action taken while pressing the enter button, |
172 | * then release the enter button*/ | 266 | * then release the enter button*/ |
173 | bool can_quit=false; | 267 | bool can_quit=false; |
174 | gui_syncquickscreen_draw(qs); | ||
175 | gui_syncstatusbar_draw(&statusbars, true); | 268 | gui_syncstatusbar_draw(&statusbars, true); |
269 | FOR_NB_SCREENS(i) | ||
270 | { | ||
271 | vp[i].x = 0; | ||
272 | vp[i].width = screens[i].width; | ||
273 | vp[i].y = STATUSBAR_HEIGHT; | ||
274 | vp[i].height = screens[i].height - STATUSBAR_HEIGHT; | ||
275 | #ifdef HAVE_LCD_COLOR | ||
276 | if (screens[i].is_color) | ||
277 | { | ||
278 | vp[i].fg_pattern = screens[i].get_foreground(); | ||
279 | vp[i].bg_pattern = screens[i].get_background(); | ||
280 | } | ||
281 | #endif | ||
282 | vp[i].xmargin = 0; | ||
283 | vp[i].ymargin = 0; | ||
284 | vp[i].font = FONT_UI; | ||
285 | vp[i].drawmode = STYLE_DEFAULT; | ||
286 | quickscreen_fix_viewports(qs, &screens[i], &vp[i]); | ||
287 | gui_quickscreen_draw(qs, &screens[i], &vp[i]); | ||
288 | } | ||
176 | while (true) { | 289 | while (true) { |
177 | button = get_action(CONTEXT_QUICKSCREEN,TIMEOUT_BLOCK); | 290 | button = get_action(CONTEXT_QUICKSCREEN,TIMEOUT_BLOCK); |
178 | if(default_event_handler(button) == SYS_USB_CONNECTED) | 291 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
179 | return(true); | 292 | return(true); |
180 | if(gui_quickscreen_do_button(qs, button)) | 293 | if(gui_quickscreen_do_button(qs, button)) |
181 | { | 294 | { |
295 | changed = true; | ||
182 | can_quit=true; | 296 | can_quit=true; |
183 | if(qs->callback) | 297 | if (button == ACTION_QS_DOWNINV && |
184 | qs->callback(qs); | 298 | !qs->items[QUICKSCREEN_TOP]) |
185 | gui_syncquickscreen_draw(qs); | 299 | break; |
300 | FOR_NB_SCREENS(i) | ||
301 | gui_quickscreen_draw(qs, &screens[i], &vp[i]); | ||
186 | } | 302 | } |
187 | else if(button==button_enter) | 303 | else if(button==button_enter) |
188 | can_quit=true; | 304 | can_quit=true; |
@@ -195,8 +311,36 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | |||
195 | 311 | ||
196 | gui_syncstatusbar_draw(&statusbars, false); | 312 | gui_syncstatusbar_draw(&statusbars, false); |
197 | } | 313 | } |
314 | if (changed) | ||
315 | settings_apply(); | ||
198 | return false; | 316 | return false; |
199 | } | 317 | } |
200 | 318 | ||
319 | bool quick_screen_quick(int button_enter) | ||
320 | { | ||
321 | struct gui_quickscreen qs; | ||
322 | qs.items[QUICKSCREEN_LEFT] = find_setting_from_string(global_settings.quickscreen_left, NULL); | ||
323 | qs.items[QUICKSCREEN_RIGHT] = find_setting_from_string(global_settings.quickscreen_right,NULL); | ||
324 | qs.items[QUICKSCREEN_BOTTOM] = find_setting_from_string(global_settings.quickscreen_bottom, NULL); | ||
325 | qs.items[QUICKSCREEN_TOP] = find_setting_from_string(global_settings.quickscreen_top,NULL); | ||
326 | qs.callback = NULL; | ||
327 | gui_syncquickscreen_run(&qs, button_enter); | ||
328 | return(0); | ||
329 | } | ||
330 | |||
331 | #ifdef BUTTON_F3 | ||
332 | bool quick_screen_f3(int button_enter) | ||
333 | { | ||
334 | struct gui_quickscreen qs; | ||
335 | qs.items[QUICKSCREEN_LEFT] = find_setting(&global_settings.scrollbar, NULL); | ||
336 | qs.items[QUICKSCREEN_RIGHT] = find_setting(&global_settings.statusbar, NULL); | ||
337 | qs.items[QUICKSCREEN_BOTTOM] = find_setting(&global_settings.flip_display, NULL); | ||
338 | qs.items[QUICKSCREEN_TOP] = NULL; | ||
339 | qs.callback = NULL; | ||
340 | gui_syncquickscreen_run(&qs, button_enter); | ||
341 | return(0); | ||
342 | } | ||
343 | #endif /* BUTTON_F3 */ | ||
344 | |||
201 | #endif /* HAVE_QUICKSCREEN */ | 345 | #endif /* HAVE_QUICKSCREEN */ |
202 | 346 | ||
diff --git a/apps/gui/quickscreen.h b/apps/gui/quickscreen.h index 179d619883..a264a9383d 100644 --- a/apps/gui/quickscreen.h +++ b/apps/gui/quickscreen.h | |||
@@ -27,45 +27,30 @@ | |||
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_TOP, |
34 | */ | 34 | QUICKSCREEN_BOTTOM, |
35 | typedef void (quickscreen_callback)(struct gui_quickscreen * qs); | 35 | QUICKSCREEN_ITEM_COUNT, |
36 | }; | ||
36 | 37 | ||
37 | struct gui_quickscreen | 38 | struct gui_quickscreen |
38 | { | 39 | { |
39 | struct option_select *left_option; | 40 | const struct settings_list *items[QUICKSCREEN_ITEM_COUNT]; |
40 | struct option_select *bottom_option; | 41 | void (*callback)(struct gui_quickscreen * qs); |
41 | struct option_select *right_option; | ||
42 | quickscreen_callback *callback; | ||
43 | }; | 42 | }; |
44 | 43 | ||
45 | /* | ||
46 | * Initializes a quickscreen | ||
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 | 44 | ||
61 | 45 | struct gui_quickscreen; | |
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); | 46 | bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter); |
69 | 47 | ||
48 | |||
49 | #ifdef BUTTON_F3 | ||
50 | extern bool quick_screen_f3(int button_enter); | ||
51 | #endif | ||
52 | extern bool quick_screen_quick(int button_enter); | ||
53 | |||
54 | |||
70 | #endif /*_GUI_QUICK_SCREEN_H_*/ | 55 | #endif /*_GUI_QUICK_SCREEN_H_*/ |
71 | #endif /* HAVE_QUICKSCREEN */ | 56 | #endif /* HAVE_QUICKSCREEN */ |