Пример #1
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		LinearGradient pat;		
		
		pat = new LinearGradient (0.0, 0.0,  0.0, 1.0);
		pat.AddColorStop (1, new Color (0, 0, 0, 1) );
		pat.AddColorStop (0, new Color (1, 1, 1, 1) );
		gr.Rectangle ( new PointD (0, 0),
			       1, 1
			       );
		
		gr.Pattern =  pat;
		gr.Fill ();
		pat.Destroy ();

		RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
				     0.4,  0.4, 0.5);
		
		pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
		pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
		gr.Pattern =  pat2;
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Fill ();
		pat2.Destroy ();
	}
		public override void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
		{
			Cairo.Color selection_color = color;
			Cairo.Color selection_highlight = CairoExtensions.ColorShade (selection_color, 1.24);
			Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
			selection_highlight.A = 0.5;
			selection_stroke.A = color.A;
			
			if (filled) {
				Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.12);
				Cairo.Color selection_fill_dark = selection_color;
				
				selection_fill_light.A = color.A;
				selection_fill_dark.A = color.A;
				
				LinearGradient grad = new LinearGradient (x, y, x, y + height);
				grad.AddColorStop (0, selection_fill_light);
				grad.AddColorStop (0.4, selection_fill_dark);
				grad.AddColorStop (1, selection_fill_light);
				
				cr.Pattern = grad;
				CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
				cr.Fill ();
				grad.Destroy ();
			}
			
			if (filled && stroked) {
				cr.LineWidth = 1.0;
				cr.Color = selection_highlight;
				CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3, Context.Radius - 1, corners, true);
				cr.Stroke ();
			}
			
			if (stroked) {
				cr.LineWidth = 1.0;
				cr.Color = selection_stroke;
				CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true);
				cr.Stroke ();
			}
		}
Пример #3
0
 private void RenderGoo (Context cr)
 {
     double max_r = Height / 2;
     double x_ofs = Width / RenderPoints.Length;
     double xc = 0, yc = Height;
     double r;
     
     double min_x = Width, max_x = 0, min_y = Height, max_y = yc;
     
     for (int i = 0, n = RenderPoints.Length; i < n; i++) {
         xc += x_ofs;
         r = Height * RenderPoints[i];
         cr.MoveTo (xc, yc);
         cr.Arc (xc, yc, r, 0, 2 * Math.PI);
         
         if (r > 0) {
             min_x = Math.Min (min_x, xc - r);
             max_x = Math.Max (max_x, xc + r);
             min_y = Math.Min (min_y, yc - r);
         }
     }
     
     render_damage = new Gdk.Rectangle (
         (int)Math.Floor (min_x),
         (int)Math.Floor (min_y),
         (int)Math.Ceiling (max_x - min_x),
         (int)Math.Ceiling (max_y - min_y)
     );
     
     cr.ClosePath ();
     
     var grad = new LinearGradient (0, 0, 0, Height);
     
     Color c = Color;
     c.A = 0;
     grad.AddColorStop (0, c);
     
     c.A = RenderLoudness / 2;
     grad.AddColorStop (1, c);
     
     cr.Pattern = grad;
     cr.Fill ();
     
     grad.Destroy ();
 }
Пример #4
0
        public static void RenderThumbnail (Cairo.Context cr, ImageSurface image, bool dispose,
            double x, double y, double width, double height, bool drawBorder, double radius,
            bool fill, Color fillColor, CairoCorners corners)
        {
            if (image == null || image.Handle == IntPtr.Zero) {
                image = null;
            }

            double p_x = x;
            double p_y = y;

            if (image != null) {
                p_x += image.Width < width ? (width - image.Width) / 2 : 0;
                p_y += image.Height < height ? (height - image.Height) / 2 : 0;
            }

            cr.Antialias = Cairo.Antialias.Default;

            if (image != null) {
                if (fill) {
                    CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
                    cr.Color = fillColor;
                    cr.Fill ();
                }

                CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
                cr.SetSource (image, p_x, p_y);
                cr.Fill ();
            } else {
                CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);

                if (fill) {
                    var grad = new LinearGradient (x, y, x, y + height);
                    grad.AddColorStop (0, fillColor);
                    grad.AddColorStop (1, CairoExtensions.ColorShade (fillColor, 1.3));
                    cr.Pattern = grad;
                    cr.Fill ();
                    grad.Destroy ();
                }

                Banshee.CairoGlyphs.BansheeLineLogo.Render (cr,
                    new Rectangle (x + 15, y + 15, width - 30, height - 30),
                    CairoExtensions.RgbaToColor (0x00000044),
                    CairoExtensions.RgbaToColor (0x00000055));
            }

            if (!drawBorder) {
                if (dispose && image != null) {
                    ((IDisposable)image).Dispose ();
                }

                return;
            }

            cr.LineWidth = 1.0;
            if (radius < 1) {
                cr.Antialias = Antialias.None;

                CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3, radius, corners);
                cr.Color = cover_border_light_color;
                cr.Stroke ();
            }

            CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius, corners);
            cr.Color = cover_border_dark_color;
            cr.Stroke ();

            if (dispose && image != null) {
                ((IDisposable)image).Dispose ();
            }
        }
Пример #5
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!CairoHelper.ShouldDrawWindow (cr, Window)) {
                return base.OnDrawn (cr);
            }

            if (reflect) {
                CairoExtensions.PushGroup (cr);
            }

            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 ();

            Pattern bar = RenderBar (Allocation.Width - 2 * h_padding, bar_height);

            cr.Save ();
            cr.Source = 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.Pattern = bar;

                LinearGradient 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);
                mask.Destroy ();

                cr.Restore ();

                CairoExtensions.PopGroupToSource (cr);
                cr.Paint ();
            }

            if (show_labels) {
                cr.Translate ((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2,
                     bar_height + bar_label_spacing);
                RenderLabels (cr);
            }

            bar.Destroy ();

            return true;
        }
Пример #6
0
        public override void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
        {
            Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
            Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (1, dark_color);

            cr.Pattern = grad;
            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill ();
            grad.Destroy ();
        }
Пример #7
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 ();
        }
