enabled status bar in menus on recorders

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1822 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Markus Braun 2002-08-20 19:37:00 +00:00
parent eef970428b
commit 5e4c1d2ad8
3 changed files with 207 additions and 39 deletions

View file

@ -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<menus[m].top+menu_lines);
i++) {
@ -123,6 +137,9 @@ static void menu_draw(int m)
/* place the cursor */
put_cursorxy(0, menus[m].cursor - menus[m].top, true);
#ifdef HAVE_LCD_BITMAP
status_draw();
#endif
lcd_update();
}
@ -138,7 +155,10 @@ static void put_cursor(int m, int target)
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
@ -196,7 +216,7 @@ void menu_run(int m)
menu_draw(m);
while(1) {
switch( button_get(true) ) {
switch( button_get_w_tmo(HZ/2) ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
@ -247,10 +267,21 @@ void menu_run(int m)
lcd_stop_scroll();
return;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F3:
#ifdef HAVE_LCD_BITMAP
global_settings.statusbar = !global_settings.statusbar;
settings_save();
menu_draw(m);
#endif
break;
#endif
default:
break;
}
status_draw();
lcd_update();
}
}

View file

@ -34,6 +34,10 @@
#include "power.h"
#include "backlight.h"
#include "powermgmt.h"
#include "status.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
#endif
struct user_settings global_settings;
@ -440,14 +444,23 @@ void set_bool(char* string, bool* variable )
bool done = false;
int button;
#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);
lcd_puts_scroll(0, 0, string);
while ( !done ) {
lcd_puts(0, 1, *variable ? "on " : "off");
#ifdef HAVE_LCD_BITMAP
status_draw();
#endif
lcd_update();
button = button_get(true);
button = button_get_w_tmo(HZ/2);
switch ( button ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
@ -458,10 +471,31 @@ void set_bool(char* string, bool* variable )
done = true;
break;
default:
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_DOWN:
#else
case BUTTON_LEFT:
case BUTTON_RIGHT:
#endif
if(!(button & BUTTON_REL))
*variable = !*variable;
break;
#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
}
}
lcd_stop_scroll();
@ -477,16 +511,25 @@ void set_int(char* string,
{
bool done = false;
#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);
lcd_puts_scroll(0, 0, string);
while (!done) {
char str[32];
snprintf(str,sizeof str,"%d %s ", *variable, unit);
lcd_puts(0,1,str);
lcd_puts(0, 1, str);
#ifdef HAVE_LCD_BITMAP
status_draw();
#endif
lcd_update();
switch( button_get(true) ) {
switch( button_get_w_tmo(HZ/2) ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
@ -519,6 +562,21 @@ void set_int(char* string,
#endif
done = true;
break;
#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 ( function )
function(*variable);
@ -530,14 +588,23 @@ void set_option(char* string, int* variable, char* options[], int numoptions )
{
bool done = false;
#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);
lcd_puts_scroll(0, 0, string);
while ( !done ) {
lcd_puts(0, 1, options[*variable]);
#ifdef HAVE_LCD_BITMAP
status_draw();
#endif
lcd_update();
switch ( button_get(true) ) {
switch ( button_get_w_tmo(HZ/2) ) {
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
@ -568,6 +635,21 @@ void set_option(char* string, int* variable, char* options[], int numoptions )
#endif
done = true;
break;
#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
}
}
lcd_stop_scroll();
@ -605,6 +687,12 @@ void set_time(char* string, int timedate[])
#endif
#endif
#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);
@ -734,7 +822,7 @@ void set_time(char* string, int timedate[])
cursor[5][INDEX_WIDTH] = width + strlen(reffub) - 1;
lcd_invertrect(cursor[cursorpos][INDEX_X],
cursor[cursorpos][INDEX_Y],
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
line_height);
#elif defined(LOADABLE_FONTS)
@ -770,17 +858,20 @@ void set_time(char* string, int timedate[])
cursor[5][INDEX_WIDTH] = width;
lcd_invertrect(cursor[cursorpos][INDEX_X],
cursor[cursorpos][INDEX_Y],
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
line_height);
#else
lcd_invertrect(cursor[cursorpos][INDEX_X],
cursor[cursorpos][INDEX_Y],
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
8);
#endif
lcd_puts(0,4,"ON to set");
lcd_puts(0,5,"OFF to revert");
lcd_puts(0, 4, "ON to set");
lcd_puts(0, 5, "OFF to revert");
#ifdef HAVE_LCD_BITMAP
status_draw();
#endif
lcd_update();
/* calculate the minimum and maximum for the number under cursor */
@ -811,7 +902,7 @@ void set_time(char* string, int timedate[])
}
}
button = button_get(true);
button = button_get_w_tmo(HZ/2);
switch ( button ) {
case BUTTON_LEFT:
cursorpos = (cursorpos + 6 - 1) % 6;
@ -838,6 +929,20 @@ void set_time(char* string, int timedate[])
done = true;
timedate[0] = -1;
break;
#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
default:
break;
}

View file

@ -19,12 +19,16 @@
#include "config.h"
#include <stdio.h>
#include <stdbool.h>
#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();
}