Пример #1
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();
        }