Пример #8
0
		void PaintProgressSurface (DockySurface surface)
		{
			if (Progress <= 0)
				return;
			
			double padding = 2.0;
			double width = surface.Width - 2 * padding;
			double height = Math.Min (26.0, 0.18 * surface.Height);
			double x = padding;
			double y = surface.Height - height - padding;
			
			double lineSize = 1.0;
			surface.Context.LineWidth = lineSize;
			
			// draw the outer stroke
			x += lineSize / 2.0;
			y += lineSize / 2.0;
			width -= lineSize;
			height -= lineSize;
			
			LinearGradient outer_stroke = new LinearGradient (0, y, 0, y + height);
			outer_stroke.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.3));
			outer_stroke.AddColorStop (1, new Cairo.Color (1, 1, 1, 0.3));
			
			DrawRoundedLine (surface, x, y, width, height, true, true, outer_stroke, null);
			outer_stroke.Destroy ();
			
			// draw the finished stroke/fill
			x += lineSize;
			y += lineSize;
			width -= 2 * lineSize;
			height -= 2 * lineSize;
			double finishedWidth = Progress * width - lineSize / 2.0;
			
			LinearGradient finished_stroke = new LinearGradient (0, y, 0, y + height);
			finished_stroke.AddColorStop (0, new Cairo.Color (67 / 255.0, 165 / 255.0, 226 / 255.0, 1));
			finished_stroke.AddColorStop (1, new Cairo.Color (32 / 255.0, 94 / 255.0, 136 / 255.0, 1));
			LinearGradient finished_fill = new LinearGradient (0, y, 0, y + height);
			finished_fill.AddColorStop (0, new Cairo.Color (91 / 255.0, 174 / 255.0, 226 / 255.0, 1));
			finished_fill.AddColorStop (1, new Cairo.Color (35 / 255.0, 115 / 255.0, 164 / 255.0, 1));
			
			DrawRoundedLine (surface, x, y, finishedWidth, height, true, false, finished_stroke, finished_fill);
			finished_stroke.Destroy ();
			finished_fill.Destroy ();
			
			// draw the remaining stroke/fill
			LinearGradient remaining_stroke = new LinearGradient (0, y, 0, y + height);
			remaining_stroke.AddColorStop (0, new Cairo.Color (82 / 255.0, 82 / 255.0, 82 / 255.0, 1));
			remaining_stroke.AddColorStop (1, new Cairo.Color (148 / 255.0, 148 / 255.0, 148 / 255.0, 1));
			LinearGradient remaining_fill = new LinearGradient (0, y, 0, y + height);
			remaining_fill.AddColorStop (0, new Cairo.Color (106 / 255.0, 106 / 255.0, 106 / 255.0, 1));
			remaining_fill.AddColorStop (1, new Cairo.Color (159 / 255.0, 159 / 255.0, 159 / 255.0, 1));
			
			DrawRoundedLine (surface, x + finishedWidth + lineSize, y, width - finishedWidth, height, false, true, remaining_stroke, remaining_fill);
			remaining_stroke.Destroy ();
			remaining_fill.Destroy ();
			
			// draw the highlight on the finished part
			x += lineSize;
			y += lineSize;
			width -= lineSize;
			height -= 2 * lineSize;
			
			LinearGradient finished_highlight = new LinearGradient (0, y, 0, y + height);
			finished_highlight.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.3));
			finished_highlight.AddColorStop (0.2, new Cairo.Color (1, 1, 1, 0));
			
			DrawRoundedLine (surface, x, y, finishedWidth, height, true, false, finished_highlight, null);
			finished_highlight.Destroy ();
		}
Пример #9
0
        internal void DrawApplicationMenu(Context cr, Rectangle r, Gdk.Rectangle itemsAlloc, double lineWidth, ApplicationMenu w)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = lineWidth * 1.5;
            Gdk.Rectangle alloc = w.Allocation;

            cr.Color = new Color (0.4, 0.4, 0.4);
            cr.Paint ();

            cr.Rectangle (itemsAlloc.X, itemsAlloc.Y, itemsAlloc.Width, itemsAlloc.Height);
            cr.Color = new Color (0.9216, 0.9216, 0.9216);
            cr.Fill ();

            cr.LineWidth = lineWidth;

            cr.MoveTo (itemsAlloc.Right - lineWidth05, itemsAlloc.Top);
            cr.LineTo (itemsAlloc.Right - lineWidth05, itemsAlloc.Bottom);
            cr.Color = new Color (1, 1, 1, 0.2);
            cr.Stroke ();

            cr.MoveTo (itemsAlloc.Right - lineWidth15, itemsAlloc.Top);
            cr.LineTo (itemsAlloc.Right - lineWidth15, itemsAlloc.Bottom);
            cr.Color = new Color (0, 0, 0, 0.2);
            cr.Stroke ();

            cr.Rectangle (alloc.X, alloc.Y, alloc.Width, itemsAlloc.Y - alloc.Y);
            LinearGradient linGrad = new LinearGradient (0, alloc.Y, 0, itemsAlloc.Y - alloc.Y);
            linGrad.AddColorStop (0.0, new Color (0.4, 0.4, 0.4));
            linGrad.AddColorStop (0.3, new Color (0.2, 0.2, 0.2));
            linGrad.AddColorStop (0.3, new Color (0, 0, 0));
            linGrad.AddColorStop (1.0, new Color (0.4, 0.4, 0.4));
            cr.Pattern = linGrad;
            cr.Fill ();
            linGrad.Destroy ();

            cr.Rectangle (alloc.X, itemsAlloc.Bottom, alloc.Width, alloc.Bottom - itemsAlloc.Bottom);
            linGrad = new LinearGradient (0, itemsAlloc.Bottom, 0, alloc.Bottom);
            linGrad.AddColorStop (0.0, new Color (0.4, 0.4, 0.4));
            linGrad.AddColorStop (0.3, new Color (0.2, 0.2, 0.2));
            linGrad.AddColorStop (0.3, new Color (0, 0, 0));
            linGrad.AddColorStop (1.0, new Color (0.4, 0.4, 0.4));
            cr.Pattern = linGrad;
            cr.Fill ();
            linGrad.Destroy ();

            Gdk.Rectangle appBtnAlloc = w.ApplicationButton.Allocation;
            appBtnAlloc.X = alloc.X;
            appBtnAlloc.Y = itemsAlloc.Y - 2 - appBtnAlloc.Height;
            DrawApplicationButton (cr, appBtnAlloc, ButtonState.Pressed, 1.0, w.ApplicationButton);
        }
Пример #10
0
        /// <summary>Draws a tile.</summary>
        public void DrawTile(Context cr, Rectangle bodyAllocation, Rectangle contentAllocation, Tile widget)
        {
            if(widget.Selected)
            {
                LinearGradient grad = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
                grad.AddColorStop (0.00, new Color (0.9922, 0.7373, 0.4353));
                grad.AddColorStop (0.27, new Color (0.9961, 0.8039, 0.5569));
                grad.AddColorStop (0.33, new Color (0.9961, 0.7255, 0.4078));
                grad.AddColorStop (1.00, new Color (0.9843, 0.8980, 0.6313));
                cr.Pattern = grad;
                cr.Rectangle (bodyAllocation);
                cr.Fill ();
                grad.Destroy ();
            }

            cr.Color = new Color (1, 1, 1);
            cr.Rectangle (contentAllocation);
            cr.Fill ();
        }
