示例#1
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnDrawn(cr));
            }

            double x     = Allocation.Width / 2;
            double y     = Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            Gdk.RGBA             rgba  = StyleContext.GetBackgroundColor(StateFlags.Selected);
            Cairo.Color          color = CairoExtensions.GdkRGBAToCairoColor(rgba);
            Cairo.RadialGradient fill  = new Cairo.RadialGradient(x, y, 0, x, y, r);
            color.A = alpha;
            fill.AddColorStop(0, color);
            fill.AddColorStop(0.5, color);
            color.A = 0;
            fill.AddColorStop(1, color);

            cr.Arc(x, y, r, 0, 2 * Math.PI);
            cr.Pattern = fill;
            cr.Fill();
            fill.Destroy();

            return(base.OnDrawn(cr));
        }
示例#2
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnExposeEvent(evnt));
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow);

            double x     = Allocation.X + Allocation.Width / 2;
            double y     = Allocation.Y + Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            Cairo.Color          color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Selected));
            Cairo.RadialGradient fill  = new Cairo.RadialGradient(x, y, 0, x, y, r);
            color.A = alpha;
            fill.AddColorStop(0, color);
            fill.AddColorStop(0.5, color);
            color.A = 0;
            fill.AddColorStop(1, color);

            cr.Arc(x, y, r, 0, 2 * Math.PI);
            cr.Pattern = fill;
            cr.Fill();
            fill.Destroy();

            CairoExtensions.DisposeContext(cr);
            return(base.OnExposeEvent(evnt));
        }
示例#3
0
        public static void Gradient (Cairo.Context cr, Theme theme, Rect rect, double opacity)
        {
            cr.Save ();
            cr.Translate (rect.X, rect.Y);

            var x = rect.Width / 2.0;
            var y = rect.Height / 2.0;
            var grad = new Cairo.RadialGradient (x, y, 0, x, y, rect.Width / 2.0);
            grad.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.1 * opacity));
            grad.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.35 * opacity));
            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
            cr.Fill ();
            grad.Destroy ();

            cr.Restore ();
        }
        public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity)
        {
            cr.Save();
            cr.Translate(rect.X, rect.Y);

            var x    = rect.Width / 2.0;
            var y    = rect.Height / 2.0;
            var grad = new Cairo.RadialGradient(x, y, 0, x, y, rect.Width / 2.0);

            grad.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.1 * opacity));
            grad.AddColorStop(1, new Cairo.Color(0, 0, 0, 0.35 * opacity));
            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle(cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
            cr.Fill();
            grad.Destroy();

            cr.Restore();
        }
示例#5
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing) {
                return base.OnDrawn (cr);
            }

            double x = Allocation.Width / 2;
            double y = Allocation.Height / 2;
            double r = Math.Min (Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine);

            Gdk.RGBA rgba = StyleContext.GetBackgroundColor (StateFlags.Selected);
            Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor (rgba);
            Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r);
            color.A = alpha;
            fill.AddColorStop (0, color);
            fill.AddColorStop (0.5, color);
            color.A = 0;
            fill.AddColorStop (1, color);

            cr.Arc (x, y, r, 0, 2 * Math.PI);
            cr.Pattern = fill;
            cr.Fill ();
            fill.Destroy ();

            return base.OnDrawn (cr);
        }
示例#6
0
        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
        {
            if (!pulsator.IsPulsing) {
                return base.OnExposeEvent (evnt);
            }

            Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow);

            double x = Allocation.X + Allocation.Width / 2;
            double y = Allocation.Y + Allocation.Height / 2;
            double r = Math.Min (Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine);

            Cairo.Color color = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Selected));
            Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r);
            color.A = alpha;
            fill.AddColorStop (0, color);
            fill.AddColorStop (0.5, color);
            color.A = 0;
            fill.AddColorStop (1, color);

            cr.Arc (x, y, r, 0, 2 * Math.PI);
            cr.Pattern = fill;
            cr.Fill ();
            fill.Destroy ();

            CairoExtensions.DisposeContext (cr);
            return base.OnExposeEvent (evnt);
        }