Index: apps/screens.c =================================================================== --- apps/screens.c (revision 16203) +++ apps/screens.c (working copy) @@ -645,145 +645,81 @@ static void quick_screen_quick_apply(struct gui_quickscreen *qs) { - global_settings.playlist_shuffle=int_to_bool(qs->left_option->option); - global_settings.dirfilter=qs->bottom_option->option; - global_settings.repeat_mode=qs->right_option->option; +// global_settings.playlist_shuffle=int_to_bool(qs->left_option->option); + // global_settings.dirfilter=qs->bottom_option->option; + //global_settings.repeat_mode=qs->right_option->option; } bool quick_screen_quick(int button_enter) { - bool res, oldshuffle; - struct option_select left_option; - struct option_select bottom_option; - struct option_select right_option; - int oldrepeat, old_x_margin, old_y_margin; - - static const struct opt_items left_items[] = { - [0]={ STR(LANG_SYSFONT_OFF) }, - [1]={ STR(LANG_SYSFONT_ON) } - }; - static const struct opt_items bottom_items[] = { - [SHOW_ALL]={ STR(LANG_SYSFONT_ALL) }, - [SHOW_SUPPORTED]={ STR(LANG_SYSFONT_FILTER_SUPPORTED) }, - [SHOW_MUSIC]={ STR(LANG_SYSFONT_FILTER_MUSIC) }, - [SHOW_PLAYLIST]={ STR(LANG_SYSFONT_FILTER_PLAYLIST) }, - }; - static const struct opt_items right_items[] = { - [REPEAT_OFF]={ STR(LANG_SYSFONT_OFF) }, - [REPEAT_ALL]={ STR(LANG_SYSFONT_ALL) }, - [REPEAT_ONE]={ STR(LANG_SYSFONT_REPEAT_ONE) }, - [REPEAT_SHUFFLE]={ STR(LANG_SYSFONT_SHUFFLE) }, -#ifdef AB_REPEAT_ENABLE - [REPEAT_AB]={ STR(LANG_SYSFONT_REPEAT_AB) } -#endif - }; struct gui_quickscreen qs; - - old_x_margin = lcd_getxmargin(); - old_y_margin = lcd_getymargin(); - lcd_setmargins(0, 0); - - option_select_init_items(&left_option, - (char *)str(LANG_SYSFONT_SHUFFLE), - bool_to_int(global_settings.playlist_shuffle), - left_items, - 2); - option_select_init_items(&bottom_option, - (char *)str(LANG_SYSFONT_FILTER), - global_settings.dirfilter, - bottom_items, - sizeof(bottom_items)/sizeof(struct opt_items)); - option_select_init_items(&right_option, - (char *)str(LANG_SYSFONT_REPEAT), - global_settings.repeat_mode, - right_items, - sizeof(right_items)/sizeof(struct opt_items)); - - gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option, - &quick_screen_quick_apply); - oldrepeat=global_settings.repeat_mode; - oldshuffle=global_settings.playlist_shuffle; - res=gui_syncquickscreen_run(&qs, button_enter); - if(!res) - { - if ( oldrepeat != global_settings.repeat_mode && - (audio_status() & AUDIO_STATUS_PLAY) ) - audio_flush_and_reload_tracks(); - if(oldshuffle != global_settings.playlist_shuffle - && audio_status() & AUDIO_STATUS_PLAY) - { -#if CONFIG_CODEC == SWCODEC - dsp_set_replaygain(); -#endif - if (global_settings.playlist_shuffle) - playlist_randomise(NULL, current_tick, true); - else - playlist_sort(NULL, true); - } - settings_save(); - } - lcd_setmargins(old_x_margin, old_y_margin); - return(res); + qs.items[QUICKSCREEN_LEFT] = find_setting(&global_settings.playlist_shuffle, NULL); + qs.items[QUICKSCREEN_RIGHT] = find_setting(&global_settings.repeat_mode, NULL); + qs.items[QUICKSCREEN_BOTTOM] = find_setting(&global_settings.dirfilter, NULL); + qs.items[QUICKSCREEN_TOP] = find_setting(&global_settings.next_folder, NULL);; + qs.callback = NULL; + gui_syncquickscreen_run(&qs, button_enter); + return(0); } #ifdef BUTTON_F3 static void quick_screen_f3_apply(struct gui_quickscreen *qs) { - global_settings.scrollbar=int_to_bool(qs->left_option->option); +/* global_settings.scrollbar=int_to_bool(qs->left_option->option); global_settings.flip_display=int_to_bool(qs->bottom_option->option); button_set_flip(global_settings.flip_display); lcd_set_flip(global_settings.flip_display); global_settings.statusbar=int_to_bool(qs->right_option->option); - gui_syncstatusbar_draw(&statusbars, true); + gui_syncstatusbar_draw(&statusbars, true);*/ } bool quick_screen_f3(int button_enter) { - bool res; - struct option_select left_option; - struct option_select bottom_option; - struct option_select right_option; - int old_x_margin, old_y_margin; - - static const struct opt_items onoff_items[] = { - [0]={ STR(LANG_SYSFONT_OFF) }, - [1]={ STR(LANG_SYSFONT_ON) } - }; - static const struct opt_items yesno_items[] = { - [0]={ STR(LANG_SYSFONT_SET_BOOL_NO) }, - [1]={ STR(LANG_SYSFONT_SET_BOOL_YES) } - }; - - struct gui_quickscreen qs; - - old_x_margin = lcd_getxmargin(); - old_y_margin = lcd_getymargin(); - lcd_setmargins(0, 0); - - option_select_init_items(&left_option, - str(LANG_SYSFONT_SCROLL_BAR), - bool_to_int(global_settings.scrollbar), - onoff_items, - 2); - option_select_init_items(&bottom_option, - str(LANG_SYSFONT_FLIP_DISPLAY), - bool_to_int(global_settings.flip_display), - yesno_items, - 2); - option_select_init_items(&right_option, - str(LANG_SYSFONT_STATUS_BAR), - bool_to_int(global_settings.statusbar), - onoff_items, - 2); - gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option, - &quick_screen_f3_apply); - res=gui_syncquickscreen_run(&qs, button_enter); - if(!res) - settings_save(); - lcd_setmargins(old_x_margin, old_y_margin); - return(res); +// bool res; +// struct option_select left_option; +// struct option_select bottom_option; +// struct option_select right_option; +// int old_x_margin, old_y_margin; +// +// static const struct opt_items onoff_items[] = { +// [0]={ STR(LANG_SYSFONT_OFF) }, +// [1]={ STR(LANG_SYSFONT_ON) } +// }; +// static const struct opt_items yesno_items[] = { +// [0]={ STR(LANG_SYSFONT_SET_BOOL_NO) }, +// [1]={ STR(LANG_SYSFONT_SET_BOOL_YES) } +// }; +// +// struct gui_quickscreen qs; +// +// old_x_margin = lcd_getxmargin(); +// old_y_margin = lcd_getymargin(); +// lcd_setmargins(0, 0); +// +// option_select_init_items(&left_option, +// str(LANG_SYSFONT_SCROLL_BAR), +// bool_to_int(global_settings.scrollbar), +// onoff_items, +// 2); +// option_select_init_items(&bottom_option, +// str(LANG_SYSFONT_FLIP_DISPLAY), +// bool_to_int(global_settings.flip_display), +// yesno_items, +// 2); +// option_select_init_items(&right_option, +// str(LANG_SYSFONT_STATUS_BAR), +// bool_to_int(global_settings.statusbar), +// onoff_items, +// 2); +// gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option, +// &quick_screen_f3_apply); +// res=gui_syncquickscreen_run(&qs, button_enter); +// if(!res) +// settings_save(); +// lcd_setmargins(old_x_margin, old_y_margin); +// return(res); } #endif /* BUTTON_F3 */ #endif /* CONFIG_KEYPAD in (RECORDER_PAD |IRIVER_H100_PAD | IRIVER_H300_PAD) */ Index: apps/gui/option_select.c =================================================================== --- apps/gui/option_select.c (revision 16203) +++ apps/gui/option_select.c (working copy) @@ -60,7 +60,7 @@ /* these two vars are needed so arbitrary values can be added to the TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */ static int table_setting_oldval = 0, table_setting_array_position = 0; -static char *option_get_valuestring(struct settings_list *setting, +char *option_get_valuestring(struct settings_list *setting, char *buffer, int buf_len, intptr_t temp_var) { @@ -210,19 +210,20 @@ } return 0; } -#if 0 -int option_select_next_val(struct settings_list *setting, - intptr_t temp_var) + +void option_select_next_val(struct settings_list *setting) { int val = 0; + int *value = setting->setting; if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) { - val = (bool)temp_var ? 0 : 1; + *(bool*)value = !*(bool*)value; + return; } else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) { struct int_setting *info = setting->int_setting; - val = (int)temp_var + info->step; + val = *value + info->step; if (val > info->max) val = info->min; } @@ -232,32 +233,32 @@ int steps = sound_steps(setting_id); int min = sound_min(setting_id); int max = sound_max(setting_id); - val = (int)temp_var + steps; - if (val > max) + val = *value + steps; + if (val >= max) val = min; } else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) { struct choice_setting *info = setting->choice_setting; - val = (int)temp_var; - if (val > info->count) + val = *value + 1; + if (val >= info->count) val = 0; } - return val; + *value = val; } - -int option_select_prev_val(struct settings_list *setting, - intptr_t temp_var) +#if 0 +void option_select_prev_val(const struct settings_list *setting) { int val = 0; + void *value = setting->setting; if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) { - val = (bool)temp_var ? 0 : 1; + *(bool*)value = !*(bool*)value; } else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) { struct int_setting *info = setting->int_setting; - val = (int)temp_var - info->step; + val = *(int*)value - info->step; if (val < info->min) val = info->max; } @@ -267,21 +268,20 @@ int steps = sound_steps(setting_id); int min = sound_min(setting_id); int max = sound_max(setting_id); - val = (int)temp_var -+ steps; + val = *(int*)value -+ steps; if (val < min) val = max; } else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) { struct choice_setting *info = setting->choice_setting; - val = (int)temp_var; + val = *(int*)value; if (val < 0) val = info->count - 1; } - return val; + *(int*)value = val; } #endif - static int selection_to_val(struct settings_list *setting, int selection) { int min = 0, max = 0, step = 1; Index: apps/gui/option_select.h =================================================================== --- apps/gui/option_select.h (revision 16203) +++ apps/gui/option_select.h (working copy) @@ -65,4 +65,9 @@ */ extern void option_select_prev(struct option_select * opt); + +void option_select_next_val(struct settings_list *setting); +char *option_get_valuestring(struct settings_list *setting, + char *buffer, int buf_len, + intptr_t temp_var); #endif /* _GUI_OPTION_SELECT_H_ */ Index: apps/gui/quickscreen.c =================================================================== --- apps/gui/quickscreen.c (revision 16203) +++ apps/gui/quickscreen.c (working copy) @@ -30,7 +30,135 @@ #include "misc.h" #include "statusbar.h" #include "action.h" +#include "settings_list.h" +#include "lang.h" +#include "option_select.h" +static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT]; +static void quickscreen_fix_viewports(struct gui_quickscreen *qs, + struct screen *display, + struct viewport *parent) +{ + struct viewport *vp; + int height, i; + + for(i=0; iscreen_type][i] = *parent; + } + + /* special handling when there is only enough room for 2 items. + discard the top and bottom items, so only show the 2 side ones */ + if (parent->height/display->char_height < 4) + { + qs->items[QUICKSCREEN_TOP] = NULL; + qs->items[QUICKSCREEN_BOTTOM] = NULL; + vps[display->screen_type][QUICKSCREEN_RIGHT].y = parent->y; + vps[display->screen_type][QUICKSCREEN_LEFT].height = parent->height/2; + vps[display->screen_type][QUICKSCREEN_RIGHT].y = parent->y+parent->height/2; + vps[display->screen_type][QUICKSCREEN_RIGHT].height = parent->height/2; + return; + } + else if (parent->height/display->char_height < 5) + { + qs->items[QUICKSCREEN_TOP] = NULL; + } + + height = parent->height / 3; + + for (i=0; iscreen_type][i].height = height; + } + vps[display->screen_type][QUICKSCREEN_LEFT].y = parent->y+height; + vps[display->screen_type][QUICKSCREEN_RIGHT].y = parent->y+height; + vps[display->screen_type][QUICKSCREEN_BOTTOM].y = parent->y+parent->height - height; + + vps[display->screen_type][QUICKSCREEN_RIGHT].x = parent->x+parent->width/2; + + vps[display->screen_type][QUICKSCREEN_LEFT].width = parent->width/2; + vps[display->screen_type][QUICKSCREEN_RIGHT].width = parent->width/2; +} + +static void quickscreen_draw_text(char *s, int item, bool title, + struct screen *display, struct viewport *vp) +{ + int line = title?0:1; + int w; + display->getstringsize(s, &w, NULL); + + if (w>vp->width) + { + if (item == QUICKSCREEN_RIGHT) + { + printf("%d %d\n", vp->height,display->char_height); + line = (vp->height/display->char_height)-(title?2:1); + if (line < 0) + line = 0; + } + display->puts_scroll(0,line,s); + } + else if (item == QUICKSCREEN_LEFT) + { + display->putsxy(0, line*display->char_height, s); + } + else if (item == QUICKSCREEN_RIGHT) + { + display->putsxy(vp->width - w, line*display->char_height, s); + } + else /* center it */ + { + display->putsxy((vp->width - w)/2, line*display->char_height, s); + } +} + +static void gui_quickscreen_draw(struct gui_quickscreen *qs, + struct screen *display, + struct viewport *parent) +{ + int i; + char buf[MAX_PATH]; + unsigned char *title, *value; + void *setting; + int temp; + display->set_viewport(parent); + display->clear_viewport(); + for (i=0; iitems[i]) + continue; + display->set_viewport(&vps[display->screen_type][i]); + display->scroll_stop(&vps[display->screen_type][i]); + + title = P2STR(ID2P(qs->items[i]->lang_id)); + setting = qs->items[i]->setting; + if (qs->items[i]->flags&F_T_BOOL) + temp = *(bool*)setting?1:0; + else + temp = *(int*)setting; + value = option_get_valuestring(qs->items[i], buf, MAX_PATH, temp); + + if (vps[display->screen_type][i].height < display->char_height*2) + { + char text[MAX_PATH]; + snprintf(text, MAX_PATH, "%s: %s", title, value); + quickscreen_draw_text(text, i, true, display, &vps[display->screen_type][i]); + } + else + { + quickscreen_draw_text(title, i, true, display, &vps[display->screen_type][i]); + quickscreen_draw_text(value, i, false, display, &vps[display->screen_type][i]); + } + display->update_viewport(); + } + display->set_viewport(parent); + display->update_viewport(); + display->set_viewport(NULL); +} + + +#if 0 void gui_quickscreen_init(struct gui_quickscreen * qs, struct option_select *left_option, struct option_select *bottom_option, @@ -121,19 +249,9 @@ gui_textarea_update(display); display->setfont(FONT_UI); } +#endif /* - * Draws the quickscreen on all available screens - * - qs : the quickscreen - */ -static void gui_syncquickscreen_draw(struct gui_quickscreen * qs) -{ - int i; - FOR_NB_SCREENS(i) - gui_quickscreen_draw(qs, &screens[i]); -} - -/* * Does the actions associated to the given button if any * - qs : the quickscreen * - button : the key we are going to analyse @@ -141,23 +259,26 @@ */ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) { - switch(button) { case ACTION_QS_LEFT: - option_select_next(qs->left_option); + if (qs->items[QUICKSCREEN_LEFT]) + option_select_next_val(qs->items[QUICKSCREEN_LEFT]); return(true); case ACTION_QS_DOWN: - option_select_next(qs->bottom_option); + if (qs->items[QUICKSCREEN_BOTTOM]) + option_select_next_val(qs->items[QUICKSCREEN_BOTTOM]); return(true); case ACTION_QS_RIGHT: - option_select_next(qs->right_option); + if (qs->items[QUICKSCREEN_RIGHT]) + option_select_next_val(qs->items[QUICKSCREEN_RIGHT]); return(true); case ACTION_QS_DOWNINV: - option_select_prev(qs->bottom_option); + if (qs->items[QUICKSCREEN_TOP]) + option_select_next_val(qs->items[QUICKSCREEN_TOP]); return(true); } return(false); @@ -165,24 +286,45 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) { - int button; + int button, i; + bool changed = false; + struct viewport vp[NB_SCREENS]; /* To quit we need either : * - a second press on the button that made us enter * - an action taken while pressing the enter button, * then release the enter button*/ bool can_quit=false; - gui_syncquickscreen_draw(qs); gui_syncstatusbar_draw(&statusbars, true); + FOR_NB_SCREENS(i) + { + vp[i].x = 0; + vp[i].width = screens[i].width; + vp[i].y = STATUSBAR_HEIGHT; + vp[i].height = screens[i].height - STATUSBAR_HEIGHT; +#ifdef HAVE_LCD_COLOR + if (screens[i].is_color) + { + vp[i].fg_pattern = screens[i].get_foreground(); + vp[i].bg_pattern = screens[i].get_background(); + } +#endif + vp[i].xmargin = 0; + vp[i].ymargin = 0; + vp[i].font = FONT_UI; + vp[i].drawmode = STYLE_DEFAULT; + quickscreen_fix_viewports(qs, &screens[i], &vp[i]); + gui_quickscreen_draw(qs, &screens[i], &vp[i]); + } while (true) { button = get_action(CONTEXT_QUICKSCREEN,TIMEOUT_BLOCK); if(default_event_handler(button) == SYS_USB_CONNECTED) return(true); if(gui_quickscreen_do_button(qs, button)) { + changed = true; can_quit=true; - if(qs->callback) - qs->callback(qs); - gui_syncquickscreen_draw(qs); + FOR_NB_SCREENS(i) + gui_quickscreen_draw(qs, &screens[i], &vp[i]); } else if(button==button_enter) can_quit=true; @@ -195,8 +337,9 @@ gui_syncstatusbar_draw(&statusbars, false); } + if (changed) + settings_apply(); return false; } - #endif /* HAVE_QUICKSCREEN */ Index: apps/gui/quickscreen.h =================================================================== --- apps/gui/quickscreen.h (revision 16203) +++ apps/gui/quickscreen.h (working copy) @@ -27,7 +27,24 @@ #include "option_select.h" #include "screen_access.h" +enum QUICKSCREEN_ITEM { + QUICKSCREEN_LEFT = 0, + QUICKSCREEN_RIGHT, + QUICKSCREEN_TOP, + QUICKSCREEN_BOTTOM, + QUICKSCREEN_ITEM_COUNT, +}; + +struct gui_quickscreen +{ + const struct settings_list *items[QUICKSCREEN_ITEM_COUNT]; + void (*callback)(struct gui_quickscreen * qs); +}; + + struct gui_quickscreen; +bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter); +#if 0 /* * Callback function called each time the quickscreen gets modified * - qs : the quickscreen that did the modification @@ -66,6 +83,6 @@ * returns : true if usb was connected, false otherwise */ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter); - +#endif #endif /*_GUI_QUICK_SCREEN_H_*/ #endif /* HAVE_QUICKSCREEN */