Пример #11
0
        /// <summary>Draws an application button.</summary>
        public void DrawApplicationButton(Context cr, Gdk.Rectangle bodyAllocation, ButtonState state, double lineWidth, BaseButton widget)
        {
            const double dropShadowOffset = 1;
            double radius = (bodyAllocation.Height - dropShadowOffset) / 2;

            double x = bodyAllocation.X + radius + dropShadowOffset;
            double y = bodyAllocation.Y + radius + dropShadowOffset;
            cr.Arc (x, y, radius, 0, 2 * Math.PI);
            cr.Color = new Color (0, 0, 0, 0.5);
            cr.Fill ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
            switch(state)
            {
            case ButtonState.Hover:
                cr.Color = new Color (0.9, 0.815, 0.533);
                break;
            case ButtonState.Pressed:
                cr.Color = new Color (0.886, 0.639, 0.356);
                break;
            default:
                cr.Color = new Color (0.8, 0.8, 0.8);
                break;
            }
            cr.Fill ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
            LinearGradient linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height);
            linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.9));
            linGrad.AddColorStop (0.5, new Color (1, 1, 1, 0.0));
            linGrad.AddColorStop (1.0, new Color (1, 1, 1, 1.0));
            cr.Pattern = linGrad;
            cr.Fill ();
            linGrad.Destroy ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
            linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height);
            linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
            linGrad.AddColorStop (0.4, new Color (0, 0, 0, 0.0));
            linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.1));
            linGrad.AddColorStop (0.75, new Color (0, 0, 0, 0.0));
            linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.0));
            cr.Pattern = linGrad;
            cr.Fill ();
            linGrad.Destroy ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, Math.PI);
            linGrad = new LinearGradient (0, bodyAllocation.Y + radius, 0, bodyAllocation.Y + bodyAllocation.Height);
            linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
            linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.5));
            cr.Pattern = linGrad;
            cr.LineWidth = 1.0;
            cr.Stroke ();
            linGrad.Destroy ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, Math.PI, 0);
            linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + radius);
            linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5));
            linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.0));
            cr.LineWidth = 1.0;
            cr.Stroke ();
            linGrad.Destroy ();

            cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
            RadialGradient radGrad = new RadialGradient (bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0, bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0.5 * radius);
            radGrad.AddColorStop (0, new Color (1, 1, 1, 0.4));
            radGrad.AddColorStop (1, new Color (1, 1, 1, 0.0));
            cr.Pattern = radGrad;
            cr.Fill ();
            radGrad.Destroy ();
        }
