diff options
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/apps/tree.c b/apps/tree.c index cbb19fc2bd..80af6e01d6 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -43,6 +43,10 @@ | |||
43 | #include "icons.h" | 43 | #include "icons.h" |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifdef LOADABLE_FONTS | ||
47 | #include "ajf.h" | ||
48 | #endif | ||
49 | |||
46 | #define MAX_FILES_IN_DIR 200 | 50 | #define MAX_FILES_IN_DIR 200 |
47 | #define TREE_MAX_FILENAMELEN MAX_PATH | 51 | #define TREE_MAX_FILENAMELEN MAX_PATH |
48 | #define MAX_DIR_LEVELS 10 | 52 | #define MAX_DIR_LEVELS 10 |
@@ -152,8 +156,20 @@ static int showdir(char *path, int start) | |||
152 | { | 156 | { |
153 | #ifdef HAVE_LCD_BITMAP | 157 | #ifdef HAVE_LCD_BITMAP |
154 | int icon_type = 0; | 158 | int icon_type = 0; |
159 | int line_height = LINE_HEIGTH; | ||
155 | #endif | 160 | #endif |
156 | int i; | 161 | int i; |
162 | int tree_max_on_screen; | ||
163 | #ifdef LOADABLE_FONTS | ||
164 | int fh; | ||
165 | unsigned char *font = lcd_getcurrentldfont(); | ||
166 | fh = ajf_get_fontheight(font); | ||
167 | tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; | ||
168 | line_height = fh; | ||
169 | #else | ||
170 | tree_max_on_screen = TREE_MAX_ON_SCREEN; | ||
171 | #endif | ||
172 | |||
157 | 173 | ||
158 | /* new dir? cache it */ | 174 | /* new dir? cache it */ |
159 | if (strncmp(path,lastdir,sizeof(lastdir))) { | 175 | if (strncmp(path,lastdir,sizeof(lastdir))) { |
@@ -217,7 +233,7 @@ static int showdir(char *path, int start) | |||
217 | lcd_setfont(0); | 233 | lcd_setfont(0); |
218 | #endif | 234 | #endif |
219 | 235 | ||
220 | for ( i=start; i < start+TREE_MAX_ON_SCREEN; i++ ) { | 236 | for ( i=start; i < start+tree_max_on_screen; i++ ) { |
221 | int len; | 237 | int len; |
222 | 238 | ||
223 | if ( i >= filesindir ) | 239 | if ( i >= filesindir ) |
@@ -235,9 +251,10 @@ static int showdir(char *path, int start) | |||
235 | icon_type = File; | 251 | icon_type = File; |
236 | } | 252 | } |
237 | lcd_bitmap(bitmap_icons_6x8[icon_type], | 253 | lcd_bitmap(bitmap_icons_6x8[icon_type], |
238 | 6, MARGIN_Y+(LINE_Y+i-start)*LINE_HEIGTH, 6, 8, true); | 254 | 6, MARGIN_Y+(LINE_Y+i-start)*line_height, 6, 8, true); |
239 | #endif | 255 | #endif |
240 | 256 | ||
257 | |||
241 | /* if MP3 filter is on, cut off the extension */ | 258 | /* if MP3 filter is on, cut off the extension */ |
242 | if (global_settings.mp3filter && | 259 | if (global_settings.mp3filter && |
243 | (dircacheptr[i]->attr & (TREE_ATTR_M3U|TREE_ATTR_MP3))) | 260 | (dircacheptr[i]->attr & (TREE_ATTR_M3U|TREE_ATTR_MP3))) |
@@ -270,6 +287,15 @@ bool dirbrowse(char *root) | |||
270 | int rc; | 287 | int rc; |
271 | int button; | 288 | int button; |
272 | int start_index; | 289 | int start_index; |
290 | int tree_max_on_screen; | ||
291 | #ifdef LOADABLE_FONTS | ||
292 | int fh; | ||
293 | unsigned char *font = lcd_getcurrentldfont(); | ||
294 | fh = ajf_get_fontheight(font); | ||
295 | tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; | ||
296 | #else | ||
297 | tree_max_on_screen = TREE_MAX_ON_SCREEN; | ||
298 | #endif | ||
273 | 299 | ||
274 | memcpy(currdir,root,sizeof(currdir)); | 300 | memcpy(currdir,root,sizeof(currdir)); |
275 | numentries = showdir(root, start); | 301 | numentries = showdir(root, start); |
@@ -379,7 +405,7 @@ bool dirbrowse(char *root) | |||
379 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 405 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); |
380 | } | 406 | } |
381 | else { | 407 | else { |
382 | if (numentries < TREE_MAX_ON_SCREEN) { | 408 | if (numentries < tree_max_on_screen) { |
383 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 409 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, |
384 | false); | 410 | false); |
385 | dircursor = numentries - 1; | 411 | dircursor = numentries - 1; |
@@ -387,11 +413,11 @@ bool dirbrowse(char *root) | |||
387 | true); | 413 | true); |
388 | } | 414 | } |
389 | else { | 415 | else { |
390 | start = numentries - TREE_MAX_ON_SCREEN; | 416 | start = numentries - tree_max_on_screen; |
391 | dircursor = TREE_MAX_ON_SCREEN - 1; | 417 | dircursor = tree_max_on_screen - 1; |
392 | numentries = showdir(currdir, start); | 418 | numentries = showdir(currdir, start); |
393 | put_cursorxy(0, CURSOR_Y + LINE_Y + | 419 | put_cursorxy(0, CURSOR_Y + LINE_Y + |
394 | TREE_MAX_ON_SCREEN - 1, true); | 420 | tree_max_on_screen - 1, true); |
395 | } | 421 | } |
396 | } | 422 | } |
397 | } | 423 | } |
@@ -404,7 +430,7 @@ bool dirbrowse(char *root) | |||
404 | if(filesindir) | 430 | if(filesindir) |
405 | { | 431 | { |
406 | if (dircursor + start + 1 < numentries ) { | 432 | if (dircursor + start + 1 < numentries ) { |
407 | if(dircursor+1 < TREE_MAX_ON_SCREEN) { | 433 | if(dircursor+1 < tree_max_on_screen) { |
408 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 434 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, |
409 | false); | 435 | false); |
410 | dircursor++; | 436 | dircursor++; |
@@ -417,7 +443,7 @@ bool dirbrowse(char *root) | |||
417 | } | 443 | } |
418 | } | 444 | } |
419 | else { | 445 | else { |
420 | if(numentries < TREE_MAX_ON_SCREEN) { | 446 | if(numentries < tree_max_on_screen) { |
421 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 447 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, |
422 | false); | 448 | false); |
423 | start = dircursor = 0; | 449 | start = dircursor = 0; |
@@ -512,7 +538,7 @@ bool dirbrowse(char *root) | |||
512 | /* restore display */ | 538 | /* restore display */ |
513 | /* We need to adjust if the number of lines on screen have | 539 | /* We need to adjust if the number of lines on screen have |
514 | changed because of a status bar change */ | 540 | changed because of a status bar change */ |
515 | if(CURSOR_Y+LINE_Y+dircursor>TREE_MAX_ON_SCREEN) { | 541 | if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) { |
516 | start++; | 542 | start++; |
517 | dircursor--; | 543 | dircursor--; |
518 | } | 544 | } |