1
0
Fork 0
forked from len0rd/rockbox

Now using lcd margins instead of a line offset for displaying status bar.

Needed to support fonts smaller than 8 pixels.


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

View file

@ -30,12 +30,10 @@
#include "settings.h" #include "settings.h"
#include "status.h" #include "status.h"
#include "applimits.h" #include "applimits.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */ #include "icons.h"
#else /* HAVE_LCD_BITMAP */ #include "widgets.h"
#define LINE_Y 0 /* Y position the entry-list starts at */ #endif
#endif /* HAVE_LCD_BITMAP */
playlist_info_t playlist; playlist_info_t playlist;
@ -183,10 +181,17 @@ void play_list(char *dir, /* "current directory" */
playlist.index = start_index; playlist.index = start_index;
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
#endif
/* If file is NULL, the list is in RAM */ /* If file is NULL, the list is in RAM */
if(file) { if(file) {
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,LINE_Y,"Loading..."); lcd_puts(0,0,"Loading...");
status_draw(); status_draw();
lcd_update(); lcd_update();
playlist.in_ram = false; playlist.in_ram = false;
@ -216,7 +221,7 @@ void play_list(char *dir, /* "current directory" */
if(global_settings.playlist_shuffle) { if(global_settings.playlist_shuffle) {
if(!playlist.in_ram) { if(!playlist.in_ram) {
lcd_puts(0,LINE_Y,"Shuffling..."); lcd_puts(0,0,"Shuffling...");
status_draw(); status_draw();
lcd_update(); lcd_update();
randomise_playlist( random_seed ); randomise_playlist( random_seed );
@ -247,7 +252,7 @@ void play_list(char *dir, /* "current directory" */
} }
if(!playlist.in_ram) { if(!playlist.in_ram) {
lcd_puts(0,LINE_Y,"Playing... "); lcd_puts(0,0,"Playing... ");
status_draw(); status_draw();
lcd_update(); lcd_update();
} }
@ -342,7 +347,7 @@ void add_indices_to_playlist(void)
next_tick = current_tick + HZ; next_tick = current_tick + HZ;
snprintf(line, sizeof line, "%d files", snprintf(line, sizeof line, "%d files",
playlist.amount); playlist.amount);
lcd_puts(0,LINE_Y+1,line); lcd_puts(0,1,line);
status_draw(); status_draw();
lcd_update(); lcd_update();
} }
@ -357,7 +362,7 @@ void add_indices_to_playlist(void)
} }
if(!playlist.in_ram) { if(!playlist.in_ram) {
snprintf(line, sizeof line, "%d files", playlist.amount); snprintf(line, sizeof line, "%d files", playlist.amount);
lcd_puts(0,LINE_Y+1,line); lcd_puts(0,1,line);
status_draw(); status_draw();
lcd_update(); lcd_update();
close(fd); close(fd);

View file

@ -69,10 +69,10 @@ void browse_root(void)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH-LINE_Y) #define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH)
#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ #define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
#define MARGIN_Y 0 /* Y pixel margin */ #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */
#define MARGIN_X 10 /* X pixel margin */ #define MARGIN_X 10 /* X pixel margin */
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ #define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
#define LINE_X 0 /* X position the entry-list starts at */ #define LINE_X 0 /* X position the entry-list starts at */
@ -167,7 +167,7 @@ static int showdir(char *path, int start)
int fh; int fh;
unsigned char *font = lcd_getcurrentldfont(); unsigned char *font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font); fh = ajf_get_fontheight(font);
tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
line_height = fh; line_height = fh;
#else #else
tree_max_on_screen = TREE_MAX_ON_SCREEN; tree_max_on_screen = TREE_MAX_ON_SCREEN;
@ -273,7 +273,7 @@ static int showdir(char *path, int start)
icon_type = File; icon_type = File;
} }
lcd_bitmap(bitmap_icons_6x8[icon_type], lcd_bitmap(bitmap_icons_6x8[icon_type],
4, MARGIN_Y+(LINE_Y+i-start)*line_height, 6, 8, true); 4, MARGIN_Y+(i-start)*line_height, 6, 8, true);
#endif #endif
@ -283,11 +283,11 @@ static int showdir(char *path, int start)
{ {
char temp = dircache[i].name[len-4]; char temp = dircache[i].name[len-4];
dircache[i].name[len-4] = 0; dircache[i].name[len-4] = 0;
lcd_puts(LINE_X, LINE_Y+i-start, dircache[i].name); lcd_puts(LINE_X, i-start, dircache[i].name);
dircache[i].name[len-4] = temp; dircache[i].name[len-4] = temp;
} }
else else
lcd_puts(LINE_X, LINE_Y+i-start, dircache[i].name); lcd_puts(LINE_X, i-start, dircache[i].name);
} }
status_draw(); status_draw();
@ -411,7 +411,7 @@ bool dirbrowse(char *root)
int fh; int fh;
unsigned char *font = lcd_getcurrentldfont(); unsigned char *font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font); fh = ajf_get_fontheight(font);
tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else #else
tree_max_on_screen = TREE_MAX_ON_SCREEN; tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif #endif
@ -424,7 +424,7 @@ bool dirbrowse(char *root)
if (numentries == -1) if (numentries == -1)
return -1; /* root is not a directory */ return -1; /* root is not a directory */
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
while(1) { while(1) {
bool restore = false; bool restore = false;
@ -545,29 +545,29 @@ bool dirbrowse(char *root)
case BUTTON_VOL_UP: case BUTTON_VOL_UP:
if(filesindir) { if(filesindir) {
if(dircursor) { if(dircursor) {
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); put_cursorxy(0, CURSOR_Y + dircursor, false);
dircursor--; dircursor--;
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
else { else {
if (start) { if (start) {
start--; start--;
numentries = showdir(currdir, start); numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
else { else {
if (numentries < tree_max_on_screen) { if (numentries < tree_max_on_screen) {
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, put_cursorxy(0, CURSOR_Y + dircursor,
false); false);
dircursor = numentries - 1; dircursor = numentries - 1;
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, put_cursorxy(0, CURSOR_Y + dircursor,
true); true);
} }
else { else {
start = numentries - tree_max_on_screen; start = numentries - tree_max_on_screen;
dircursor = tree_max_on_screen - 1; dircursor = tree_max_on_screen - 1;
numentries = showdir(currdir, start); numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y + put_cursorxy(0, CURSOR_Y +
tree_max_on_screen - 1, true); tree_max_on_screen - 1, true);
} }
} }
@ -583,28 +583,28 @@ bool dirbrowse(char *root)
{ {
if (dircursor + start + 1 < numentries ) { if (dircursor + start + 1 < numentries ) {
if(dircursor+1 < tree_max_on_screen) { if(dircursor+1 < tree_max_on_screen) {
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, put_cursorxy(0, CURSOR_Y + dircursor,
false); false);
dircursor++; dircursor++;
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
else { else {
start++; start++;
numentries = showdir(currdir, start); numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
} }
else { else {
if(numentries < tree_max_on_screen) { if(numentries < tree_max_on_screen) {
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, put_cursorxy(0, CURSOR_Y + dircursor,
false); false);
start = dircursor = 0; start = dircursor = 0;
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
else { else {
start = dircursor = 0; start = dircursor = 0;
numentries = showdir(currdir, start); numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
} }
lcd_update(); lcd_update();
@ -614,14 +614,8 @@ bool dirbrowse(char *root)
case TREE_MENU: { case TREE_MENU: {
bool lastfilter = global_settings.mp3filter; bool lastfilter = global_settings.mp3filter;
bool lastsortcase = global_settings.sort_case; bool lastsortcase = global_settings.sort_case;
#ifdef HAVE_LCD_BITMAP
bool laststate=statusbar(false);
#endif
lcd_stop_scroll(); lcd_stop_scroll();
main_menu(); main_menu();
#ifdef HAVE_LCD_BITMAP
statusbar(laststate);
#endif
/* do we need to rescan dir? */ /* do we need to rescan dir? */
if ( lastfilter != global_settings.mp3filter || if ( lastfilter != global_settings.mp3filter ||
lastsortcase != global_settings.sort_case) lastsortcase != global_settings.sort_case)
@ -650,13 +644,18 @@ bool dirbrowse(char *root)
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F3: case BUTTON_F3:
#endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
global_settings.statusbar = !global_settings.statusbar; global_settings.statusbar = !global_settings.statusbar;
settings_save(); settings_save();
#ifdef LOADABLE_FONTS
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif
restore = true; restore = true;
#endif #endif
break; break;
#endif
#ifndef SIMULATOR #ifndef SIMULATOR
case SYS_USB_CONNECTED: { case SYS_USB_CONNECTED: {
@ -694,7 +693,7 @@ bool dirbrowse(char *root)
dircursor--; dircursor--;
} }
numentries = showdir(currdir, start); numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); put_cursorxy(0, CURSOR_Y + dircursor, true);
} }
if ( numentries ) { if ( numentries ) {
@ -711,12 +710,12 @@ bool dirbrowse(char *root)
int len = strlen(dircache[i].name); int len = strlen(dircache[i].name);
char temp = dircache[i].name[len-4]; char temp = dircache[i].name[len-4];
dircache[i].name[len-4] = 0; dircache[i].name[len-4] = 0;
lcd_puts_scroll(LINE_X, LINE_Y+dircursor, lcd_puts_scroll(LINE_X, dircursor,
dircache[i].name); dircache[i].name);
dircache[i].name[len-4] = temp; dircache[i].name[len-4] = temp;
} }
else else
lcd_puts_scroll(LINE_X, LINE_Y+dircursor, lcd_puts_scroll(LINE_X, dircursor,
dircache[i].name); dircache[i].name);
} }
} }

View file

@ -44,12 +44,6 @@
#include "ajf.h" #include "ajf.h"
#endif #endif
#ifdef HAVE_LCD_BITMAP
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
#else /* HAVE_LCD_BITMAP */
#define LINE_Y 0 /* Y position the entry-list starts at */
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#define PLAY_DISPLAY_2LINEID3 0 #define PLAY_DISPLAY_2LINEID3 0
#define PLAY_DISPLAY_FILENAME_SCROLL 1 #define PLAY_DISPLAY_FILENAME_SCROLL 1
@ -82,7 +76,6 @@ static void draw_screen(struct mp3entry* id3)
font_height = 8; font_height = 8;
#endif #endif
lcd_clear_display(); lcd_clear_display();
if(!id3) if(!id3)
{ {
@ -117,14 +110,14 @@ static void draw_screen(struct mp3entry* id3)
strncpy(szArtist,szTok,sizeof(szArtist)); strncpy(szArtist,szTok,sizeof(szArtist));
szArtist[sizeof(szArtist)-1] = 0; szArtist[sizeof(szArtist)-1] = 0;
szDelimit = strrchr(id3->path, ch); szDelimit = strrchr(id3->path, ch);
lcd_puts(0,LINE_Y, szArtist?szArtist:"<nothing>"); lcd_puts(0, 0, szArtist?szArtist:"<nothing>");
// removes the .mp3 from the end of the display buffer // removes the .mp3 from the end of the display buffer
szPeriod = strrchr(szDelimit, '.'); szPeriod = strrchr(szDelimit, '.');
if (szPeriod != NULL) if (szPeriod != NULL)
*szPeriod = 0; *szPeriod = 0;
lcd_puts_scroll(0,LINE_Y+1,(++szDelimit)); lcd_puts_scroll(0, 1, (++szDelimit));
break; break;
} }
case PLAY_DISPLAY_FILENAME_SCROLL: case PLAY_DISPLAY_FILENAME_SCROLL:
@ -147,12 +140,12 @@ static void draw_screen(struct mp3entry* id3)
playlist.amount, playlist.amount,
id3->path); id3->path);
} }
lcd_puts_scroll(0,LINE_Y, buffer); lcd_puts_scroll(0, 0, buffer);
break; break;
} }
case PLAY_DISPLAY_2LINEID3: case PLAY_DISPLAY_2LINEID3:
{ {
int l = LINE_Y; int l = 0;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
char buffer[64]; char buffer[64];
@ -161,7 +154,7 @@ static void draw_screen(struct mp3entry* id3)
lcd_puts(0, l++, id3->album?id3->album:""); lcd_puts(0, l++, id3->album?id3->album:"");
lcd_puts(0, l++, id3->artist?id3->artist:""); lcd_puts(0, l++, id3->artist?id3->artist:"");
if(LINE_Y==0&&font_height<=8) { if(!global_settings.statusbar && font_height <= 8) {
if(id3->vbr) if(id3->vbr)
snprintf(buffer, sizeof(buffer), "%d kbit (avg)", snprintf(buffer, sizeof(buffer), "%d kbit (avg)",
id3->bitrate); id3->bitrate);
@ -345,6 +338,11 @@ static void display_file_time(unsigned int elapsed, unsigned int length)
char buffer[32]; char buffer[32];
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int line;
if(global_settings.statusbar)
line = 5;
else
line = 6;
snprintf(buffer,sizeof(buffer), snprintf(buffer,sizeof(buffer),
"Time:%3d:%02d/%d:%02d", "Time:%3d:%02d/%d:%02d",
elapsed / 60000, elapsed / 60000,
@ -352,7 +350,7 @@ static void display_file_time(unsigned int elapsed, unsigned int length)
length / 60000, length / 60000,
length % 60000 / 1000 ); length % 60000 / 1000 );
lcd_puts(0, 6, buffer); lcd_puts(0, line, buffer);
slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, elapsed*100/length, Grow_Right); slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, elapsed*100/length, Grow_Right);
lcd_update(); lcd_update();
#else #else
@ -410,6 +408,7 @@ void display_keylock_text(bool locked)
{ {
lcd_puts(2, 3, "Key lock is OFF"); lcd_puts(2, 3, "Key lock is OFF");
} }
status_draw();
lcd_update(); lcd_update();
#endif #endif
@ -435,6 +434,7 @@ void display_mute_text(bool muted)
{ {
lcd_puts(2, 3, "Mute is OFF"); lcd_puts(2, 3, "Mute is OFF");
} }
status_draw();
lcd_update(); lcd_update();
#endif #endif
@ -464,6 +464,9 @@ int wps_show(void)
lcd_icon(ICON_AUDIO, true); lcd_icon(ICON_AUDIO, true);
lcd_icon(ICON_PARAM, false); lcd_icon(ICON_PARAM, false);
#else #else
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0); lcd_setmargins(0, 0);
#endif #endif
@ -876,15 +879,9 @@ int wps_show(void)
#endif #endif
if(!keys_locked && !dont_go_to_menu && menu_button_is_down) if(!keys_locked && !dont_go_to_menu && menu_button_is_down)
{ {
#ifdef HAVE_LCD_BITMAP
bool laststate=statusbar(false);
#endif
lcd_stop_scroll(); lcd_stop_scroll();
button_set_release(old_release_mask); button_set_release(old_release_mask);
main_menu(); main_menu();
#ifdef HAVE_LCD_BITMAP
statusbar(laststate);
#endif
old_release_mask = button_set_release(RELEASE_MASK); old_release_mask = button_set_release(RELEASE_MASK);
ignore_keyup = true; ignore_keyup = true;
id3 = mpeg_current_track(); id3 = mpeg_current_track();
@ -905,6 +902,10 @@ int wps_show(void)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
global_settings.statusbar = !global_settings.statusbar; global_settings.statusbar = !global_settings.statusbar;
settings_save(); settings_save();
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
draw_screen(id3); draw_screen(id3);
#endif #endif
break; break;