Пример #12
0
        /// <summary>Draws a ribbon.</summary>
        public void DrawRibbon(Context cr, Gdk.Rectangle menuBarAllocation, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = 3 * lineWidth05;
            double x0, x1, y0, y1;
            LinearGradient linGrad;

            if(menuBarAllocation.Height > 0)
            {
                cr.Rectangle (menuBarAllocation.X, menuBarAllocation.Y, menuBarAllocation.Width, menuBarAllocation.Height - 1);
                linGrad = new LinearGradient (0, menuBarAllocation.Y, 0, menuBarAllocation.Y + menuBarAllocation.Height - 1);
                linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.2));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.0));
                linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.5));
                cr.Pattern = linGrad;
                cr.Fill ();
                linGrad.Destroy ();

                cr.MoveTo (menuBarAllocation.X, menuBarAllocation.Bottom + 0.5);
                cr.LineTo (menuBarAllocation.Right, menuBarAllocation.Bottom + 0.5);
                cr.Color = new Color (1, 1, 1, 0.5);
                cr.LineWidth = 1;
                cr.Stroke ();

                // Quick Access Toolbar background

                Gdk.Rectangle alloc = widget.QuickAccessToolbar.Allocation;
                x0 = alloc.X;
                x1 = alloc.Right - 1;
                y0 = alloc.Y;
                y1 = alloc.Bottom - 1;
                double radius = (y1 - y0) / 2;

                cr.LineWidth = 1;

                if(widget.ApplicationButton != null)
                {
                    Gdk.Rectangle alloc2 = widget.ApplicationButton.Allocation;
                    double cx = alloc2.X + alloc2.Width / 2;
                    double cy = alloc2.Y + alloc2.Height / 2;
                    double radius2 = x0 - cx;
                    double alpha = Math.Asin ((y0 - cy) / radius2);
                    double beta = Math.Asin ((y1 - cy) / radius2);
                    double curveWidth0 = Math.Cos (Math.Abs (alpha)) * radius2;
                    double curveWidth1 = Math.Cos (Math.Abs (beta)) * radius2;
                    double curveWidth = Math.Min (curveWidth0, curveWidth1);

                    cr.Save ();
                    cr.Rectangle (cx + curveWidth, y0, x1 - cx - curveWidth, alloc.Height);
                    cr.ClipPreserve ();
                    cr.ArcNegative (cx, cy, radius2, -alpha, -beta);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
                    //cr.Color = new Color (1, 0, 0);
                    cr.Fill ();
                    cr.Restore ();
                    cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();

                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();
                    radius2 -= 1;
                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 - 0.5);
                    cr.LineTo (x1, y0 - 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 + 0.5);
                    cr.LineTo (x1, y0 + 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 - 0.5);
                    cr.LineTo (x1, y1 - 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 + 0.5);
                    cr.LineTo (x1, y1 + 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();
                }
                else
                {
                    cr.Rectangle (x0, y0, x1 - x0, alloc.Height);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
                    cr.Fill ();

                    cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();

                    cr.MoveTo (x0 + 0.5, y0);
                    cr.LineTo (x0 + 0.5, y1);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (x0 + 1.5, y0);
                    cr.LineTo (x0 + 1.5, y1);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();
                }

                cr.Arc (x1, y0 + radius, radius + 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                cr.Color = new Color (1, 1, 1, 0.4);
                cr.Stroke ();

                cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                cr.Color = new Color (0, 0, 0, 0.6);
                cr.Stroke ();
            }

            Ribbon.RibbonPage p = widget.CurrentPage;
            if(p != null)
            {
                //Color c = ColorScheme.GetColor(colorScheme.Bright, 0.92);
                Color c = colorScheme.Normal;

                if(bodyAllocation.Height > 0)
                {
                    /*** PAGE ***/

                    x0 = bodyAllocation.X; x1 = bodyAllocation.X + bodyAllocation.Width;
                    y0 = bodyAllocation.Y; y1 = bodyAllocation.Y + bodyAllocation.Height;

                    cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth05, Math.PI/2, Math.PI);
                    cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                    cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
                    cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth05, 0, Math.PI/2);
                    cr.LineTo (x0 + roundSize, y1 - lineWidth05);

                    /*** BACKGOUND ***/
                    cr.Color = c;
                    cr.FillPreserve ();

                    /*** DARK BORDER ***/
                    cr.LineWidth = lineWidth;
                    cr.Color = ColorScheme.GetColorAbsolute (colorScheme.Normal, 0.75);
                    cr.Stroke ();

                    /*** GLASS EFFECT ***/
                    double ymid = Math.Round (y0 + (y1 - y0) * 0.25);

                    cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth, Math.PI, 3*Math.PI/2);
                    cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth, 3*Math.PI/2, 0);
                    cr.LineTo (x1 - lineWidth, ymid);
                    cr.LineTo (x0 + lineWidth, ymid);
                    cr.LineTo (x0 + lineWidth, y0 + roundSize);
                    linGrad = new LinearGradient (0, y0, 0, ymid);
                    linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
                    linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.075));
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();

                    cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth, Math.PI/2, Math.PI);
                    cr.LineTo (x0 + lineWidth, ymid);
                    cr.LineTo (x1 - lineWidth, ymid);
                    cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth, 0, Math.PI/2);
                    cr.LineTo (x0 + roundSize, y1 - lineWidth);
                    linGrad = new LinearGradient (0, ymid, 0, y1);
                    linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.1));
                    linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.0));
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();
                }

                /*** TAB ***/

                Gdk.Rectangle r = p.LabelAllocation;

                x0 = r.X; x1 = r.X + r.Width;
                y0 = r.Y; y1 = r.Y + r.Height + lineWidth;

                /*** TAB :: BACKGROUND ***/

                cr.MoveTo (x0 + lineWidth05, y1);
                cr.LineTo (x0 + lineWidth05, y0 + roundSize);
                cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
                cr.LineTo (x1 - lineWidth05, y1);

                linGrad = new LinearGradient (0, y0, 0, y1);
                linGrad.AddColorStop (0.0, colorScheme.PrettyBright);
                linGrad.AddColorStop (1.0, c);
                cr.Pattern = linGrad;
                cr.Fill ();
                linGrad.Destroy ();

                /*** TAB :: DARK BORDER ***/

                cr.MoveTo (x0 + lineWidth05, y1);
                cr.LineTo (x0 + lineWidth05, y0 + roundSize);
                cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
                cr.LineTo (x1 - lineWidth05, y1);

                cr.LineWidth = lineWidth;
                cr.Color = ColorScheme.GetColorRelative (colorScheme.Bright, -0.1);
                cr.Stroke ();

                y1 -= 1.0;

                /*** TAB :: HIGHLIGHT ***/

                cr.MoveTo (x0 + lineWidth15, y1);
                cr.LineTo (x0 + lineWidth15, y0 + roundSize);
                cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth15, 3*Math.PI/2, 0);
                cr.LineTo (x1 - lineWidth15, y1);

                cr.LineWidth = lineWidth;
                linGrad = new LinearGradient (0, y0+lineWidth, 0, y1);
                linGrad.AddColorStop (0.0, colorScheme.PrettyBright);
                linGrad.AddColorStop (1.0, ColorScheme.SetAlphaChannel (colorScheme.Bright, 0));
                cr.Pattern = linGrad;
                cr.Stroke ();
                linGrad.Destroy ();

                /*** TAB :: SHADOW ***/

                cr.MoveTo (x0 - lineWidth05, y1);
                cr.LineTo (x0 - lineWidth05, y0 + roundSize);
                cr.Arc (x0 + roundSize, y0 + roundSize, roundSize + lineWidth05, Math.PI, 3*Math.PI/2);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize + lineWidth05, 3*Math.PI/2, 0);
                cr.LineTo (x1 + lineWidth05, y1);

                cr.LineWidth = lineWidth;
                cr.Color = new Color (0, 0, 0, 0.2);
                cr.Stroke ();
            }
        }
