diff options
-rw-r--r-- | apps/menu.c | 38 | ||||
-rw-r--r-- | apps/tree.c | 32 |
2 files changed, 46 insertions, 24 deletions
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 @@ | |||
23 | #include "kernel.h" | 23 | #include "kernel.h" |
24 | #include "debug.h" | 24 | #include "debug.h" |
25 | 25 | ||
26 | #ifdef HAVE_LCD_BITMAP | ||
27 | #include "icons.h" | ||
28 | #endif | ||
29 | |||
26 | struct menu { | 30 | struct menu { |
27 | int top; | 31 | int top; |
28 | int cursor; | 32 | int cursor; |
@@ -38,19 +42,37 @@ struct menu { | |||
38 | #define MENU_LINES 2 | 42 | #define MENU_LINES 2 |
39 | #endif | 43 | #endif |
40 | 44 | ||
41 | #ifdef HAVE_LCD_BITMAP | ||
42 | #define CURSOR_CHAR "-" | ||
43 | #else | ||
44 | #ifdef HAVE_NEW_CHARCELL_LCD | 45 | #ifdef HAVE_NEW_CHARCELL_LCD |
45 | #define CURSOR_CHAR "\x7e" | 46 | #define CURSOR_CHAR "\x7e" |
46 | #else | 47 | #else |
47 | #define CURSOR_CHAR "\x89" | 48 | #define CURSOR_CHAR "\x89" |
48 | #endif | 49 | #endif |
49 | #endif | ||
50 | 50 | ||
51 | static struct menu menus[MAX_MENUS]; | 51 | static struct menu menus[MAX_MENUS]; |
52 | static bool inuse[MAX_MENUS] = { false }; | 52 | static bool inuse[MAX_MENUS] = { false }; |
53 | 53 | ||
54 | /* count in letter posistions, NOT pixels */ | ||
55 | void put_cursorxy(int x, int y, bool on) | ||
56 | { | ||
57 | /* place the cursor */ | ||
58 | if(on) { | ||
59 | #ifdef HAVE_LCD_BITMAP | ||
60 | lcd_bitmap ( bitmap_icons_6x8[Cursor], | ||
61 | x*6, y*8, 6, 8, true); | ||
62 | #else | ||
63 | lcd_puts(x, y, CURSOR_CHAR); | ||
64 | #endif | ||
65 | } | ||
66 | else { | ||
67 | #ifdef HAVE_LCD_BITMAP | ||
68 | /* I use xy here since it needs to disregard the margins */ | ||
69 | lcd_putsxy (x*6, y*8, " ", 0); | ||
70 | #else | ||
71 | lcd_puts(x, y, " "); | ||
72 | #endif | ||
73 | } | ||
74 | } | ||
75 | |||
54 | static void menu_draw(int m) | 76 | static void menu_draw(int m) |
55 | { | 77 | { |
56 | int i = 0; | 78 | int i = 0; |
@@ -66,8 +88,8 @@ static void menu_draw(int m) | |||
66 | lcd_puts(1, i-menus[m].top, menus[m].items[i].desc); | 88 | lcd_puts(1, i-menus[m].top, menus[m].items[i].desc); |
67 | } | 89 | } |
68 | 90 | ||
69 | /* place the cursor */ | 91 | /* place the cursor */ |
70 | lcd_puts(0, menus[m].cursor - menus[m].top, CURSOR_CHAR); | 92 | put_cursorxy(0, menus[m].cursor - menus[m].top, true); |
71 | 93 | ||
72 | lcd_update(); | 94 | lcd_update(); |
73 | } | 95 | } |
@@ -80,7 +102,7 @@ static void put_cursor(int m, int target) | |||
80 | { | 102 | { |
81 | bool do_update = true; | 103 | bool do_update = true; |
82 | 104 | ||
83 | lcd_puts(0, menus[m].cursor - menus[m].top, " "); | 105 | put_cursorxy(0, menus[m].cursor - menus[m].top, false); |
84 | menus[m].cursor = target; | 106 | menus[m].cursor = target; |
85 | 107 | ||
86 | if ( target < menus[m].top ) { | 108 | if ( target < menus[m].top ) { |
@@ -95,7 +117,7 @@ static void put_cursor(int m, int target) | |||
95 | } | 117 | } |
96 | 118 | ||
97 | if (do_update) { | 119 | if (do_update) { |
98 | lcd_puts(0, menus[m].cursor - menus[m].top, CURSOR_CHAR); | 120 | put_cursorxy(0, menus[m].cursor - menus[m].top, true); |
99 | lcd_update(); | 121 | lcd_update(); |
100 | } | 122 | } |
101 | 123 | ||
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) | |||
67 | #define LINE_Y 0 /* Y position the entry-list starts at */ | 67 | #define LINE_Y 0 /* Y position the entry-list starts at */ |
68 | #define LINE_X 2 /* X position the entry-list starts at */ | 68 | #define LINE_X 2 /* X position the entry-list starts at */ |
69 | #define LINE_HEIGTH 8 /* pixels for each text line */ | 69 | #define LINE_HEIGTH 8 /* pixels for each text line */ |
70 | #define CURSOR_CHAR "-" | 70 | |
71 | #define CURSOR_Y 1 /* the cursor is not positioned in regard to | ||
72 | the margins, so this is the amount of lines | ||
73 | we add to the cursor Y position to position | ||
74 | it on a line */ | ||
71 | 75 | ||
72 | extern unsigned char bitmap_icons_6x8[LastIcon][6]; | 76 | extern unsigned char bitmap_icons_6x8[LastIcon][6]; |
73 | 77 | ||
@@ -78,11 +82,7 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6]; | |||
78 | #define LINE_Y 0 /* Y position the entry-list starts at */ | 82 | #define LINE_Y 0 /* Y position the entry-list starts at */ |
79 | #define LINE_X 1 /* X position the entry-list starts at */ | 83 | #define LINE_X 1 /* X position the entry-list starts at */ |
80 | 84 | ||
81 | #ifdef HAVE_NEW_CHARCELL_LCD | 85 | #define CURSOR_Y 0 /* not really used for players */ |
82 | #define CURSOR_CHAR "\x7e" | ||
83 | #else | ||
84 | #define CURSOR_CHAR "\x89" | ||
85 | #endif | ||
86 | 86 | ||
87 | #endif /* HAVE_LCD_BITMAP */ | 87 | #endif /* HAVE_LCD_BITMAP */ |
88 | 88 | ||
@@ -239,7 +239,7 @@ bool dirbrowse(char *root) | |||
239 | if (numentries == -1) | 239 | if (numentries == -1) |
240 | return -1; /* root is not a directory */ | 240 | return -1; /* root is not a directory */ |
241 | 241 | ||
242 | lcd_puts(0, dircursor, CURSOR_CHAR); | 242 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
243 | if ( numentries ) | 243 | if ( numentries ) |
244 | lcd_puts_scroll(LINE_X, LINE_Y+dircursor, | 244 | lcd_puts_scroll(LINE_X, LINE_Y+dircursor, |
245 | dircacheptr[start+dircursor]->name); | 245 | dircacheptr[start+dircursor]->name); |
@@ -266,7 +266,7 @@ bool dirbrowse(char *root) | |||
266 | else | 266 | else |
267 | start = dircursor = 0; | 267 | start = dircursor = 0; |
268 | numentries = showdir(currdir, start); | 268 | numentries = showdir(currdir, start); |
269 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 269 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
270 | } | 270 | } |
271 | else | 271 | else |
272 | mpeg_stop(); | 272 | mpeg_stop(); |
@@ -310,21 +310,21 @@ bool dirbrowse(char *root) | |||
310 | } | 310 | } |
311 | } | 311 | } |
312 | numentries = showdir(currdir, start); | 312 | numentries = showdir(currdir, start); |
313 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 313 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
314 | break; | 314 | break; |
315 | 315 | ||
316 | case TREE_PREV: | 316 | case TREE_PREV: |
317 | if(dircursor) { | 317 | if(dircursor) { |
318 | lcd_puts(0, LINE_Y+dircursor, " "); | 318 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); |
319 | dircursor--; | 319 | dircursor--; |
320 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 320 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
321 | lcd_update(); | 321 | lcd_update(); |
322 | } | 322 | } |
323 | else { | 323 | else { |
324 | if (start) { | 324 | if (start) { |
325 | start--; | 325 | start--; |
326 | numentries = showdir(currdir, start); | 326 | numentries = showdir(currdir, start); |
327 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 327 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | break; | 330 | break; |
@@ -332,14 +332,14 @@ bool dirbrowse(char *root) | |||
332 | case TREE_NEXT: | 332 | case TREE_NEXT: |
333 | if (dircursor + start + 1 < numentries ) { | 333 | if (dircursor + start + 1 < numentries ) { |
334 | if(dircursor+1 < TREE_MAX_ON_SCREEN) { | 334 | if(dircursor+1 < TREE_MAX_ON_SCREEN) { |
335 | lcd_puts(0, LINE_Y+dircursor, " "); | 335 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); |
336 | dircursor++; | 336 | dircursor++; |
337 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 337 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
338 | } | 338 | } |
339 | else { | 339 | else { |
340 | start++; | 340 | start++; |
341 | numentries = showdir(currdir, start); | 341 | numentries = showdir(currdir, start); |
342 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 342 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | break; | 345 | break; |
@@ -352,7 +352,7 @@ bool dirbrowse(char *root) | |||
352 | /* TODO: this is just a copy from BUTTON_STOP, fix it */ | 352 | /* TODO: this is just a copy from BUTTON_STOP, fix it */ |
353 | lcd_clear_display(); | 353 | lcd_clear_display(); |
354 | numentries = showdir(currdir, start); | 354 | numentries = showdir(currdir, start); |
355 | lcd_puts(0, LINE_Y+dircursor, CURSOR_CHAR); | 355 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
356 | 356 | ||
357 | break; | 357 | break; |
358 | } | 358 | } |