Esempio n. 1
0
        protected override void ClippedRender(Hyena.Data.Gui.CellContext context)
        {
            if (!EnsureLayout ()) {
                return;
            }

            var cr = context.Context;
            context.Theme.Widget.StyleContext.Save ();
            if (context.TextAsForeground) {
                context.Theme.Widget.StyleContext.AddClass ("button");
            } else {
                context.Theme.Widget.StyleContext.AddClass ("entry");
            }
            Foreground = new Brush (context.Theme.Widget.StyleContext.GetColor (context.State));

            Brush foreground = Foreground;
            if (!foreground.IsValid) {
                return;
            }

            cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip ();

            bool fade = Fade && text_alloc.Width > RenderSize.Width;

            if (fade) {
                cr.PushGroup ();
            }

            Foreground.Apply (cr);
            UpdateLayout (GetText (), RenderSize.Width, RenderSize.Height, true);
            if (Hyena.PlatformDetection.IsWindows) {
              // FIXME windows; working around some unknown issue with ShowLayout; bgo#644311

              cr.Antialias = Cairo.Antialias.None;
              PangoCairoHelper.LayoutPath (cr, layout, true);
            } else {
              PangoCairoHelper.ShowLayout (cr, layout);
            }

            TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;

            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 ();
            context.Theme.Widget.StyleContext.Restore ();
        }