Пример #13
0
        /// <summary>Draws a button.</summary>
        public void DrawButton(Context cr, Rectangle bodyAllocation, ButtonState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, BaseButton widget)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = lineWidth05 * 3;

            bool upLeft = true, upRight = true, downRight = true, downLeft = true;
            switch(widget.GroupStyle)
            {
                case GroupStyle.Left:
                    upRight = downRight = false;
                    break;
                case GroupStyle.Center:
                    upLeft = downLeft = upRight = downRight = false;
                    break;
                case GroupStyle.Right:
                    upLeft = downLeft = false;
                    break;
            }

            cr.LineWidth = lineWidth;

            if(state == ButtonState.Pressed || state == ButtonState.Hover)
            {
                LinearGradient bodyPattern, innerBorderPattern;
                Color borderColor;

                if(state == ButtonState.Pressed)
                {
                    bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
                    bodyPattern.AddColorStopRgb (0.0, new Color (0.996, 0.847, 0.667));
                    bodyPattern.AddColorStopRgb (0.37, new Color (0.984, 0.710, 0.396));
                    bodyPattern.AddColorStopRgb (0.43, new Color (0.980, 0.616, 0.204));
                    bodyPattern.AddColorStopRgb (1.0, new Color (0.992, 0.933, 0.667));

                    innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height);
                    innerBorderPattern.AddColorStop (0.0, new Color (0.876, 0.718, 0.533, 1));
                    innerBorderPattern.AddColorStop (1.0, new Color (0.876, 0.718, 0.533, 0));

                    borderColor = new Color (0.671, 0.631, 0.549);
                }
                else
                {
                    bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
                    bodyPattern.AddColorStopRgb (0.0, new Color (1, 0.996, 0.890));
                    bodyPattern.AddColorStopRgb (0.37, new Color (1, 0.906, 0.592));
                    bodyPattern.AddColorStopRgb (0.43, new Color (1, 0.843, 0.314));
                    bodyPattern.AddColorStopRgb (1.0, new Color (1, 0.906, 0.588));

                    innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height);
                    innerBorderPattern.AddColorStop (0.0, new Color (1, 1, 0.969, 1));
                    innerBorderPattern.AddColorStop (1.0, new Color (1, 1, 0.969, 0));

                    borderColor = new Color (0.824, 0.753, 0.553);
                }

                double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05;
                double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;

                if(upLeft) cr.MoveTo (x0 + roundSize, y0);
                else cr.MoveTo (x0, y0);
                if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                else cr.LineTo (x1, y0);
                if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                else cr.LineTo (x1, y1);
                if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                else cr.LineTo (x0, y1);
                if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                else cr.LineTo (x0, y0);

                cr.Pattern = bodyPattern;
                cr.Fill ();
                bodyPattern.Destroy ();

                x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15;
                x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15;

                double roundSizeMinusLineWidth = roundSize - lineWidth;

                if(widget.GroupStyle != GroupStyle.Left) x0 -= lineWidth;

                if(upLeft) cr.MoveTo (x0 + roundSizeMinusLineWidth, y0);
                else cr.MoveTo (x0, y0);
                if(upRight) cr.Arc (x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5*Math.PI, 0);
                else cr.LineTo (x1, y0);
                if(downRight) cr.Arc (x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5*Math.PI);
                else cr.LineTo (x1, y1);
                if(downLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5*Math.PI, Math.PI);
                else cr.LineTo (x0, y1);
                if(upLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5*Math.PI);
                else cr.LineTo (x0, y0);

                if(widget.GroupStyle != GroupStyle.Left) x0 += lineWidth;

                cr.Pattern = innerBorderPattern;
                cr.Stroke ();
                innerBorderPattern.Destroy ();

                x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05;
                x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;

                if(upLeft) cr.MoveTo (x0 + roundSize, y0);
                else cr.MoveTo (x0, y0);
                if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                else cr.LineTo (x1, y0);
                if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                else cr.LineTo (x1, y1);
                if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                else cr.LineTo (x0, y1);
                if(widget.GroupStyle == GroupStyle.Left)
                {
                    if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                    else cr.LineTo (x0, y0);
                }

                cr.Color = borderColor;
                cr.Stroke ();
            }
            else if(widget.DrawBackground)
            {
                LinearGradient bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
                if(widget.OpaqueBackground)
                {
                    bodyPattern.AddColorStop (0.0, new Color (0.9, 0.9, 0.9));
                    bodyPattern.AddColorStop (0.37, new Color (0.6, 0.6, 0.6));
                    bodyPattern.AddColorStop (0.43, new Color (0.6, 0.6, 0.6));
                    bodyPattern.AddColorStop (1.0, new Color (0.9, 0.9, 0.9));

                }
                else
                {
                    bodyPattern.AddColorStop (0.0, new Color (1, 1, 1, 0.7));
                    bodyPattern.AddColorStop (0.37, new Color (1, 1, 1, 0.2));
                    bodyPattern.AddColorStop (0.43, new Color (1, 1, 1, 0.2));
                    bodyPattern.AddColorStop (1.0, new Color (1, 1, 1, 0.7));
                }

                double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05;
                double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;

                if(upLeft) cr.MoveTo (x0 + roundSize, y0);
                else cr.MoveTo (x0, y0);
                if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                else cr.LineTo (x1, y0);
                if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                else cr.LineTo (x1, y1);
                if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                else cr.LineTo (x0, y1);
                if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                else cr.LineTo (x0, y0);

                cr.Pattern = bodyPattern;
                cr.Fill ();
                bodyPattern.Destroy ();

                if(widget.GroupStyle != GroupStyle.Left)
                {
                    if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                    else cr.MoveTo (x0, y1);
                    if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                    else cr.LineTo (x0, y0);

                    cr.Color = new Color (1, 1, 1, 0.5);
                    cr.Stroke ();
                }

                if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                else cr.MoveTo (x0, y0);
                if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                else cr.LineTo (x1, y0);
                if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                else cr.LineTo (x1, y1);
                if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                else cr.LineTo (x0, y1);
                if(widget.GroupStyle == GroupStyle.Left)
                {
                    if(upLeft) cr.LineTo (x0, y0 + roundSize);
                    else cr.LineTo (x0, y0);
                }

                cr.Color = new Color (0, 0, 0, 0.2);
                cr.Stroke ();
            }

            if(arrowSize > 0)
            {
                double x, y;

                switch(widget.ImagePosition)
                {
                    case Gtk.PositionType.Bottom:
                    case Gtk.PositionType.Top:
                        x = bodyAllocation.X + (bodyAllocation.Width - arrowSize) / 2.0;
                        y = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth - arrowSize - 2 * arrowPadding;

                        if(drawSeparator)
                        {
                            double left = bodyAllocation.X + 2 * lineWidth, right = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth;

                            cr.MoveTo (left, y - lineWidth / 2);
                            cr.LineTo (right, y - lineWidth / 2);
                            cr.Color = new Color (0, 0, 0, 0.1);
                            cr.Stroke ();

                            cr.MoveTo (left, y + lineWidth / 2);
                            cr.LineTo (right, y + lineWidth / 2);
                            cr.Color = new Color (1, 1, 1, 0.6);
                            cr.Stroke ();
                        }

                        y += arrowPadding;
                        break;
                    default:
                        x = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth - arrowSize - 2 * arrowPadding;
                        y = bodyAllocation.Y + (bodyAllocation.Height - arrowSize) / 2.0;

                        if(drawSeparator)
                        {
                            double top = bodyAllocation.Y + 2 * lineWidth, bottom = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth;
                            cr.MoveTo (x - lineWidth / 2, top);
                            cr.LineTo (x - lineWidth / 2, bottom);
                            cr.Color = new Color (0, 0, 0, 0.1);
                            cr.Stroke ();

                            cr.MoveTo (x + lineWidth / 2, top);
                            cr.LineTo (x + lineWidth / 2, bottom);
                            cr.Color = new Color (1, 1, 1, 0.6);
                            cr.Stroke ();
                        }

                        x += arrowPadding;
                        break;
                }

                y += arrowSize / 4.0 + lineWidth / 2.0;
                cr.MoveTo (x, y);
                cr.LineTo (x + arrowSize, y);
                cr.LineTo (x + arrowSize / 2.0, y + arrowSize / 2.0);
                cr.LineTo (x, y);
                cr.Color = new Color (0, 0, 0);
                cr.Fill ();
            }
        }
