From bf603f98cbc9e7cb290771908112c3465580f7d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 Jun 2002 08:47:44 +0000 Subject: made to use the new cursor bitmap on the recorder, so put_cursorxy() is now a better way to position the cursor git-svn-id: svn://svn.rockbox.org/rockbox/trunk@993 a1c6a512-1295-4272-9138-f99709370657 --- apps/menu.c | 38 ++++++++++++++++++++++++++++++-------- apps/tree.c | 32 ++++++++++++++++---------------- 2 files changed, 46 insertions(+), 24 deletions(-) (limited to 'apps') diff --git a/apps/menu.c b/apps/menu.c index b8c652c04a..c4ddd62db5 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -23,6 +23,10 @@ #include "kernel.h" #include "debug.h" +#ifdef HAVE_LCD_BITMAP +#include "icons.h" +#endif + struct menu { int top; int cursor; @@ -38,19 +42,37 @@ struct menu { #define MENU_LINES 2 #endif -#ifdef HAVE_LCD_BITMAP -#define CURSOR_CHAR "-" -#else #ifdef HAVE_NEW_CHARCELL_LCD #define CURSOR_CHAR "\x7e" #else #define CURSOR_CHAR "\x89" #endif -#endif static struct menu menus[MAX_MENUS]; static bool inuse[MAX_MENUS] = { false }; +/* count in letter posistions, NOT pixels */ +void put_cursorxy(int x, int y, bool on) +{ + /* place the cursor */ + if(on) { +#ifdef HAVE_LCD_BITMAP + lcd_bitmap ( bitmap_icons_6x8[Cursor], + x*6, y*8, 6, 8, true); +#else + lcd_puts(x, y, CURSOR_CHAR); +#endif + } + else { +#ifdef HAVE_LCD_BITMAP + /* I use xy here since it needs to disregard the margins */ + lcd_putsxy (x*6, y*8, " ", 0); +#else + lcd_puts(x, y, " "); +#endif + } +} + static void menu_draw(int m) { int i = 0; @@ -66,8 +88,8 @@ static void menu_draw(int m) lcd_puts(1, i-menus[m].top, menus[m].items[i].desc); } - /* place the cursor */ - lcd_puts(0, menus[m].cursor - menus[m].top, CURSOR_CHAR); + /* place the cursor */ + put_cursorxy(0, menus[m].cursor - menus[m].top, true); lcd_update(); } @@ -80,7 +102,7 @@ static void put_cursor(int m, int target) { bool do_update = true; - lcd_puts(0, menus[m].cursor - menus[m].top, " "); + put_cursorxy(0, menus[m].cursor - menus[m].top, false); menus[m].cursor = target; if ( target < menus[m].top ) { @@ -95,7 +117,7 @@ static void put_cursor(int m, int target) } if (do_update) { - lcd_puts(0, menus[m].cursor - menus[m].top, CURSOR_CHAR); + put_cursorxy(0, menus[m].cursor - menus[m].top, true); lcd_update(); } diff --git a/apps/tree.c b/apps/tree.c index 7a4a49278b..88bdaddff8 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -67,7 +67,11 @@ void browse_root(void) #define LINE_Y 0 /* Y position the entry-list starts at */ #define LINE_X 2 /* X position the entry-list starts at */ #define LINE_HEIGTH 8 /* pixels for each text line */ -#define CURSOR_CHAR "-" + +#define CURSOR_Y 1 /* the cursor is not positioned in regard to + the margins, so this is the amount of lines + we add to the cursor Y position to position + it on a line */ extern unsigned char bitmap_icons_6x8[LastIcon][6]; @@ -78,11 +82,7 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6]; #define LINE_Y 0 /* Y position the entry-list starts at */ #define LINE_X 1 /* X position the entry-list starts at */ -#ifdef HAVE_NEW_CHARCELL_LCD -#define CURSOR_CHAR "\x7e" -#else -#define CURSOR_CHAR "\x89" -#endif +#define CURSOR_Y 0 /* not really used for players */ #endif /* HAVE_LCD_BITMAP */ @@ -239,7 +239,7 @@ bool dirbrowse(char *root) if (numentries == -1) return -1; /* root is not a directory */ - lcd_puts(0, dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + dircursor, true); if ( numentries ) lcd_puts_scroll(LINE_X, LINE_Y+dircursor, dircacheptr[start+dircursor]->name); @@ -266,7 +266,7 @@ bool dirbrowse(char *root) else start = dircursor = 0; numentries = showdir(currdir, start); - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); } else mpeg_stop(); @@ -310,21 +310,21 @@ bool dirbrowse(char *root) } } numentries = showdir(currdir, start); - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); break; case TREE_PREV: if(dircursor) { - lcd_puts(0, LINE_Y+dircursor, " "); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); dircursor--; - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); lcd_update(); } else { if (start) { start--; numentries = showdir(currdir, start); - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); } } break; @@ -332,14 +332,14 @@ bool dirbrowse(char *root) case TREE_NEXT: if (dircursor + start + 1 < numentries ) { if(dircursor+1 < TREE_MAX_ON_SCREEN) { - lcd_puts(0, LINE_Y+dircursor, " "); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); dircursor++; - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); } else { start++; numentries = showdir(currdir, start); - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); } } break; @@ -352,7 +352,7 @@ bool dirbrowse(char *root) /* TODO: this is just a copy from BUTTON_STOP, fix it */ lcd_clear_display(); numentries = showdir(currdir, start); - lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); + put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); break; } -- cgit v1.2.3