From 6c2af7c2aa8afde380b5a5f7c606c49dd38bef18 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 1 Sep 2005 08:04:37 +0000 Subject: On popular demand, the arrow cursor is reintroduced git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7438 a1c6a512-1295-4272-9138-f99709370657 --- apps/menu.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'apps/menu.c') diff --git a/apps/menu.c b/apps/menu.c index 3b0ee4ddd6..ad22047b9d 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -59,7 +59,8 @@ struct menu { /* pixel margins */ #define MARGIN_X (global_settings.scrollbar && \ - menu_lines < menus[m].itemcount ? SCROLLBAR_WIDTH : 0) + menu_lines < menus[m].itemcount ? SCROLLBAR_WIDTH : 0) +\ + CURSOR_WIDTH #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* position the entry-list starts at */ @@ -72,6 +73,7 @@ struct menu { the margins, so this is the amount of lines we add to the cursor Y position to position it on a line */ +#define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4) #define SCROLLBAR_X 0 #define SCROLLBAR_Y lcd_getymargin() @@ -93,19 +95,44 @@ struct menu { static struct menu menus[MAX_MENUS]; static bool inuse[MAX_MENUS] = { false }; -#ifdef HAVE_LCD_CHARCELLS /* count in letter positions, NOT pixels */ void put_cursorxy(int x, int y, bool on) { +#ifdef HAVE_LCD_BITMAP + int fh, fw; + int xpos, ypos; + + /* check here instead of at every call (ugly, but cheap) */ + if (global_settings.invert_cursor) + return; + + lcd_getstringsize("A", &fw, &fh); + xpos = x*6; + ypos = y*fh + lcd_getymargin(); + if ( fh > 8 ) + ypos += (fh - 8) / 2; +#endif + /* place the cursor */ if(on) { +#ifdef HAVE_LCD_BITMAP + lcd_mono_bitmap(bitmap_icons_6x8[Icon_Cursor], xpos, ypos, 4, 8); +#else lcd_putc(x, y, CURSOR_CHAR); +#endif } else { +#if defined(HAVE_LCD_BITMAP) + /* I use xy here since it needs to disregard the margins */ + lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); + lcd_fillrect (xpos, ypos, 4, 8); + lcd_set_drawmode(DRMODE_SOLID); +#else lcd_putc(x, y, ' '); +#endif } } -#endif + void menu_draw(int m) { int i = 0; @@ -153,20 +180,18 @@ void menu_draw(int m) /* We want to scroll the line where the cursor is */ if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) #ifdef HAVE_LCD_BITMAP - lcd_puts_scroll_style(LINE_X, i-menus[m].top, - P2STR(menus[m].items[i].desc), STYLE_INVERT); -#else - lcd_puts_scroll(LINE_X, i-menus[m].top, - P2STR(menus[m].items[i].desc)); + if (global_settings.invert_cursor) + lcd_puts_scroll_style(LINE_X, i-menus[m].top, + P2STR(menus[m].items[i].desc), STYLE_INVERT); + else #endif + lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc)); else lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc)); } -#ifdef HAVE_LCD_CHARCELLS /* place the cursor */ put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); -#endif #ifdef HAVE_LCD_BITMAP if (global_settings.scrollbar && menus[m].itemcount > menu_lines) -- cgit v1.2.3