Пример #14
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 ();
        }
		protected override void PaintIconSurface (DockySurface surface)
		{
			if (DeskGrid == null)
				return;
			
			int cols = DeskGrid.GetLength (0);
			int rows = DeskGrid.GetLength (1);
			
			Gdk.Color gdkColor = Style.Backgrounds [(int) Gtk.StateType.Selected];
			Cairo.Color selection_color = new Cairo.Color ((double) gdkColor.Red / ushort.MaxValue,
											(double) gdkColor.Green / ushort.MaxValue,
											(double) gdkColor.Blue / ushort.MaxValue,
											0.5);
			Context cr = surface.Context;

			cr.AlphaPaint ();
			
			LinearGradient lg = new LinearGradient (0, 0, 0, surface.Height);
			lg.AddColorStop (0, new Cairo.Color (.35, .35, .35, .6));
			lg.AddColorStop (1, new Cairo.Color (.05, .05, .05, .7));
			
			for (int x = 0; x < cols; x++) {
				for (int y = 0; y < rows; y++) {
					if (DeskGrid[x,y] != null) {
						Cairo.Rectangle area = DeskAreaOnIcon (surface.Width, surface.Height, x, y);
						cr.Rectangle (area.X, area.Y, area.Width, area.Height);
						cr.Pattern = lg;
						cr.FillPreserve ();
						if (DeskGrid[x,y].IsActive) {
							cr.Color = selection_color;
							cr.Fill ();
							if (area.Width >= 16 && area.Height >= 16) {
								using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon ("desktop", (int) area.Width, (int) area.Height)) {
									Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (int) area.X + (area.Width - pbuf.Width) / 2, (int) area.Y + (area.Height - pbuf.Height) / 2);
									cr.Paint ();
								}
							}
						}
						cr.NewPath ();
					}
				}
			}
			
			lg.Destroy ();
			
			for (int x = 0; x < cols; x++) {
				for (int y = 0; y < rows; y++) {
					if (DeskGrid[x,y] != null) {
						Cairo.Rectangle area = DeskAreaOnIcon (surface.Width, surface.Height, x, y);
						cr.Rectangle (area.X, area.Y, area.Width, area.Height);
					}
				}
			}
			
			lg = new LinearGradient (0, 0, 0, surface.Height);
			lg.AddColorStop (0, new Cairo.Color (.95, .95, .95, .7));
			lg.AddColorStop (1, new Cairo.Color (.5, .5, .5, .7));
			cr.Pattern = lg;
			cr.StrokePreserve ();
			lg.Destroy ();
		}
Пример #16
0
        internal void DrawApplicationMenuItem(Context cr, Rectangle bodyAllocation, MenuItemState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, ApplicationMenuItem widget)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = lineWidth05 * 3;
            double separatorX = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth - arrowSize - 2 * arrowPadding;

            cr.LineWidth = lineWidth;

            if(state != MenuItemState.Default)
            {
                LinearGradient bodyPattern, innerBorderPattern;
                Color borderColor;

                bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
                bodyPattern.AddColorStopRgb (0.0, new Color (1, 0.996, 0.890));
                bodyPattern.AddColorStopRgb (0.37, new Color (1, 0.906, 0.592));
                bodyPattern.AddColorStopRgb (0.43, new Color (1, 0.843, 0.314));
                bodyPattern.AddColorStopRgb (1.0, new Color (1, 0.906, 0.588));

                innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height);
                innerBorderPattern.AddColorStop (0.0, new Color (1, 1, 0.969, 1));
                innerBorderPattern.AddColorStop (1.0, new Color (1, 1, 0.969, 0));

                borderColor = new Color (0.824, 0.753, 0.553);

                double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05;
                double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;

                cr.MoveTo (x0 + roundSize, y0);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);

                cr.Pattern = bodyPattern;
                cr.Fill ();
                bodyPattern.Destroy ();

                if(state == MenuItemState.HilightAction)
                {
                    cr.Color = new Color (1, 1, 1, 0.7);
                    cr.MoveTo (x0 + roundSize, y0);
                    cr.LineTo (separatorX, y0);
                    cr.LineTo (separatorX, y1);
                    cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
                    cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
                    cr.Fill ();
                }
                else if(state == MenuItemState.HilightMenu)
                {
                    cr.Color = new Color (1, 1, 1, 0.7);
                    cr.MoveTo (separatorX, y0);
                    cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                    cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                    cr.LineTo (separatorX, y1);
                    cr.LineTo (separatorX, y0);
                    cr.Fill ();
                }

                x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15;
                x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15;

                double roundSizeMinusLineWidth = roundSize - lineWidth;

                x0 -= lineWidth;

                cr.MoveTo (x0 + roundSizeMinusLineWidth, y0);
                cr.Arc (x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5*Math.PI, 0);
                cr.Arc (x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5*Math.PI);
                cr.Arc (x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5*Math.PI, Math.PI);
                cr.Arc (x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5*Math.PI);

                x0 += lineWidth;

                cr.Pattern = innerBorderPattern;
                cr.Stroke ();
                innerBorderPattern.Destroy ();

                x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05;
                x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;

                cr.MoveTo (x0 + roundSize, y0);
                cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
                cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
                cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);

                cr.Color = borderColor;
                cr.Stroke ();
            }

            if(arrowSize > 0)
            {
                double x, y;

                x = separatorX;
                y = bodyAllocation.Y + (bodyAllocation.Height - arrowSize) / 2.0;

                if(drawSeparator)
                {
                    double top = bodyAllocation.Y + 2 * lineWidth, bottom = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth;
                    cr.MoveTo (x - lineWidth / 2, top);
                    cr.LineTo (x - lineWidth / 2, bottom);
                    cr.Color = new Color (0, 0, 0, 0.1);
                    cr.Stroke ();

                    cr.MoveTo (x + lineWidth / 2, top);
                    cr.LineTo (x + lineWidth / 2, bottom);
                    cr.Color = new Color (1, 1, 1, 0.6);
                    cr.Stroke ();
                }

                x += arrowSize / 4.0 + lineWidth / 2.0;

                cr.MoveTo (x, y);
                cr.LineTo (x, y + arrowSize);
                cr.LineTo (x + arrowSize / 2.0, y + arrowSize / 2.0);
                cr.LineTo (x, y);
                cr.Color = new Color (0, 0, 0);
                cr.Fill ();
            }
        }
