diff --git a/apps/menu.c b/apps/menu.c index 4be4e78e87..93e8394011 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -23,13 +23,15 @@ #include "kernel.h" #include "debug.h" #include "panic.h" - +#include "settings.h" +#include "status.h" #ifdef HAVE_LCD_BITMAP #include "icons.h" #endif #ifdef LOADABLE_FONTS #include "ajf.h" #endif + struct menu { int top; int cursor; @@ -40,7 +42,9 @@ struct menu { #define MAX_MENUS 4 #ifdef HAVE_LCD_BITMAP -#define MENU_LINES 8 +#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ +#define LINE_HEIGTH 8 /* pixels for each text line */ +#define MENU_LINES (LCD_HEIGHT / LINE_HEIGTH - LINE_Y) #else #define MENU_LINES 2 #endif @@ -71,7 +75,7 @@ void put_cursorxy(int x, int y, bool on) if(on) { #ifdef HAVE_LCD_BITMAP lcd_bitmap ( bitmap_icons_6x8[Cursor], - x*6, y*fh, 4, 8, true); + x*6, y*fh + lcd_getymargin(), 4, 8, true); #elif defined(SIMULATOR) /* player simulator */ unsigned char cursor[] = { 0x7f, 0x3e, 0x1c, 0x08 }; @@ -83,7 +87,7 @@ void put_cursorxy(int x, int y, bool on) else { #if defined(HAVE_LCD_BITMAP) /* I use xy here since it needs to disregard the margins */ - lcd_clearrect (x*6, y*fh, 4, 8); + lcd_clearrect (x*6, y*fh + lcd_getymargin(), 4, 8); #elif defined(SIMULATOR) /* player simulator in action */ lcd_clearrect (x*6, 12+y*16, 4, 8); @@ -101,7 +105,10 @@ static void menu_draw(int m) int fh; unsigned char* font = lcd_getcurrentldfont(); fh = ajf_get_fontheight(font); - menu_lines = LCD_HEIGHT/fh; + if (global_settings.statusbar) + menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; + else + menu_lines = LCD_HEIGHT/fh; #else int menu_lines = MENU_LINES; #endif @@ -109,9 +116,16 @@ static void menu_draw(int m) lcd_clear_display(); lcd_stop_scroll(); #ifdef HAVE_LCD_BITMAP - lcd_setmargins(0,0); + if(global_settings.statusbar) + lcd_setmargins(0, STATUSBAR_HEIGHT); + else + lcd_setmargins(0, 0); lcd_setfont(0); #endif + /* correct cursor pos if out of screen */ + if (menus[m].cursor - menus[m].top >= menu_lines) + menus[m].top++; + for (i = menus[m].top; (i < menus[m].itemcount) && (i #include +#include "kernel.h" #include "lcd.h" #include "menu.h" #include "button.h" #include "mpeg.h" #include "settings.h" #include "status.h" +#ifdef HAVE_LCD_BITMAP +#include "icons.h" +#endif static char *fmt[] = { @@ -38,6 +42,7 @@ void set_sound(char* string, int setting) { bool done = false; + bool changed = false; int min, max; int val; int numdec; @@ -51,26 +56,35 @@ void set_sound(char* string, min = mpeg_sound_min(setting); max = mpeg_sound_max(setting); +#ifdef HAVE_LCD_BITMAP + if(global_settings.statusbar) + lcd_setmargins(0, STATUSBAR_HEIGHT); + else + lcd_setmargins(0, 0); +#endif lcd_clear_display(); lcd_puts_scroll(0,0,string); while (!done) { - val = mpeg_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 (changed) { + val = mpeg_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); + } } lcd_puts(0,1,str); - lcd_update(); status_draw(); + lcd_update(); - switch( button_get(true) ) { + changed = false; + switch( button_get_w_tmo(HZ/2) ) { #ifdef HAVE_RECORDER_KEYPAD case BUTTON_UP: case BUTTON_UP | BUTTON_REPEAT: @@ -81,6 +95,7 @@ void set_sound(char* string, (*variable)++; if(*variable > max ) *variable = max; + changed = true; break; #ifdef HAVE_RECORDER_KEYPAD @@ -93,6 +108,7 @@ void set_sound(char* string, (*variable)--; if(*variable < min ) *variable = min; + changed = true; break; #ifdef HAVE_RECORDER_KEYPAD @@ -103,12 +119,28 @@ void set_sound(char* string, #endif done = true; break; - } - mpeg_sound_set(setting, *variable); -#ifdef HAVE_MAS3507D - if(setting == SOUND_BALANCE) - mpeg_sound_set(SOUND_VOLUME, global_settings.volume); +#ifdef HAVE_RECORDER_KEYPAD + case BUTTON_F3: +#ifdef HAVE_LCD_BITMAP + global_settings.statusbar = !global_settings.statusbar; + settings_save(); + if(global_settings.statusbar) + lcd_setmargins(0, STATUSBAR_HEIGHT); + else + lcd_setmargins(0, 0); + lcd_clear_display(); + lcd_puts_scroll(0, 0, string); #endif + break; +#endif + } + if (changed) { + mpeg_sound_set(setting, *variable); +#ifdef HAVE_MAS3507D + if(setting == SOUND_BALANCE) + mpeg_sound_set(SOUND_VOLUME, global_settings.volume); +#endif + } } lcd_stop_scroll(); }