diff options
| author | Kevin Ferrare <kevin@rockbox.org> | 2005-11-06 03:18:34 +0000 |
|---|---|---|
| committer | Kevin Ferrare <kevin@rockbox.org> | 2005-11-06 03:18:34 +0000 |
| commit | 9b5264d37faf0588f996a1716c41a6e51f4d16ea (patch) | |
| tree | 03d6f571683fdaa2b2877c4df51fb75df9d76fae /apps | |
| parent | ec8f328d89f7db22f9894148e2c0431e44ebf191 (diff) | |
| download | rockbox-9b5264d37faf0588f996a1716c41a6e51f4d16ea.zip rockbox-9b5264d37faf0588f996a1716c41a6e51f4d16ea.tar.gz rockbox-9b5264d37faf0588f996a1716c41a6e51f4d16ea.tar.bz2 rockbox-9b5264d37faf0588f996a1716c41a6e51f4d16ea.tar.xz | |
Corrected the bug with boolean settings (the inverted screen that couldn't be turned back to normal) added full multi-screen sound setting support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7761 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/gui/select.c | 2 | ||||
| -rw-r--r-- | apps/gui/select.h | 1 | ||||
| -rw-r--r-- | apps/settings.c | 25 | ||||
| -rw-r--r-- | apps/sound_menu.c | 107 |
4 files changed, 41 insertions, 94 deletions
diff --git a/apps/gui/select.c b/apps/gui/select.c index 8323783..58747fb 100644 --- a/apps/gui/select.c +++ b/apps/gui/select.c @@ -44,6 +44,7 @@ void gui_select_init_numeric(struct gui_select * select, select->min_value=min_value; select->max_value=max_value+1; select->option=init_value; + select->nb_decimals=0; select->step=step; select->extra_string=unit; select->formatter=formatter; @@ -62,6 +63,7 @@ void gui_select_init_items(struct gui_select * select, select->min_value=0; select->max_value=nb_items; select->option=selected; + select->nb_decimals=0; select->step=1; select->formatter=NULL; select->items=items; diff --git a/apps/gui/select.h b/apps/gui/select.h index e79dcd3..87ecb1c 100644 --- a/apps/gui/select.h +++ b/apps/gui/select.h @@ -80,6 +80,7 @@ struct gui_select int max_value; int step; int option; + int nb_decimals; const char * extra_string; /* In the case the option is a number */ void (*formatter)(char* dest, diff --git a/apps/settings.c b/apps/settings.c index 6e863e7..870376c 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -1418,12 +1418,14 @@ bool set_int(const char* string, gui_syncselect_draw(&select); talk_unit(voice_unit, *variable); if ( function ) - function(gui_select_get_selected(&select)); + function(*variable); } gui_syncstatusbar_draw(&statusbars, false); if(gui_select_is_canceled(&select)) { *variable=oldvalue; + if ( function ) + function(*variable); return false; } if(default_event_handler(button) == SYS_USB_CONNECTED) @@ -1446,11 +1448,14 @@ bool set_int(const char* string, else \ *(bool *)dest=value?true:false -#define set_int_fromtype(type, dest, var) \ - if (type == INT) \ - dest=*(int *)var; \ - else \ - dest=*(bool *)var?1:0 +#define type_fromvoidptr(type, value) \ + (type == INT)? \ + (int)(*(int*)(value)) \ + : \ + (bool)(*(bool*)(value)) + +#define get_int_fromtype(type, var) \ + (type == INT)?*(int *)var:(*(bool *)var?1:0) bool set_option(const char* string, void* variable, enum optiontype type, const struct opt_items* options, int numoptions, void (*function)(int)) @@ -1458,12 +1463,12 @@ bool set_option(const char* string, void* variable, enum optiontype type, int button; int oldvalue; /* oldvalue=*variable; */ - set_int_fromtype(type, oldvalue, variable); + oldvalue=get_int_fromtype(type, variable); struct gui_select select; gui_select_init_items(&select, string, oldvalue, options, numoptions); gui_syncselect_draw(&select); if (global_settings.talk_menu) - talk_id(options[gui_select_get_selected(&select)].voice_id, false); + talk_id(options[gui_select_get_selected(&select)].voice_id, true); while ( !gui_select_is_validated(&select) ) { gui_syncstatusbar_draw(&statusbars, true); @@ -1476,13 +1481,15 @@ bool set_option(const char* string, void* variable, enum optiontype type, if (global_settings.talk_menu) talk_id(options[gui_select_get_selected(&select)].voice_id, false); if ( function ) - function(*(int *)variable); + function(type_fromvoidptr(type, variable)); } gui_syncstatusbar_draw(&statusbars, false); if(gui_select_is_canceled(&select)) { /* *variable=oldvalue; */ set_type_fromint(type, variable, oldvalue); + if ( function ) + function(type_fromvoidptr(type, variable)); return false; } if(default_event_handler(button) == SYS_USB_CONNECTED) diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 738c457..20e44f7 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -50,104 +50,41 @@ static const char* const fmt[] = "%d.%02d %s " /* 2 decimals */ }; +int selected_setting; /* Used by the callback */ +void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit) +{ + val = sound_val2phys(selected_setting, val); + int integer = val / 10; + int dec = val % 10; + snprintf(buffer, buffer_size, "%d.%d %s", integer, dec, unit); +} + bool set_sound(const char* string, int* variable, int setting) { - bool done = false; - bool changed = true; - int min, max; - int val; - int numdec; - int integer; - int dec; - const char* unit; - char str[32]; int talkunit = UNIT_INT; - int steps; - int button; - - unit = sound_unit(setting); - numdec = sound_numdecimals(setting); - steps = sound_steps(setting); - min = sound_min(setting); - max = sound_max(setting); + const char* unit = sound_unit(setting); + int numdec = sound_numdecimals(setting); + int steps = sound_steps(setting); + int min = sound_min(setting); + int max = sound_max(setting); + void(*sound_callback)(int)=sound_get_fn(setting); if (*unit == 'd') /* crude reconstruction */ talkunit = UNIT_DB; else if (*unit == '%') talkunit = UNIT_PERCENT; else if (*unit == 'H') talkunit = UNIT_HERTZ; - -#ifdef HAVE_LCD_BITMAP - if(global_settings.statusbar) - lcd_setmargins(0, STATUSBAR_HEIGHT); + if(!numdec) + return set_int(string, unit, talkunit, variable, sound_callback, + steps, min, max, NULL ); else - lcd_setmargins(0, 0); -#endif - lcd_clear_display(); - lcd_puts_scroll(0,0,string); - - while (!done) { - if (changed) { - val = sound_val2phys(setting, *variable); - if(numdec) - { - integer = val / (10 * numdec); - dec = val % (10 * numdec); - snprintf(str,sizeof str, fmt[numdec], integer, dec, unit); - } - else - { - snprintf(str,sizeof str,"%d %s ", val, unit); - } - if (global_settings.talk_menu) - talk_value(val, talkunit, false); /* speak it */ - } - lcd_puts(0,1,str); - status_draw(true); - lcd_update(); - - changed = false; - button = button_get_w_tmo(HZ/2); - switch( button ) { - case SETTINGS_INC: - case SETTINGS_INC | BUTTON_REPEAT: - (*variable)+=steps; - if(*variable > max ) - *variable = max; - changed = true; - break; - - case SETTINGS_DEC: - case SETTINGS_DEC | BUTTON_REPEAT: - (*variable)-=steps; - if(*variable < min ) - *variable = min; - changed = true; - break; - - case SETTINGS_OK: - case SETTINGS_CANCEL: -#ifdef SETTINGS_OK2 - case SETTINGS_OK2: -#endif -#ifdef SETTINGS_CANCEL2 - case SETTINGS_CANCEL2: -#endif - done = true; - break; - - default: - if(default_event_handler(button) == SYS_USB_CONNECTED) - return true; - break; - } - if (changed) - sound_set(setting, *variable); + {/* Decimal number */ + selected_setting=setting; + return set_int(string, unit, talkunit, variable, sound_callback, + steps, min, max, &dec_sound_formatter ); } - lcd_stop_scroll(); - return false; } static bool volume(void) |