Пример #17
0
        /// <summary>Draws a group.</summary>
        internal void DrawGroup(Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
        {
            double lineWidth05 = lineWidth/2, lineWidth15 = 3*lineWidth05;
            LinearGradient linGrad;

            double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
            double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;
            cr.Arc (x1, y1, roundSize - lineWidth05, 0, Math.PI/2);
            cr.Arc (x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
            cr.Arc (x0, y0, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
            cr.Arc (x1, y0 + lineWidth, roundSize - lineWidth05, 3*Math.PI/2, 0);
            cr.LineTo (x1 + roundSize - lineWidth05, y1);
            cr.LineWidth = lineWidth;
            cr.Color = colorScheme.Bright;
            cr.Stroke ();

            if(l != null)
            {
                int lblWidth, lblHeight;
                Pango.CairoHelper.UpdateLayout (cr, l);
                l.GetPixelSize(out lblWidth, out lblHeight);

                if(w.LabelPosition == Position.Top || w.LabelPosition == Position.Bottom)
                {
                    double labelY;
                    double bandHeight = lblHeight + 2*space;

                    if(w.LabelPosition == Position.Top)
                    {
                        cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                        cr.Arc (x1, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
                        double bandY = y0 - roundSize + 2*lineWidth + bandHeight;
                        cr.LineTo (x1 + roundSize - lineWidth15, bandY);
                        cr.LineTo (x0 - roundSize + lineWidth05, bandY);
                        linGrad = new LinearGradient (0, bandY - bandHeight, 0, bandY);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelY = bandY - bandHeight - space;
                    }
                    else
                    {
                        cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
                        cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
                        double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
                        cr.LineTo (x0 - roundSize + lineWidth05, bandY);
                        cr.LineTo (x1 + roundSize - lineWidth15, bandY);
                        linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelY = bandY;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableHorizontalSpace = r.Width - 2 * frameSize;
                    if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;

                    cr.Save ();
                    cr.Rectangle (r.X + frameSize, labelY, availableHorizontalSpace, bandHeight);
                    cr.Clip ();

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), labelY + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
                else	// label at right or left
                {
                    double labelX;
                    double bandWidth = lblHeight + 2*space;

                    if(w.LabelPosition == Position.Left)
                    {
                        cr.Arc (x0, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
                        cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                        double bandX = x0 - roundSize + 2*lineWidth + bandWidth;
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        linGrad = new LinearGradient (bandX - bandWidth, 0, bandX, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX - bandWidth - space;
                    }
                    else
                    {
                        cr.Arc (x1, y0 - lineWidth05, roundSize - lineWidth15, 3*Math.PI/2, 0);
                        cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
                        double bandX = x1 + roundSize - 2*lineWidth - bandWidth;
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        linGrad = new LinearGradient (bandX, 0, bandX + bandWidth, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX + space;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableVerticalSpace = r.Height - 2 * frameSize;
                    if(expandButton.Visible) availableVerticalSpace -= expandButton.HeightRequest + space;

                    cr.Save ();
                    cr.Rectangle (labelX, r.Y + frameSize, bandWidth, availableVerticalSpace);
                    cr.Clip ();
                    cr.Rotate (-Math.PI / 2);

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    double shift = Math.Max(0, (availableVerticalSpace - lblWidth) / 2);
                    if(expandButton.Visible) shift += expandButton.HeightRequest + space;
                    cr.MoveTo (-(r.Y + r.Height - 2 * space - shift), labelX + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
            }

            cr.MoveTo (x1 + roundSize - lineWidth15, y1);
            cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
            cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
            cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
            cr.Arc (x1 - lineWidth, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
            cr.LineTo (x1 + roundSize - lineWidth15, y1);
            cr.LineWidth = lineWidth;
            linGrad = new LinearGradient (0, r.Y, 0, r.Y + r.Height - lineWidth);
            linGrad.AddColorStop (0.0, ColorScheme.GetColorRelative (colorScheme.PrettyDark, 0.1));
            linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
            cr.Pattern = linGrad;
            cr.Stroke ();
            linGrad.Destroy ();
        }
Пример #18
0
        public static void RenderThumbnail (Cairo.Context cr, ImageSurface image, bool dispose,
            double x, double y, double width, double height, double radius,
            bool fill, Cairo.Color fillColor, CairoCorners corners, double scale)
        {
            if (image == null || image.Handle == IntPtr.Zero) {
                image = null;
            }

            double p_x = x;
            double p_y = y;

            if (image != null) {
                double scaled_image_width = scale * image.Width;
                double scaled_image_height = scale * image.Height;

                p_x += (scaled_image_width < width ? (width - scaled_image_width) / 2 : 0) / scale;
                p_y += (scaled_image_height < height ? (height - scaled_image_height) / 2 : 0) / scale;
            }

            cr.Antialias = Cairo.Antialias.Default;

            if (image != null) {
                if (fill) {
                    CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
                    cr.Color = fillColor;
                    cr.Fill ();
                }

                cr.Scale (scale, scale);
                CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
                cr.SetSource (image, p_x, p_y);
                cr.Fill ();
                cr.Scale (1.0/scale, 1.0/scale);
            } else {
                CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);

                if (fill) {
                    var grad = new LinearGradient (x, y, x, y + height);
                    grad.AddColorStop (0, fillColor);
                    grad.AddColorStop (1, CairoExtensions.ColorShade (fillColor, 1.3));
                    cr.Pattern = grad;
                    cr.Fill ();
                    grad.Destroy ();
                }
            }

            cr.Stroke ();

            if (dispose && image != null) {
                ((IDisposable)image).Dispose ();
            }
        }
Пример #19
0
        internal void DrawKeyTip(Context cr, Point reference, double horizontal_align, double vertical_align, Pango.Layout layout)
        {
            Pango.Layout min_layout = Pango.CairoHelper.CreateLayout (cr);

            min_layout.SetText ("O");
            Pango.CairoHelper.UpdateLayout (cr, min_layout);
            int minWidth, minHeight;
            min_layout.GetPixelSize (out minWidth, out minHeight);

            /*layout.SetText (label);
            Pango.CairoHelper.UpdateLayout (cr, layout);*/
            int lblWidth, lblHeight;
            layout.GetPixelSize (out lblWidth, out lblHeight);

            int width = Math.Max (minWidth, lblWidth);
            int height = Math.Max (minHeight, lblHeight);

            double x0 = reference.X - (width * horizontal_align), x1 = x0 + width;
            double y0 = reference.Y - (height * vertical_align), y1 = y0 + height;

            cr.LineWidth = 1.0;

            cr.MoveTo (x0 + 1.5, y0 + 0.5);
            cr.LineTo (x1 - 1.5, y0 + 0.5);
            cr.LineTo (x1 - 0.5, y0 + 1.5);
            cr.LineTo (x1 - 0.5, y1 - 1.5);
            cr.LineTo (x1 - 1.5, y1 - 0.5);
            cr.LineTo (x0 + 1.5, y1 - 0.5);
            cr.LineTo (x0 + 0.5, y1 - 1.5);
            cr.LineTo (x0 + 0.5, y0 + 1.5);
            cr.LineTo (x0 + 0.5, y0 + 0.5);

            cr.Color = new Color (0, 0, 0);
            cr.StrokePreserve ();

            LinearGradient grad = new LinearGradient (0, y0, 0, y1);
            grad.AddColorStop (0, colorScheme.LightBright);
            grad.AddColorStop (1, colorScheme.LightDark);
            cr.Pattern = grad;
            cr.Fill ();
            grad.Destroy ();

            Pango.CairoHelper.UpdateLayout (cr, layout);
            cr.MoveTo (x0 + 1, y0 +1);
            cr.Color = new Color (0, 0, 0);
            Pango.CairoHelper.ShowLayout (cr, layout);
        }
Пример #20
0
		protected sealed override void PaintSurface (DockySurface surface)
		{
			surface.Clear ();
			
			lock (buffers) {
				if (slideCounter > 0 && slideCounter < slideSteps) {
					double offset = Allocation.Width * Math.Log (slideCounter) / Math.Log (slideSteps);
					
					if (MovedLeft) {
						ShowBuffer (surface, Page, offset - Allocation.Width);
						ShowBuffer (surface, LastPage, offset);
					} else {
						ShowBuffer (surface, Page, Allocation.Width - offset);
						ShowBuffer (surface, LastPage, -offset);
					}
					
					// fade out the edges during a slide
					Gradient linpat = new LinearGradient (0, surface.Height / 2, surface.Width, surface.Height / 2);
					linpat.AddColorStop (0, new Color(1, 1, 1, 1));
					linpat.AddColorStop (2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1 - 2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1, new Color(1, 1, 1, 1));
						
					surface.Context.Save ();
					surface.Context.Operator = Operator.Source;
					surface.Context.Color = new Cairo.Color (0, 0, 0, 0);
					surface.Context.Mask (linpat);
					surface.Context.PaintWithAlpha (0);
					surface.Context.Restore ();
					linpat.Destroy ();
				} else {
					ShowBuffer (surface, Page, 0);
				}
			}
			
			// overlay the prev/next arrow buttons
			if (buttonBuffer != null && (buttonBuffer.Width != surface.Width || buttonBuffer.Height != surface.Height))
				ResetButtons ();
			
			if (buttonBuffer == null) {
				buttonBuffer = new DockySurface (surface.Width, surface.Height, surface);
				DrawButtonsBuffer ();
			}
			
			buttonBuffer.Internal.Show (surface.Context, 0, 0);
		}
Пример #21
0
		void DrawActiveIndicator (DockySurface surface, Gdk.Rectangle area, Cairo.Color color, double opacity)
		{
			surface.Context.Rectangle (area.X, area.Y, area.Width, area.Height);
			LinearGradient lg;
			
			switch (Position) {
			case DockPosition.Top:
				lg = new LinearGradient (0, area.Y, 0, area.Y + area.Height);
				break;
			case DockPosition.Left:
				lg = new LinearGradient (area.X, 0, area.X + area.Width, 0);
				break;
			case DockPosition.Right:
				lg = new LinearGradient (area.X + area.Width, 0, area.X, 0);
				break;
			default:
			case DockPosition.Bottom:
				lg = new LinearGradient (0, area.Y + area.Height, 0, area.Y);
				break;
			}
			lg.AddColorStop (0, color.SetAlpha (0.6 * opacity));
			lg.AddColorStop (1, color.SetAlpha (0.0));
			
			surface.Context.Pattern = lg;
			surface.Context.Fill ();
			
			lg.Destroy ();
		}
Пример #22
0
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Cairo.Color gtk_background_color =
                CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBackgroundColor (StateFlags.Normal));
            Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
            Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95);

            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (0.75, dark_color);
            grad.AddColorStop (0, light_color);

            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
            cr.Fill ();

            cr.Color = border_color;
            cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill ();
            grad.Destroy ();
        }
Пример #23
0
		protected override void PaintIconSurface (DockySurface surface)
		{
			int size = Math.Min (surface.Width, surface.Height);
			Context cr = surface.Context;
			
			double center = size / 2.0;
			Cairo.Color base_color = new Cairo.Color (1, .3, .3, .5).SetHue (120 * (1 - CPUUtilization));
			
			double radius = Math.Max (Math.Min (CPUUtilization * 1.3, 1), .001);
			
			// draw underlay
			cr.Arc (center, center, center * RadiusPercent, 0, Math.PI * 2);
			cr.Color = new Cairo.Color (0, 0, 0, .5);
			cr.FillPreserve ();
			
			RadialGradient rg = new RadialGradient (center, center, 0, center, center, center * RadiusPercent);
			rg.AddColorStop (0, base_color);
			rg.AddColorStop (0.2, base_color);
			rg.AddColorStop (1, new Cairo.Color (base_color.R, base_color.G, base_color.B, 0.15));
			cr.Pattern = rg;
			cr.FillPreserve ();
			
			rg.Destroy ();
			
			// draw cpu indicator
			rg = new RadialGradient (center, center, 0, center, center, center * RadiusPercent * radius);
			rg.AddColorStop (0, new Cairo.Color (base_color.R, base_color.G, base_color.B, 1));
			rg.AddColorStop (0.2, new Cairo.Color (base_color.R, base_color.G, base_color.B, 1));
			rg.AddColorStop (1, new Cairo.Color (base_color.R, base_color.G, base_color.B, Math.Max (0, CPUUtilization * 1.3 - 1)));
			cr.Pattern = rg;
			cr.Fill ();
			
			rg.Destroy ();
			
			// draw highlight
			cr.Arc (center, center * .8, center * .6, 0, Math.PI * 2);
			LinearGradient lg = new LinearGradient (0, 0, 0, center);
			lg.AddColorStop (0, new Cairo.Color (1, 1, 1, .35));
			lg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));
			cr.Pattern = lg;
			cr.Fill ();
			lg.Destroy ();
			
			// draw outer circles
			cr.LineWidth = 1;
			cr.Arc (center, center, center * RadiusPercent, 0, Math.PI * 2);
			cr.Color = new Cairo.Color (1, 1, 1, .75);
			cr.Stroke ();
			
			cr.LineWidth = 1;
			cr.Arc (center, center, center * RadiusPercent - 1, 0, Math.PI * 2);
			cr.Color = new Cairo.Color (.8, .8, .8, .75);
			cr.Stroke ();
			
			// draw memory indicate
			cr.LineWidth = size / 32.0;
			cr.ArcNegative (center, center, center * RadiusPercent - 1, Math.PI, Math.PI - Math.PI * (2 * MemoryUtilization));
			cr.Color = new Cairo.Color (1, 1, 1, .8);
			cr.Stroke ();
		}