Beispiel #1
0
        protected void UpdateTexture ()
        {
            text.SetSurfaceSize ((uint) (Width+MarginX),(uint) (Height+MarginY));
            text.Clear ();
            Cairo.Context context = text.Create ();

            double lwidth = 1;
            double hlwidth = lwidth*0.5;
            double width = Width - lwidth;
            double height = Height - lwidth;
            double radius = Math.Min(marginX, marginY)*0.75;

            if ((radius > height / 2) || (radius > width / 2))
                radius = Math.Min(height / 2, width / 2);

            context.MoveTo (hlwidth, hlwidth + radius);
            context.Arc (hlwidth + radius, hlwidth + radius, radius, Math.PI, -Math.PI / 2);
            context.LineTo (hlwidth + width - radius, hlwidth);
            context.Arc (hlwidth + width - radius, hlwidth + radius, radius, -Math.PI / 2, 0);
            context.LineTo (hlwidth + width, hlwidth + height - radius);
            context.Arc (hlwidth + width - radius, hlwidth + height - radius, radius, 0, Math.PI / 2);
            context.LineTo (hlwidth + radius, hlwidth + height);
            context.Arc (hlwidth + radius, hlwidth + height - radius, radius, Math.PI / 2, Math.PI);
            context.ClosePath ();

            context.LineWidth = lwidth;
            context.SetSourceRGB (1.0,1.0,1.0);
            context.Stroke ();

            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();
        }
Beispiel #2
0
        public static void MakeReflection(Cairo.ImageSurface source, CairoTexture dest)
        {
            int w = source.Width + 4;
            int h = source.Height * 2 + 4;

            dest.SetSurfaceSize((uint)w, (uint)h);

            Cairo.Context context = dest.Create();

            MakeReflection(context, source, w, h);

            //((IDisposable) context.Target).Dispose ();
            ((IDisposable)context).Dispose();
        }
Beispiel #3
0
        /// <summary>
        /// Draws the button into the texture
        /// </summary>
        /// <param name="actor">
        /// A <see cref="CairoTexture"/>
        /// </param>
        protected void Draw (CairoTexture actor)
        {
            double x = 0.5, y = 0.5;
            double r = (texture_height - x - y) / 2;

            Cairo.Context cr = actor.Create ();

            if ((Borders & Border.Right) == Border.Right)
                cr.Arc (-x+texture_width-r, y+r, r, -Math.PI/2, Math.PI/2);
            else {
                cr.MoveTo (x+r,y);
                cr.LineTo (-x+texture_width, y);
                cr.LineTo (-x+texture_width, y+2*r);
            }

            if ((Borders & Border.Left) == Border.Left)
                cr.Arc (x+r, y+r, r, Math.PI/2, -Math.PI/2);
            else {
                cr.LineTo (x, y+2*r);
                cr.LineTo (x, y);
            }

            cr.ClosePath ();

            cr.Color = Style.Background;
            cr.FillPreserve();

            cr.Color = Style.Border;
            cr.LineWidth = Style.BorderSize;
            cr.Stroke ();

            cr.Color = Style.Standard.Color;

            cr.SelectFontFace (Style.Standard.Family, Style.Standard.Slant, Style.Standard.Weight);
            cr.SetFontSize (Style.Standard.Size);

            TextExtents te = cr.TextExtents (Text);

            cr.MoveTo ((texture_width-te.Width)/2,2*r-texture_height/4);
            cr.FontOptions.HintStyle = HintStyle.Full;
            cr.ShowText (Text);

            ((IDisposable) cr.Target).Dispose ();
            ((IDisposable) cr).Dispose ();
        }
        protected virtual void SetupBackground()
        {
            background.Clear();
            Cairo.Context context = background.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            double margin = Margin;

            //left curvature:
            context.MoveTo(-hlwidth, -hlwidth);
            context.CurveTo(margin * 0.33, -hlwidth,
                            margin * 0.5, Height * 0.4,
                            margin * 0.5, Height * 0.5);
            context.CurveTo(margin * 0.5, Height * 0.6,
                            margin * 0.66, Height - hlwidth,
                            margin - hlwidth, Height - hlwidth);


            //straight bottom:
            context.LineTo(Width - margin - hlwidth, Height - hlwidth);

            //right curvature:
            context.CurveTo(Width - margin * 0.66, Height - hlwidth,
                            Width - margin * 0.5, Height * 0.6,
                            Width - margin * 0.5, Height * 0.5);
            context.CurveTo(Width - margin * 0.5, Height * 0.4,
                            Width - margin * 0.33, -hlwidth,
                            Width - hlwidth, -hlwidth);

            //straight top:
            context.LineTo(-hlwidth, -hlwidth);
            context.ClosePath();

            context.LineWidth = lwidth;
            context.SetSourceRGBA(1.0, 1.0, 1.0, 1.0);
            context.StrokePreserve();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.10);
            context.Fill();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Beispiel #5
