diff options
Diffstat (limited to 'apps/menu.c')
-rw-r--r-- | apps/menu.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/apps/menu.c b/apps/menu.c index c8a5d0e73d..7267afe193 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -22,11 +22,14 @@ | |||
22 | #include "button.h" | 22 | #include "button.h" |
23 | #include "kernel.h" | 23 | #include "kernel.h" |
24 | #include "debug.h" | 24 | #include "debug.h" |
25 | #include "panic.h" | ||
25 | 26 | ||
26 | #ifdef HAVE_LCD_BITMAP | 27 | #ifdef HAVE_LCD_BITMAP |
27 | #include "icons.h" | 28 | #include "icons.h" |
28 | #endif | 29 | #endif |
29 | 30 | #ifdef LOADABLE_FONTS | |
31 | #include "ajf.h" | ||
32 | #endif | ||
30 | struct menu { | 33 | struct menu { |
31 | int top; | 34 | int top; |
32 | int cursor; | 35 | int cursor; |
@@ -54,11 +57,19 @@ static bool inuse[MAX_MENUS] = { false }; | |||
54 | /* count in letter posistions, NOT pixels */ | 57 | /* count in letter posistions, NOT pixels */ |
55 | void put_cursorxy(int x, int y, bool on) | 58 | void put_cursorxy(int x, int y, bool on) |
56 | { | 59 | { |
60 | #ifdef LOADABLE_FONTS | ||
61 | int fh; | ||
62 | unsigned char* font = lcd_getcurrentldfont(); | ||
63 | fh = ajf_get_fontheight(font); | ||
64 | #else | ||
65 | int fh = 8; | ||
66 | #endif | ||
67 | |||
57 | /* place the cursor */ | 68 | /* place the cursor */ |
58 | if(on) { | 69 | if(on) { |
59 | #ifdef HAVE_LCD_BITMAP | 70 | #ifdef HAVE_LCD_BITMAP |
60 | lcd_bitmap ( bitmap_icons_6x8[Cursor], | 71 | lcd_bitmap ( bitmap_icons_6x8[Cursor], |
61 | x*6, y*8, 4, 8, true); | 72 | x*6, y*fh, 4, 8, true); |
62 | #elif defined(SIMULATOR) | 73 | #elif defined(SIMULATOR) |
63 | /* player simulator */ | 74 | /* player simulator */ |
64 | unsigned char cursor[] = { 0x7f, 0x3e, 0x1c, 0x08 }; | 75 | unsigned char cursor[] = { 0x7f, 0x3e, 0x1c, 0x08 }; |
@@ -70,7 +81,7 @@ void put_cursorxy(int x, int y, bool on) | |||
70 | else { | 81 | else { |
71 | #if defined(HAVE_LCD_BITMAP) | 82 | #if defined(HAVE_LCD_BITMAP) |
72 | /* I use xy here since it needs to disregard the margins */ | 83 | /* I use xy here since it needs to disregard the margins */ |
73 | lcd_clearrect (x*6, y*8, 4, 8); | 84 | lcd_clearrect (x*6, y*fh, 4, 8); |
74 | #elif defined(SIMULATOR) | 85 | #elif defined(SIMULATOR) |
75 | /* player simulator in action */ | 86 | /* player simulator in action */ |
76 | lcd_clearrect (x*6, 12+y*16, 4, 8); | 87 | lcd_clearrect (x*6, 12+y*16, 4, 8); |
@@ -83,6 +94,15 @@ void put_cursorxy(int x, int y, bool on) | |||
83 | static void menu_draw(int m) | 94 | static void menu_draw(int m) |
84 | { | 95 | { |
85 | int i = 0; | 96 | int i = 0; |
97 | #ifdef LOADABLE_FONTS | ||
98 | int menu_lines; | ||
99 | int fh; | ||
100 | unsigned char* font = lcd_getcurrentldfont(); | ||
101 | fh = ajf_get_fontheight(font); | ||
102 | menu_lines = LCD_HEIGHT/fh; | ||
103 | #else | ||
104 | int menu_lines = MENU_LINES; | ||
105 | #endif | ||
86 | 106 | ||
87 | lcd_clear_display(); | 107 | lcd_clear_display(); |
88 | lcd_stop_scroll(); | 108 | lcd_stop_scroll(); |
@@ -91,7 +111,7 @@ static void menu_draw(int m) | |||
91 | lcd_setfont(0); | 111 | lcd_setfont(0); |
92 | #endif | 112 | #endif |
93 | for (i = menus[m].top; | 113 | for (i = menus[m].top; |
94 | (i < menus[m].itemcount) && (i<menus[m].top+MENU_LINES); | 114 | (i < menus[m].itemcount) && (i<menus[m].top+menu_lines); |
95 | i++) { | 115 | i++) { |
96 | if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) | 116 | if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) |
97 | lcd_puts_scroll(1, i-menus[m].top, menus[m].items[i].desc); | 117 | lcd_puts_scroll(1, i-menus[m].top, menus[m].items[i].desc); |
@@ -111,7 +131,15 @@ static void menu_draw(int m) | |||
111 | static void put_cursor(int m, int target) | 131 | static void put_cursor(int m, int target) |
112 | { | 132 | { |
113 | bool do_update = true; | 133 | bool do_update = true; |
114 | 134 | #ifdef LOADABLE_FONTS | |
135 | int menu_lines; | ||
136 | int fh; | ||
137 | unsigned char* font = lcd_getcurrentldfont(); | ||
138 | fh = ajf_get_fontheight(font); | ||
139 | menu_lines = LCD_HEIGHT/fh; | ||
140 | #else | ||
141 | int menu_lines = MENU_LINES; | ||
142 | #endif | ||
115 | put_cursorxy(0, menus[m].cursor - menus[m].top, false); | 143 | put_cursorxy(0, menus[m].cursor - menus[m].top, false); |
116 | menus[m].cursor = target; | 144 | menus[m].cursor = target; |
117 | menu_draw(m); | 145 | menu_draw(m); |
@@ -121,7 +149,7 @@ static void put_cursor(int m, int target) | |||
121 | menu_draw(m); | 149 | menu_draw(m); |
122 | do_update = false; | 150 | do_update = false; |
123 | } | 151 | } |
124 | else if ( target-menus[m].top > MENU_LINES-1 ) { | 152 | else if ( target-menus[m].top > menu_lines-1 ) { |
125 | menus[m].top++; | 153 | menus[m].top++; |
126 | menu_draw(m); | 154 | menu_draw(m); |
127 | do_update = false; | 155 | do_update = false; |