Exemple #1
0
        private void RenderAnimation(Cairo.Context cr)
        {
            if (stage.Actor == null)
            {
                // We are not in a transition, just render
                RenderStage(cr, current_track, current_image);
                return;
            }

            if (current_track == null)
            {
                // Fade in the whole stage, nothing to fade out
                CairoExtensions.PushGroup(cr);
                RenderStage(cr, incoming_track, incoming_image);
                CairoExtensions.PopGroupToSource(cr);

                cr.PaintWithAlpha(stage.Actor.Percent);
                return;
            }

            // XFade only the cover art
            RenderCoverArt(cr, incoming_image);

            CairoExtensions.PushGroup(cr);
            RenderCoverArt(cr, current_image);
            CairoExtensions.PopGroupToSource(cr);

            cr.PaintWithAlpha(1.0 - stage.Actor.Percent);

            // Fade in/out the text
            bool same_artist_album = incoming_track != null?incoming_track.ArtistAlbumEqual(current_track) : false;

            bool same_track = incoming_track != null?incoming_track.Equals(current_track) : false;

            if (same_artist_album)
            {
                RenderTrackInfo(cr, incoming_track, same_track, true);
            }

            if (stage.Actor.Percent <= 0.5)
            {
                // Fade out old text
                CairoExtensions.PushGroup(cr);
                RenderTrackInfo(cr, current_track, !same_track, !same_artist_album);
                CairoExtensions.PopGroupToSource(cr);

                cr.PaintWithAlpha(1.0 - (stage.Actor.Percent * 2.0));
            }
            else
            {
                // Fade in new text
                CairoExtensions.PushGroup(cr);
                RenderTrackInfo(cr, incoming_track, !same_track, !same_artist_album);
                CairoExtensions.PopGroupToSource(cr);

                cr.PaintWithAlpha((stage.Actor.Percent - 0.5) * 2.0);
            }
        }
        private void RenderAnimation(Cairo.Context cr)
        {
            if (stage.Actor == null)
            {
                // We are not in a transition, just render
                RenderStage(cr, current_track, current_image);
                return;
            }

            if (current_track == null)
            {
                // Fade in the whole stage, nothing to fade out
                cr.PushGroup();
                RenderStage(cr, incoming_track, incoming_image);
                cr.PopGroupToSource();

                cr.PaintWithAlpha(stage.Actor.Percent);
                return;
            }

            // Draw the old cover art more and more translucent
            cr.PushGroup();
            RenderCoverArt(cr, current_image);
            cr.PopGroupToSource();
            cr.PaintWithAlpha(1.0 - stage.Actor.Percent);

            // Draw the new cover art more and more opaque
            cr.PushGroup();
            RenderCoverArt(cr, incoming_image);
            cr.PopGroupToSource();
            cr.PaintWithAlpha(stage.Actor.Percent);

            bool same_artist_album = incoming_track != null?incoming_track.ArtistAlbumEqual(current_track) : false;

            bool same_track = incoming_track != null?incoming_track.Equals(current_track) : false;

            if (same_artist_album)
            {
                RenderTrackInfo(cr, incoming_track, same_track, true);
            }

            // Don't xfade the text since it'll look bad (overlapping words); instead, fade
            // the old out, and then the new in
            if (stage.Actor.Percent <= 0.5)
            {
                // Fade out old text
                cr.PushGroup();
                RenderTrackInfo(cr, current_track, !same_track, !same_artist_album);
                cr.PopGroupToSource();

                cr.PaintWithAlpha(1.0 - (stage.Actor.Percent * 2.0));
            }
            else
            {
                // Fade in new text
                cr.PushGroup();
                RenderTrackInfo(cr, incoming_track, !same_track, !same_artist_album);
                cr.PopGroupToSource();

                cr.PaintWithAlpha((stage.Actor.Percent - 0.5) * 2.0);
            }
        }