diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2021-11-17 08:22:56 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-27 09:02:17 -0500 |
commit | fd50baa23ff5e17fad7d549ac226e8cf8dc67b86 (patch) | |
tree | 99d87e39ddb78c83a954258d494521e69cc44652 | |
parent | e4d8431211eef3236a0030b49ed307ce6c048f6c (diff) | |
download | rockbox-fd50baa23f.tar.gz rockbox-fd50baa23f.zip |
PictureFlow: Reversible and interruptible animations
Makes PF usable on older devices with few FPS,
and makes it quicker to navigate on current devices.
- PF_BACK while zooming in to zoom out again
- PF_SELECT or PF_PREV/PF_NEXT while zooming in to skip animation
- PF_BACK while zooming out to skip animation
- PF_PREV/PF_NEXT while zooming out to skip animation + scroll
- PF_SELECT while zooming out to zoom in again
- PF_CONTEXT while zooming out to skip animation and append
- PF_CONTEXT while scrolling to append
- PF_SELECT while scrolling to zoom in
Change-Id: I8d041b53f5990181059fe837a8ca121ebf37a676
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 98ccba56f3..07403083f0 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -3295,6 +3295,47 @@ static void update_cover_out_animation(void) } /** + Skip steps for zooming into the current cover +*/ +static void interrupt_cover_in_animation(void) +{ + pf_state = pf_show_tracks; + cover_animation_keyframe = 0; + extra_fade = 13 * 19; + center_slide.distance = -5 * 19; + center_slide.angle = 19 + (15 * 16); +} + +/** + Skip steps for zooming out the current cover +*/ +static void interrupt_cover_out_animation(void) +{ + pf_state = pf_idle; + cover_animation_keyframe = 0; + extra_fade = 0; + set_current_slide(center_index); +} + +/** + Stop zooming out the current cover and start zooming in +*/ +static void revert_cover_out_animation(void) +{ + pf_state = pf_cover_in; + cover_animation_keyframe = 34 - cover_animation_keyframe; +} + +/** + Stop zooming into the current cover and start zooming out +*/ +static void revert_cover_in_animation(void) +{ + pf_state = pf_cover_out; + cover_animation_keyframe = 34 - cover_animation_keyframe; +} + +/** Draw a blue gradient at y with height h */ static inline void draw_gradient(int y, int h) @@ -3817,7 +3858,11 @@ static int pictureflow_main(void) pf_state = pf_cover_out; free_borrowed_tracks(); } - if (pf_state == pf_idle || pf_state == pf_scrolling) + else if (pf_state == pf_cover_in) + revert_cover_in_animation(); + else if (pf_state == pf_cover_out) + interrupt_cover_out_animation(); + else if (pf_state == pf_idle || pf_state == pf_scrolling) return PLUGIN_OK; break; case PF_MENU: @@ -3838,6 +3883,11 @@ static int pictureflow_main(void) case PF_NEXT_REPEAT: if ( pf_state == pf_show_tracks ) select_next_track(); + else if (pf_state == pf_cover_in) + interrupt_cover_in_animation(); + else if (pf_state == pf_cover_out) + interrupt_cover_out_animation(); + if ( pf_state == pf_idle || pf_state == pf_scrolling ) show_next_slide(); break; @@ -3846,13 +3896,27 @@ static int pictureflow_main(void) case PF_PREV_REPEAT: if ( pf_state == pf_show_tracks ) select_prev_track(); + else if (pf_state == pf_cover_in) + interrupt_cover_in_animation(); + else if (pf_state == pf_cover_out) + interrupt_cover_out_animation(); + if ( pf_state == pf_idle || pf_state == pf_scrolling ) show_previous_slide(); break; #if PF_PLAYBACK_CAPABLE case PF_CONTEXT: - if ( pf_cfg.auto_wps != 0 && - (pf_state == pf_idle || pf_state == pf_show_tracks)) { + if (pf_cfg.auto_wps != 0 && + (pf_state == pf_idle || pf_state == pf_scrolling || + pf_state == pf_show_tracks || pf_state == pf_cover_out)) { + + if ( pf_state == pf_scrolling) + { + set_current_slide(target); + pf_state = pf_idle; + } else if (pf_state == pf_cover_out) + interrupt_cover_out_animation(); + if( pf_state == pf_idle ) { create_track_index(center_slide.slide_index); reset_track_list(); @@ -3887,7 +3951,9 @@ static int pictureflow_main(void) break; } case PF_SELECT: - if ( pf_state == pf_idle ) { + if ( pf_state == pf_idle || pf_state == pf_scrolling) { + if (pf_state == pf_scrolling) + set_current_slide(target); #if PF_PLAYBACK_CAPABLE if(pf_cfg.auto_wps == 1) { create_track_index(center_slide.slide_index); @@ -3900,6 +3966,10 @@ static int pictureflow_main(void) #endif pf_state = pf_cover_in; } + else if (pf_state == pf_cover_out) + revert_cover_out_animation(); + else if (pf_state == pf_cover_in) + interrupt_cover_in_animation(); else if ( pf_state == pf_show_tracks ) { #if PF_PLAYBACK_CAPABLE start_playback(false); |