diff options
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 121 |
1 files changed, 68 insertions, 53 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index b5ea0af9ae..3b308d1866 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -2072,8 +2072,6 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
2072 | int buflen) | 2072 | int buflen) |
2073 | { | 2073 | { |
2074 | bool ret; | 2074 | bool ret; |
2075 | if (slide_index == -1) | ||
2076 | rb->strlcpy(buf, EMPTY_SLIDE, buflen); | ||
2077 | 2075 | ||
2078 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) | 2076 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) |
2079 | return false; | 2077 | return false; |
@@ -3162,7 +3160,7 @@ static inline void set_current_slide(const int slide_index) | |||
3162 | } | 3160 | } |
3163 | 3161 | ||
3164 | 3162 | ||
3165 | static void interrupt_cover_out_animation(void); | 3163 | static void skip_animation_to_idle_state(void); |
3166 | static bool sort_albums(int new_sorting, bool from_settings) | 3164 | static bool sort_albums(int new_sorting, bool from_settings) |
3167 | { | 3165 | { |
3168 | int i, album_idx, artist_idx; | 3166 | int i, album_idx, artist_idx; |
@@ -3196,7 +3194,7 @@ static bool sort_albums(int new_sorting, bool from_settings) | |||
3196 | if (pf_state == pf_show_tracks || | 3194 | if (pf_state == pf_show_tracks || |
3197 | pf_state == pf_cover_in || | 3195 | pf_state == pf_cover_in || |
3198 | pf_state == pf_cover_out) | 3196 | pf_state == pf_cover_out) |
3199 | interrupt_cover_out_animation(); | 3197 | skip_animation_to_idle_state(); |
3200 | else if (pf_state == pf_scrolling) | 3198 | else if (pf_state == pf_scrolling) |
3201 | set_current_slide(target); | 3199 | set_current_slide(target); |
3202 | pf_state = pf_idle; | 3200 | pf_state = pf_idle; |
@@ -3256,6 +3254,8 @@ static void start_animation(void) | |||
3256 | pf_state = pf_scrolling; | 3254 | pf_state = pf_scrolling; |
3257 | } | 3255 | } |
3258 | 3256 | ||
3257 | static void update_scroll_animation(void); | ||
3258 | |||
3259 | /** | 3259 | /** |
3260 | Go to the previous slide | 3260 | Go to the previous slide |
3261 | */ | 3261 | */ |
@@ -3269,6 +3269,8 @@ static void show_previous_slide(void) | |||
3269 | } else if ( step > 0 ) { | 3269 | } else if ( step > 0 ) { |
3270 | target = center_index; | 3270 | target = center_index; |
3271 | step = (target <= center_slide.slide_index) ? -1 : 1; | 3271 | step = (target <= center_slide.slide_index) ? -1 : 1; |
3272 | if (step < 0) | ||
3273 | update_scroll_animation(); | ||
3272 | } else { | 3274 | } else { |
3273 | target = fmax(0, center_index - 2); | 3275 | target = fmax(0, center_index - 2); |
3274 | } | 3276 | } |
@@ -3288,6 +3290,8 @@ static void show_next_slide(void) | |||
3288 | } else if ( step < 0 ) { | 3290 | } else if ( step < 0 ) { |
3289 | target = center_index; | 3291 | target = center_index; |
3290 | step = (target < center_slide.slide_index) ? -1 : 1; | 3292 | step = (target < center_slide.slide_index) ? -1 : 1; |
3293 | if (step > 0) | ||
3294 | update_scroll_animation(); | ||
3291 | } else { | 3295 | } else { |
3292 | target = fmin(center_index + 2, number_of_slides - 1); | 3296 | target = fmin(center_index + 2, number_of_slides - 1); |
3293 | } | 3297 | } |
@@ -3473,7 +3477,7 @@ static void cleanup(void) | |||
3473 | #endif | 3477 | #endif |
3474 | } | 3478 | } |
3475 | 3479 | ||
3476 | static void interrupt_cover_in_animation(void); | 3480 | static void skip_animation_to_show_tracks(void); |
3477 | static void adjust_album_display_for_setting(int old_val, int new_val) | 3481 | static void adjust_album_display_for_setting(int old_val, int new_val) |
3478 | { | 3482 | { |
3479 | if (old_val == new_val) | 3483 | if (old_val == new_val) |
@@ -3484,7 +3488,7 @@ static void adjust_album_display_for_setting(int old_val, int new_val) | |||
3484 | reset_slides(); | 3488 | reset_slides(); |
3485 | 3489 | ||
3486 | if (pf_state == pf_show_tracks) | 3490 | if (pf_state == pf_show_tracks) |
3487 | interrupt_cover_in_animation(); | 3491 | skip_animation_to_show_tracks(); |
3488 | } | 3492 | } |
3489 | 3493 | ||
3490 | /** | 3494 | /** |
@@ -3706,21 +3710,33 @@ static int main_menu(void) | |||
3706 | } | 3710 | } |
3707 | } | 3711 | } |
3708 | 3712 | ||
3713 | #define ZOOMIN_FRAME_COUNT 19 | ||
3714 | #define ZOOMIN_FRAME_DIST -5 | ||
3715 | #define ZOOMIN_FRAME_ANGLE 1 | ||
3716 | #define ZOOMIN_FRAME_FADE 13 | ||
3717 | |||
3718 | #define ROTATE_FRAME_COUNT 15 | ||
3719 | #define ROTATE_FRAME_ANGLE 16 | ||
3720 | |||
3721 | #define KEYFRAME_COUNT ZOOMIN_FRAME_COUNT + ROTATE_FRAME_COUNT | ||
3722 | |||
3709 | /** | 3723 | /** |
3710 | Animation step for zooming into the current cover | 3724 | Animation step for zooming into the current cover |
3711 | */ | 3725 | */ |
3712 | static void update_cover_in_animation(void) | 3726 | static void update_cover_in_animation(void) |
3713 | { | 3727 | { |
3714 | cover_animation_keyframe++; | 3728 | cover_animation_keyframe++; |
3715 | if( cover_animation_keyframe < 20 ) { | 3729 | |
3716 | center_slide.distance-=5; | 3730 | if(cover_animation_keyframe <= ZOOMIN_FRAME_COUNT) |
3717 | center_slide.angle+=1; | 3731 | { |
3718 | extra_fade += 13; | 3732 | center_slide.distance += ZOOMIN_FRAME_DIST; |
3719 | } | 3733 | center_slide.angle += ZOOMIN_FRAME_ANGLE; |
3720 | else if( cover_animation_keyframe < 35 ) { | 3734 | extra_fade += ZOOMIN_FRAME_FADE; |
3721 | center_slide.angle+=16; | ||
3722 | } | 3735 | } |
3723 | else { | 3736 | else if(cover_animation_keyframe <= KEYFRAME_COUNT) |
3737 | center_slide.angle += ROTATE_FRAME_ANGLE; | ||
3738 | else | ||
3739 | { | ||
3724 | cover_animation_keyframe = 0; | 3740 | cover_animation_keyframe = 0; |
3725 | pf_state = pf_show_tracks; | 3741 | pf_state = pf_show_tracks; |
3726 | } | 3742 | } |
@@ -3732,36 +3748,40 @@ static void update_cover_in_animation(void) | |||
3732 | static void update_cover_out_animation(void) | 3748 | static void update_cover_out_animation(void) |
3733 | { | 3749 | { |
3734 | cover_animation_keyframe++; | 3750 | cover_animation_keyframe++; |
3735 | if( cover_animation_keyframe <= 15 ) { | 3751 | |
3736 | center_slide.angle-=16; | 3752 | if(cover_animation_keyframe <= ROTATE_FRAME_COUNT) |
3737 | } | 3753 | center_slide.angle -= ROTATE_FRAME_ANGLE; |
3738 | else if( cover_animation_keyframe < 35 ) { | 3754 | else if(cover_animation_keyframe <= KEYFRAME_COUNT) |
3739 | center_slide.distance+=5; | 3755 | { |
3740 | center_slide.angle-=1; | 3756 | center_slide.distance -= ZOOMIN_FRAME_DIST; |
3741 | extra_fade -= 13; | 3757 | center_slide.angle -= ZOOMIN_FRAME_ANGLE; |
3758 | extra_fade -= ZOOMIN_FRAME_FADE; | ||
3742 | } | 3759 | } |
3743 | else { | 3760 | else |
3761 | { | ||
3744 | cover_animation_keyframe = 0; | 3762 | cover_animation_keyframe = 0; |
3745 | pf_state = pf_idle; | 3763 | pf_state = pf_idle; |
3746 | } | 3764 | } |
3747 | } | 3765 | } |
3748 | 3766 | ||
3749 | /** | 3767 | /** |
3750 | Skip steps for zooming into the current cover | 3768 | Immediately show tracks and skip any animation frames |
3751 | */ | 3769 | */ |
3752 | static void interrupt_cover_in_animation(void) | 3770 | static void skip_animation_to_show_tracks(void) |
3753 | { | 3771 | { |
3754 | pf_state = pf_show_tracks; | 3772 | pf_state = pf_show_tracks; |
3755 | cover_animation_keyframe = 0; | 3773 | cover_animation_keyframe = 0; |
3756 | extra_fade = 13 * 19; | 3774 | |
3757 | center_slide.distance = -5 * 19; | 3775 | extra_fade = ZOOMIN_FRAME_COUNT * ZOOMIN_FRAME_FADE; |
3758 | center_slide.angle = 19 + (15 * 16); | 3776 | center_slide.distance = ZOOMIN_FRAME_COUNT * ZOOMIN_FRAME_DIST; |
3777 | center_slide.angle = (ZOOMIN_FRAME_COUNT * ZOOMIN_FRAME_ANGLE) + | ||
3778 | (ROTATE_FRAME_COUNT * ROTATE_FRAME_ANGLE); | ||
3759 | } | 3779 | } |
3760 | 3780 | ||
3761 | /** | 3781 | /** |
3762 | Skip steps for zooming out the current cover | 3782 | Immediately transition to idle state and skip any animation frames |
3763 | */ | 3783 | */ |
3764 | static void interrupt_cover_out_animation(void) | 3784 | static void skip_animation_to_idle_state(void) |
3765 | { | 3785 | { |
3766 | pf_state = pf_idle; | 3786 | pf_state = pf_idle; |
3767 | cover_animation_keyframe = 0; | 3787 | cover_animation_keyframe = 0; |
@@ -3770,21 +3790,12 @@ static void interrupt_cover_out_animation(void) | |||
3770 | } | 3790 | } |
3771 | 3791 | ||
3772 | /** | 3792 | /** |
3773 | Stop zooming out the current cover and start zooming in | 3793 | Change direction during cover in/out animation |
3774 | */ | 3794 | */ |
3775 | static void revert_cover_out_animation(void) | 3795 | static void reverse_animation(void) |
3776 | { | 3796 | { |
3777 | pf_state = pf_cover_in; | 3797 | pf_state = pf_state == pf_cover_out ? pf_cover_in : pf_cover_out; |
3778 | cover_animation_keyframe = 34 - cover_animation_keyframe; | 3798 | cover_animation_keyframe = KEYFRAME_COUNT - cover_animation_keyframe; |
3779 | } | ||
3780 | |||
3781 | /** | ||
3782 | Stop zooming into the current cover and start zooming out | ||
3783 | */ | ||
3784 | static void revert_cover_in_animation(void) | ||
3785 | { | ||
3786 | pf_state = pf_cover_out; | ||
3787 | cover_animation_keyframe = 34 - cover_animation_keyframe; | ||
3788 | } | 3799 | } |
3789 | 3800 | ||
3790 | /** | 3801 | /** |
@@ -3967,7 +3978,7 @@ static void select_next_album(void) | |||
3967 | free_borrowed_tracks(); | 3978 | free_borrowed_tracks(); |
3968 | target = center_index + 1; | 3979 | target = center_index + 1; |
3969 | set_current_slide(target); | 3980 | set_current_slide(target); |
3970 | interrupt_cover_in_animation(); | 3981 | skip_animation_to_show_tracks(); |
3971 | } | 3982 | } |
3972 | } | 3983 | } |
3973 | 3984 | ||
@@ -3977,7 +3988,7 @@ static void select_prev_album(void) | |||
3977 | free_borrowed_tracks(); | 3988 | free_borrowed_tracks(); |
3978 | target = center_index - 1; | 3989 | target = center_index - 1; |
3979 | set_current_slide(target); | 3990 | set_current_slide(target); |
3980 | interrupt_cover_in_animation(); | 3991 | skip_animation_to_show_tracks(); |
3981 | } | 3992 | } |
3982 | } | 3993 | } |
3983 | 3994 | ||
@@ -4605,9 +4616,9 @@ static int pictureflow_main(const char* selected_file) | |||
4605 | free_borrowed_tracks(); | 4616 | free_borrowed_tracks(); |
4606 | } | 4617 | } |
4607 | else if (pf_state == pf_cover_in) | 4618 | else if (pf_state == pf_cover_in) |
4608 | revert_cover_in_animation(); | 4619 | reverse_animation(); |
4609 | else if (pf_state == pf_cover_out) | 4620 | else if (pf_state == pf_cover_out) |
4610 | interrupt_cover_out_animation(); | 4621 | skip_animation_to_idle_state(); |
4611 | else if (pf_state == pf_idle || pf_state == pf_scrolling) | 4622 | else if (pf_state == pf_idle || pf_state == pf_scrolling) |
4612 | return PLUGIN_OK; | 4623 | return PLUGIN_OK; |
4613 | break; | 4624 | break; |
@@ -4634,9 +4645,9 @@ static int pictureflow_main(const char* selected_file) | |||
4634 | if ( pf_state == pf_show_tracks ) | 4645 | if ( pf_state == pf_show_tracks ) |
4635 | select_next_track(); | 4646 | select_next_track(); |
4636 | else if (pf_state == pf_cover_in) | 4647 | else if (pf_state == pf_cover_in) |
4637 | interrupt_cover_in_animation(); | 4648 | skip_animation_to_show_tracks(); |
4638 | else if (pf_state == pf_cover_out) | 4649 | else if (pf_state == pf_cover_out) |
4639 | interrupt_cover_out_animation(); | 4650 | skip_animation_to_idle_state(); |
4640 | 4651 | ||
4641 | if ( pf_state == pf_idle || pf_state == pf_scrolling ) | 4652 | if ( pf_state == pf_idle || pf_state == pf_scrolling ) |
4642 | show_next_slide(); | 4653 | show_next_slide(); |
@@ -4647,9 +4658,9 @@ static int pictureflow_main(const char* selected_file) | |||
4647 | if ( pf_state == pf_show_tracks ) | 4658 | if ( pf_state == pf_show_tracks ) |
4648 | select_prev_track(); | 4659 | select_prev_track(); |
4649 | else if (pf_state == pf_cover_in) | 4660 | else if (pf_state == pf_cover_in) |
4650 | interrupt_cover_in_animation(); | 4661 | skip_animation_to_show_tracks(); |
4651 | else if (pf_state == pf_cover_out) | 4662 | else if (pf_state == pf_cover_out) |
4652 | interrupt_cover_out_animation(); | 4663 | skip_animation_to_idle_state(); |
4653 | 4664 | ||
4654 | if ( pf_state == pf_idle || pf_state == pf_scrolling ) | 4665 | if ( pf_state == pf_idle || pf_state == pf_scrolling ) |
4655 | show_previous_slide(); | 4666 | show_previous_slide(); |
@@ -4685,6 +4696,10 @@ static int pictureflow_main(const char* selected_file) | |||
4685 | } | 4696 | } |
4686 | else if ( pf_state == pf_show_tracks ) | 4697 | else if ( pf_state == pf_show_tracks ) |
4687 | select_prev_album(); | 4698 | select_prev_album(); |
4699 | else if (pf_state == pf_cover_in) | ||
4700 | reverse_animation(); | ||
4701 | else if (pf_state == pf_cover_out) | ||
4702 | skip_animation_to_idle_state(); | ||
4688 | break; | 4703 | break; |
4689 | #if PF_PLAYBACK_CAPABLE | 4704 | #if PF_PLAYBACK_CAPABLE |
4690 | case PF_CONTEXT: | 4705 | case PF_CONTEXT: |
@@ -4697,7 +4712,7 @@ static int pictureflow_main(const char* selected_file) | |||
4697 | pf_state = pf_idle; | 4712 | pf_state = pf_idle; |
4698 | } | 4713 | } |
4699 | else if (pf_state == pf_cover_out) | 4714 | else if (pf_state == pf_cover_out) |
4700 | interrupt_cover_out_animation(); | 4715 | skip_animation_to_idle_state(); |
4701 | 4716 | ||
4702 | if (context_menu_ready()) | 4717 | if (context_menu_ready()) |
4703 | { | 4718 | { |
@@ -4727,9 +4742,9 @@ static int pictureflow_main(const char* selected_file) | |||
4727 | pf_state = pf_cover_in; | 4742 | pf_state = pf_cover_in; |
4728 | } | 4743 | } |
4729 | else if (pf_state == pf_cover_out) | 4744 | else if (pf_state == pf_cover_out) |
4730 | revert_cover_out_animation(); | 4745 | reverse_animation(); |
4731 | else if (pf_state == pf_cover_in) | 4746 | else if (pf_state == pf_cover_in) |
4732 | interrupt_cover_in_animation(); | 4747 | skip_animation_to_show_tracks(); |
4733 | #if PF_PLAYBACK_CAPABLE | 4748 | #if PF_PLAYBACK_CAPABLE |
4734 | else if (pf_state == pf_show_tracks) { | 4749 | else if (pf_state == pf_show_tracks) { |
4735 | if(pf_cfg.auto_wps != 0) { | 4750 | if(pf_cfg.auto_wps != 0) { |