0
        /// <summary>
        /// Generates the undlying texture
        /// </summary>
        protected override void GenerateTextures ()
        {
            double x = 5+0.5, y = 5+0.5;
            double r = (texture_width - x - y) / 2;

            CairoTexture actor = new CairoTexture (texture_width,texture_height);
            Cairo.Context context = actor.Create ();

            context.Arc (x+r, y+r, r, 0, 2*Math.PI);

            context.ClosePath ();

            context.Color = Style.Background;
            context.FillPreserve ();

            context.Color = Style.Border;
            context.LineWidth = Style.BorderSize;
            context.Stroke ();

            context.Color = Style.Foreground;

            context.MoveTo (x+5,texture_height /2);
            context.LineTo (texture_width-5-x, texture_height /2);
            context.LineWidth = 2.0;
            context.Stroke ();

            if (inward)
            {
                context.MoveTo (texture_width /2,y+5);
                context.LineTo (texture_width /2,texture_height-5-y);
                context.Stroke ();
            }

            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();

            textures.Add (actor);
        }
        public virtual void Update()
        {
            outline.Clear();
            Cairo.Context context = outline.Create();

            context.LineWidth = line_width;
            context.MoveTo(outline.Height * 0.5, 0.5);
            context.Arc(outline.Width - outline.Height * 0.5, outline.Height * 0.5, (outline.Height - line_width) * 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
            context.Arc(outline.Height * 0.5, outline.Height * 0.5, (outline.Height - line_width) * 0.5, 0.5 * Math.PI, 1.5 * Math.PI);
            context.ClosePath();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.2);
            context.FillPreserve();
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.Stroke();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();

            handle.Update();
            handle.RaiseTop();
            arrow_left.Update();
            arrow_right.Update();
        }
Beispiel #7
0
        /// <summary>
        /// Redraws the circle_prototype which is used for all circles as template.
        /// This means a new circle is drawn with cairo and stored in a texture.
        /// </summary>
        static private void UpdatePrototype (CairoTexture actor, double r, double g, double b, double a,
                                                   double arc, double a_r, double a_g, double a_b)
        {
            double size = (double)circle_size;

            actor.Clear();
            Cairo.Context context = actor.Create();


            Cairo.Gradient pattern = new Cairo.RadialGradient(size/2.0,size/2.0,size/3.0,
                                                            size/2.0,size/2.0,size/2.0);

            pattern.AddColorStop(0,new Cairo.Color (r,g,b,a));
            pattern.AddColorStop(1.0,new Cairo.Color (r,g,b,0.1));

            context.LineWidth = (double)size/5.0;
            context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,0,2*Math.PI);

            context.Save();

            context.Pattern = pattern;
            context.Fill();

            if (arc != 0) {

                context.LineWidth = (double)size/10.0;
                context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,-Math.PI/2.0,2*Math.PI*arc/100.0-Math.PI/2.0);

                Hyena.Log.Debug ("Arc prototype "+ arc);
                context.Color = new Cairo.Color (a_r,a_g,a_b,0.5);
                context.Stroke ();
            }
            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();
        }
Beispiel #8
0
        public void DrawSpinner (CairoTexture tex, int count)
        {
            Cairo.Context cr = tex.Create ();

            cr.Translate (height /2, height /2);
            cr.LineWidth = 3;

            for (int i = 0; i < 8; i ++) {
                cr.Color = new Cairo.Color (1,1,1,1-(double)((count+i)%8)/7);

                cr.MoveTo (0, -height/2.5+3);
                cr.LineTo (0, -height/2.5);
                cr.Rotate (-Math.PI / 4);
                cr.Stroke ();
            }

            ((IDisposable) cr.Target).Dispose ();
            ((IDisposable) cr).Dispose ();
        }