diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist_viewer.c | 21 | ||||
-rw-r--r-- | apps/tree.c | 246 | ||||
-rw-r--r-- | apps/tree.h | 22 |
3 files changed, 113 insertions, 176 deletions
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index e872b495b3..98f04b8eaf 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -130,9 +130,7 @@ static void update_display_line(int line, bool scroll); static void scroll_display(int lines); static void update_first_index(void); static bool update_playlist(bool force); -#ifdef TREE_SHIFT static int onplay_menu(int index); -#endif static bool viewer_menu(void); static bool show_icons(void); static bool show_indices(void); @@ -672,7 +670,6 @@ static bool update_playlist(bool force) return true; } -#ifdef TREE_SHIFT /* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen. Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist changed. */ @@ -747,7 +744,6 @@ static int onplay_menu(int index) return ret; } -#endif /* Menu of viewer options. Invoked via F1(r) or Menu(p). */ static bool viewer_menu(void) @@ -918,20 +914,22 @@ bool playlist_viewer_ex(char* filename) update = true; break; - case TREE_SHIFT | TREE_PREV: - case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT: +#ifdef TREE_PGUP + case TREE_PGUP: + case TREE_PGUP | BUTTON_REPEAT: /* Pageup */ scroll_display(-viewer.num_display_lines); update = true; break; - case TREE_SHIFT | TREE_NEXT: - case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT: + case TREE_PGDN: + case TREE_PGDN | BUTTON_REPEAT: /* Pagedown */ scroll_display(viewer.num_display_lines); update = true; break; - +#endif + case TREE_RUN: if (viewer.move_track >= 0) { @@ -973,7 +971,10 @@ bool playlist_viewer_ex(char* filename) update = true; break; - case TREE_SHIFT | TREE_RUN: + case TREE_CONTEXT: +#ifdef TREE_CONTEXT2 + case TREE_CONTEXT2: +#endif { /* ON+PLAY menu */ int ret; diff --git a/apps/tree.c b/apps/tree.c index a8eb0fcdd1..e9d747f253 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -764,134 +764,6 @@ void set_current_file(char *path) } } -#ifdef TREE_SHIFT -static bool handle_shift(int *ds, int *dc, int numentries, - int tree_max_on_screen, - const int *dirfilter) -{ - bool exit = false; - bool used = false; - - int dirstart = *ds; - int dircursor = *dc; - char buf[MAX_PATH]; - -#ifdef HAVE_LCD_BITMAP - int fw, fh; - lcd_getstringsize("A", &fw, &fh); -#endif - - while (!exit) { - switch (button_get(true)) { - case TREE_PREV: -#ifdef TREE_RC_PREV - case TREE_RC_PREV: -#endif -#ifdef TREE_SHIFT - case TREE_SHIFT | TREE_PREV: - case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT: -#endif - used = true; - if ( dirstart ) { - dirstart -= tree_max_on_screen; - if ( dirstart < 0 ) - dirstart = 0; - } - else - dircursor = 0; - break; - - case TREE_NEXT: -#ifdef TREE_RC_NEXT - case TREE_RC_NEXT: -#endif -#ifdef TREE_SHIFT - case TREE_SHIFT | TREE_NEXT: - case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT: -#endif - used = true; - if ( dirstart < numentries - tree_max_on_screen ) { - dirstart += tree_max_on_screen; - if ( dirstart > - numentries - tree_max_on_screen ) - dirstart = numentries - tree_max_on_screen; - } - else - dircursor = numentries - dirstart - 1; - break; - - - case TREE_RUN | BUTTON_REL: -#ifdef TREE_RC_PLAY - case TREE_RC_RUN: -#endif -#ifdef TREE_SHIFT - case TREE_SHIFT | TREE_RUN | BUTTON_REL: -#endif - { - int onplay_result; - - if(!numentries) - onplay_result = onplay(NULL, 0); - else { - if (currdir[1]) - snprintf(buf, sizeof buf, "%s/%s", - currdir, dircache[dircursor+dirstart].name); - else - snprintf(buf, sizeof buf, "/%s", - dircache[dircursor+dirstart].name); - onplay_result = onplay(buf, - dircache[dircursor+dirstart].attr); - } - - switch (onplay_result) - { - case ONPLAY_OK: - used = true; - break; - case ONPLAY_RELOAD_DIR: - reload_dir = 1; - used = true; - break; - case ONPLAY_START_PLAY: - used = false; /* this will enable the wps */ - break; - } - exit = true; - break; - } -#ifdef TREE_SHIFT - case TREE_SHIFT | BUTTON_REL: - case TREE_SHIFT | TREE_PREV | BUTTON_REL: - case TREE_SHIFT | TREE_NEXT | BUTTON_REL: - exit = true; - break; -#endif - } - if ( used && !exit ) { -#ifdef HAVE_LCD_BITMAP - int xpos,ypos; -#endif - showdir(currdir, dirstart, dirfilter); -#ifdef HAVE_LCD_BITMAP - if (global_settings.invert_cursor) { - xpos = lcd_getxmargin(); - ypos = (CURSOR_Y + dircursor) * fh + lcd_getymargin(); - lcd_invertrect(xpos, ypos, LCD_WIDTH-xpos, fh); - } - else -#endif - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); - lcd_update(); - } - } - *ds = dirstart; - *dc = dircursor; - - return used; -} -#endif - static bool dirbrowse(const char *root, const int *dirfilter) { int numentries=0; @@ -910,6 +782,7 @@ static bool dirbrowse(const char *root, const int *dirfilter) long thumbnail_time = -1; /* for delaying a thumbnail */ bool update_all = false; /* set this to true when the whole file list has been refreshed on screen */ + int lastbutton = 0; #ifdef HAVE_LCD_BITMAP tree_max_on_screen = recalc_screen_height(); @@ -1043,15 +916,14 @@ static bool dirbrowse(const char *root, const int *dirfilter) break; #endif +#ifdef TREE_ENTER case TREE_ENTER: case TREE_ENTER | BUTTON_REPEAT: -#if defined TREE_RC_ENTER && (TREE_RC_ENTER != TREE_RC_RUN) +#endif +#ifdef TREE_RC_ENTER case TREE_RC_ENTER: #endif -#if defined TREE_RUN && (TREE_RUN != TREE_ENTER) case TREE_RUN: - case TREE_RUN | BUTTON_REPEAT: -#endif if ( !numentries ) break; if (currdir[1]) @@ -1320,6 +1192,33 @@ static bool dirbrowse(const char *root, const int *dirfilter) } break; +#ifdef TREE_PGUP + case TREE_PGUP: + case TREE_PGUP | BUTTON_REPEAT: + if ( dirstart ) { + dirstart -= tree_max_on_screen; + if ( dirstart < 0 ) + dirstart = 0; + } + else + dircursor = 0; + restore = true; + break; + + case TREE_PGDN: + case TREE_PGDN | BUTTON_REPEAT: + if ( dirstart < numentries - tree_max_on_screen ) { + dirstart += tree_max_on_screen; + if ( dirstart > + numentries - tree_max_on_screen ) + dirstart = numentries - tree_max_on_screen; + } + else + dircursor = numentries - dirstart - 1; + restore = true; + break; +#endif + case TREE_MENU: if (*dirfilter < NUM_FILTER_MODES) { @@ -1330,35 +1229,27 @@ static bool dirbrowse(const char *root, const int *dirfilter) } break; -#ifdef TREE_SHIFT /* I bet the folks without ON-button want this to - work on a different button */ - case TREE_SHIFT: - if (handle_shift(&dirstart, &dircursor, numentries, - tree_max_on_screen, dirfilter)) - { - /* start scroll */ - restore = true; - } - else + case TREE_WPS: +#ifdef TREE_WPS_PRE + if (lastbutton != TREE_WPS_PRE) + break; +#endif + /* don't enter wps from plugin browser etc */ + if (*dirfilter < NUM_FILTER_MODES) { - if (*dirfilter < NUM_FILTER_MODES) - /* don't catch single ON from .rockbox browsing */ + if (mpeg_status() & MPEG_STATUS_PLAY) { - if (mpeg_status() & MPEG_STATUS_PLAY) - { - start_wps=true; - } - else - { - start_resume(false); - restore = true; - } + start_wps=true; + } + else + { + start_resume(false); + restore = true; } } break; -#endif -#if CONFIG_KEYPAD == RECORDER_PAD +#ifdef BUTTON_F2 case BUTTON_F2: if (*dirfilter < NUM_FILTER_MODES) { @@ -1373,14 +1264,48 @@ static bool dirbrowse(const char *root, const int *dirfilter) { if (quick_screen(CONTEXT_TREE, BUTTON_F3)) reload_root = true; - -#ifdef HAVE_LCD_BITMAP tree_max_on_screen = recalc_screen_height(); -#endif restore = true; } + break; #endif + + case TREE_CONTEXT: +#ifdef TREE_CONTEXT2 + case TREE_CONTEXT2: +#endif + { + int onplay_result; + + if(!numentries) + onplay_result = onplay(NULL, 0); + else { + if (currdir[1]) + snprintf(buf, sizeof buf, "%s/%s", + currdir, dircache[dircursor+dirstart].name); + else + snprintf(buf, sizeof buf, "/%s", + dircache[dircursor+dirstart].name); + onplay_result = onplay(buf, + dircache[dircursor+dirstart].attr); + } + + switch (onplay_result) + { + case ONPLAY_OK: + restore = true; + break; + + case ONPLAY_RELOAD_DIR: + reload_dir = true; + break; + + case ONPLAY_START_PLAY: + start_wps = true; + break; + } break; + } case BUTTON_NONE: if (thumbnail_time != -1 && @@ -1406,10 +1331,13 @@ static bool dirbrowse(const char *root, const int *dirfilter) } if ( button ) + { ata_spin(); + lastbutton = button; + } if (start_wps) - { + { lcd_stop_scroll(); if (wps_show() == SYS_USB_CONNECTED) reload_root = true; diff --git a/apps/tree.h b/apps/tree.h index 4b3406416f..adbfc625ce 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -26,10 +26,15 @@ #define TREE_PREV BUTTON_UP #define TREE_EXIT BUTTON_LEFT #define TREE_ENTER BUTTON_RIGHT -#define TREE_RUN BUTTON_PLAY +#define TREE_RUN (BUTTON_PLAY | BUTTON_REL) #define TREE_MENU BUTTON_F1 -#define TREE_SHIFT BUTTON_ON #define TREE_OFF BUTTON_OFF +#define TREE_WPS (BUTTON_ON | BUTTON_REL) +#define TREE_WPS_PRE BUTTON_ON +#define TREE_PGUP (BUTTON_ON | BUTTON_UP) +#define TREE_PGDN (BUTTON_ON | BUTTON_DOWN) +#define TREE_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT) +#define TREE_CONTEXT2 (BUTTON_ON | BUTTON_PLAY) #define TREE_RC_NEXT BUTTON_RC_RIGHT #define TREE_RC_REV BUTTON_RC_LEFT @@ -41,10 +46,12 @@ #define TREE_NEXT BUTTON_RIGHT #define TREE_PREV BUTTON_LEFT #define TREE_EXIT BUTTON_STOP -#define TREE_ENTER BUTTON_PLAY -#define TREE_RUN BUTTON_PLAY +#define TREE_RUN (BUTTON_PLAY | BUTTON_REL) #define TREE_MENU BUTTON_MENU -#define TREE_SHIFT BUTTON_ON +#define TREE_WPS (BUTTON_ON | BUTTON_REL) +#define TREE_WPS_PRE BUTTON_ON +#define TREE_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT) +#define TREE_CONTEXT2 (BUTTON_ON | BUTTON_PLAY) #define TREE_RC_NEXT BUTTON_RC_RIGHT #define TREE_RC_REV BUTTON_RC_LEFT @@ -56,10 +63,11 @@ #define TREE_NEXT BUTTON_DOWN #define TREE_PREV BUTTON_UP #define TREE_EXIT BUTTON_LEFT -#define TREE_ENTER BUTTON_RIGHT #define TREE_RUN BUTTON_RIGHT #define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT) -#define TREE_SHIFT BUTTON_MENU +#define TREE_WPS (BUTTON_MENU | BUTTON_REL) +#define TREE_WPS_PRE BUTTON_MENU +#define TREE_CONTEXT (BUTTON_RIGHT | BUTTON_REPEAT) #endif |