protected override bool OnDrawn(Cairo.Context cr) { if (!CairoHelper.ShouldDrawWindow(cr, Window)) { return(base.OnDrawn(cr)); } if (reflect) { cr.PushGroup(); } cr.Operator = Operator.Over; cr.Translate(h_padding, 0); cr.Rectangle(0, 0, Allocation.Width - h_padding, Math.Max(2 * bar_height, bar_height + bar_label_spacing + layout_height)); cr.Clip(); using (var bar = RenderBar(Allocation.Width - 2 * h_padding, bar_height)) { cr.Save(); cr.SetSource(bar); cr.Paint(); cr.Restore(); if (reflect) { cr.Save(); cr.Rectangle(0, bar_height, Allocation.Width - h_padding, bar_height); cr.Clip(); Matrix matrix = new Matrix(); matrix.InitScale(1, -1); matrix.Translate(0, -(2 * bar_height) + 1); cr.Transform(matrix); cr.SetSource(bar); using (var mask = new LinearGradient(0, 0, 0, bar_height)) { mask.AddColorStop(0.25, new Color(0, 0, 0, 0)); mask.AddColorStop(0.5, new Color(0, 0, 0, 0.125)); mask.AddColorStop(0.75, new Color(0, 0, 0, 0.4)); mask.AddColorStop(1.0, new Color(0, 0, 0, 0.7)); cr.Mask(mask); } cr.Restore(); cr.PopGroupToSource(); cr.Paint(); } if (show_labels) { cr.Translate((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2, bar_height + bar_label_spacing); RenderLabels(cr); } } return(true); }
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); } }
protected override void ClippedRender(Context cr) { if (!EnsureLayout ()) { return; } Brush foreground = Foreground; if (!foreground.IsValid) { return; } cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height); cr.Clip (); bool fade = text_alloc.Width > RenderSize.Width; if (fade) { cr.PushGroup (); } cr.MoveTo (text_alloc.X, text_alloc.Y); Foreground.Apply (cr); Pango.CairoHelper.ShowLayout (cr, layout); cr.Fill (); if (fade) { LinearGradient mask = new LinearGradient (RenderSize.Width - 20, 0, RenderSize.Width, 0); mask.AddColorStop (0, new Color (0, 0, 0, 1)); mask.AddColorStop (1, new Color (0, 0, 0, 0)); cr.PopGroupToSource (); cr.Mask (mask); mask.Destroy (); } cr.ResetClip (); }