static void DrawIcon (MonoTextEditor editor, Cairo.Context cr, DocumentLine lineSegment, double x, double y, double width, double height)
		{
			if (lineSegment.IsBookmarked) {
				var color1 = editor.ColorStyle.Bookmarks.Color;
				var color2 = editor.ColorStyle.Bookmarks.SecondColor;
				
				DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);

				// FIXME: VV: Remove gradient features
				using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) {
					pat.AddColorStop (0, color1);
					pat.AddColorStop (1, color2);
					cr.SetSource (pat);
					cr.FillPreserve ();
				}

				// FIXME: VV: Remove gradient features
				using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) {
					pat.AddColorStop (0, color2);
					//pat.AddColorStop (1, color1);
					cr.SetSource (pat);
					cr.Stroke ();
				}
			}
		}
Example #2
0
        private static void Taskbar()
        {
            var Data    = new byte[Compositor.PACKET_SIZE];
            var Request = (GuiRequest *)Data.GetDataOffset();

            Request->ClientID = 0;
            Request->Type     = RequestType.NewWindow;

            var Window = (NewWindow *)Request;

            Window->X      = 0;
            Window->Y      = 0;
            Window->Width  = VBE.Xres;
            Window->Height = 30;

            Compositor.Server.Write(Data);
            Client.Read(Data);

            string HashCode = new string(Window->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);

            TaskbarID = Window->WindowID;

            uint surface = Cairo.ImageSurfaceCreateForData(Window->Width * 4, Window->Height, Window->Width, ColorFormat.ARGB32, aBuffer);
            uint context = Cairo.Create(surface);

            uint pattern = Cairo.PatternCreateLinear(30, 0, 0, 0);

            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern);
            Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern);
            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern);

            Cairo.SetOperator(Operator.Over, context);
            Cairo.Rectangle(30, VBE.Xres, 0, 0, context);
            Cairo.SetSource(pattern, context);
            Cairo.Fill(context);

            Cairo.Rectangle(2, VBE.Xres, 30 - 2, 0, context);
            Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, context);
            Cairo.Fill(context);

            Cairo.PatternDestroy(pattern);
            Cairo.Destroy(context);
            Cairo.SurfaceDestroy(surface);

            Request->Type = RequestType.Redraw;
            var Redraw = (Redraw *)Request;

            Redraw->WindowID = TaskbarID;
            Redraw->X        = 0;
            Redraw->Y        = 0;
            Redraw->Width    = VBE.Xres;
            Redraw->Height   = 40;
            Compositor.Server.Write(Data);

            TaskbarSurface = surface;
            TaskbarContext = context;
            Heap.Free(Data);
        }
Example #3
0
 public override void DrawFrameBackground(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color, Cairo.Pattern pattern)
 {
     color.A = Context.FillAlpha;
     if (pattern != null) {
         cr.SetSource (pattern);
     } else {
         cr.SetSourceColor (color);
     }
     CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.All);
     cr.Fill ();
 }
Example #4
0
		static void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
		{
			e.Arc(center.X, center.Y, radius, 0, 360);
			Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
			pat.AddColorStop(0, Eto.Drawing.Color.FromArgb(240, 240, 230, 75).ToCairo());
			pat.AddColorStop(1, Eto.Drawing.Color.FromArgb(0, 0, 0, 50).ToCairo());
			e.LineWidth = 0.1;
			e.SetSource(pat);
			e.FillPreserve();
			e.Stroke();
		}
Example #5
0
        public 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.SetSource (grad);
            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill ();
            grad.Dispose ();
        }
Example #6
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;
            using (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.SetSource (grad);
                CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
                cr.Fill ();
            }

            cr.Restore ();
        }
Example #7
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad = radius - 0.5;
            int centerX = region.X + region.Width / 2;
            int centerY = region.Y + region.Height / 2;

            context.MoveTo (centerX + rad, centerY);
            context.Arc (centerX, centerY, rad, 0, Math.PI * 2);

            double high;
            double low;
            switch (state) {
            case StateType.Selected:
                high = 0.85;
                low = 1.0;
                break;
            case StateType.Prelight:
                high = 1.0;
                low = 0.9;
                break;
            case StateType.Insensitive:
                high = 0.95;
                low = 0.83;
                break;
            default:
                high = 1.0;
                low = 0.85;
                break;
            }
            using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
                lg.AddColorStop (0, new Cairo.Color (high, high, high));
                lg.AddColorStop (1, new Cairo.Color (low, low, low));
                context.SetSource (lg);
                context.FillPreserve ();
            }

            context.SetSourceRGBA (0, 0, 0, 0.4);
            context.LineWidth = 1;
            context.Stroke ();
        }
Example #8
0
 protected void DrawSurfaceAt(Cairo.Context gr, ImageSurface surface, double x, double y)
 {
     gr.Save();
     gr.SetSource(surface, this._x + x, this._y + y);
     gr.Paint();
     gr.Restore();
 }
Example #9
0
		void DrawCloseButton (Cairo.Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				double fillColor = .74;
				
				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);
				
				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();
				
				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);
					
					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();
					
					
					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new Cairo.LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.SetSource (lg);
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();

				}
			}
		}
Example #10
0
		void DrawTab (Cairo.Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int) (tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int) (padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));


			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (LinearGradient gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();
			
			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));
					
					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)
			
			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3, 
			                               tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2, 
			                               CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw. 
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
Example #11
0
        public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            cr.LineWidth = BorderWidth;
            border_color.A = 0.3;
            cr.SetSourceColor (border_color);

            double offset = (double)BorderWidth / 2.0;
            double w = Math.Max (0, alloc.Width * 0.75);
            double x = alloc.X + (alloc.Width - w) * 0.5 + offset;
            double y = alloc.Y + alloc.Height + offset;

            LinearGradient g = new LinearGradient (x, y, x + w, y);

            Color transparent = border_color;
            transparent.A = 0.0;

            g.AddColorStop (0, transparent);
            g.AddColorStop (0.4, border_color);
            g.AddColorStop (0.6, border_color);
            g.AddColorStop (1, transparent);

            cr.SetSource (g);

            cr.MoveTo (x, y);
            cr.LineTo (x + w, y);
            cr.Stroke ();

            g.Dispose ();
        }
Example #12
0
            protected override void ClippedRender(Cairo.Context cr)
            {
                LinearGradient grad = new LinearGradient (0, 0, RenderSize.Width, RenderSize.Height);
                grad.AddColorStop (0, new Color (0.5, 0.5, 0.5));
                grad.AddColorStop (1, new Color (0, 0, 0));
                cr.SetSource (grad);

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

                grad.Dispose ();

                base.ClippedRender (cr);
            }
Example #13
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 ();
            }
        }
			public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
			{
				if (metrics.SelectionStart >= 0 || editor.CurrentMode is TextLinkEditMode || editor.TextViewMargin.SearchResultMatchCount > 0)
					return false;
				foreach (var usage in Usages) {
					int markerStart = usage.TextSegment.Offset;
					int markerEnd = usage.TextSegment.EndOffset;
					
					if (markerEnd < metrics.TextStartOffset || markerStart > metrics.TextEndOffset) 
						return false; 
					
					double @from;
					double to;
					
					if (markerStart < metrics.TextStartOffset && metrics.TextEndOffset < markerEnd) {
						@from = metrics.TextRenderStartPosition;
						to = metrics.TextRenderEndPosition;
					} else {
						int start = metrics.TextStartOffset < markerStart ? markerStart : metrics.TextStartOffset;
						int end = metrics.TextEndOffset < markerEnd ? metrics.TextEndOffset : markerEnd;
						
						uint curIndex = 0, byteIndex = 0;
						TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - metrics.TextStartOffset), ref curIndex, ref byteIndex);
						
						int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
						
						@from = metrics.TextRenderStartPosition + (int)(x_pos / Pango.Scale.PangoScale);
						
						TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - metrics.TextStartOffset), ref curIndex, ref byteIndex);
						x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
			
						to = metrics.TextRenderStartPosition + (int)(x_pos / Pango.Scale.PangoScale);
					}
		
					@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
					to = System.Math.Max (to, editor.TextViewMargin.XOffset);
					if (@from < to) {
						Mono.TextEditor.Highlighting.AmbientColor colorStyle;
						if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write) {
							colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
						} else {
							colorStyle = editor.ColorStyle.UsagesRectangle;
						}

						using (var lg = new LinearGradient (@from + 1, y + 1, to , y + editor.LineHeight)) {
							lg.AddColorStop (0, colorStyle.Color);
							lg.AddColorStop (1, colorStyle.SecondColor);
							cr.SetSource (lg);
							cr.RoundedRectangle (@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4);
							cr.FillPreserve ();
						}
						
						cr.SetSourceColor (colorStyle.BorderColor);
						cr.Stroke ();
					}
				}
				return true;
			}
		void DrawBackground (Cairo.Context cr, Gdk.Rectangle allocation)
		{
			cr.LineWidth = 1;
			cr.Rectangle (0, 0, allocation.Width, allocation.Height);

			if (TextEditor.ColorStyle != null) {
				if (MonoDevelop.Core.Platform.IsWindows) {
					using (var pattern = new Cairo.SolidPattern (win81Background)) {
						cr.SetSource (pattern);
						cr.Fill ();
					}
				} else {
					var col = TextEditor.ColorStyle.PlainText.Background.ToXwtColor ();
					col.Light *= 0.948;
					using (var grad = new Cairo.LinearGradient (0, 0, allocation.Width, 0)) {
						grad.AddColorStop (0, col.ToCairoColor ());
						grad.AddColorStop (0.7, TextEditor.ColorStyle.PlainText.Background);
						grad.AddColorStop (1, col.ToCairoColor ());
						cr.SetSource (grad);
						cr.Fill ();
					}
				}
			}
			DrawLeftBorder (cr);
		}
Example #16
0
        public void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
        {
            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;
            LinearGradient grad = null;

            if (filled) {
                if (flat_fill) {
		    cr.SetSourceColor (selection_color);
                } else {
                    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;

                    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.SetSource (grad);
                }

                CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill ();

                if (grad != null) {
			grad.Dispose ();
                }
            }

            if (filled && stroked) {
                cr.LineWidth = 1.0;
		cr.SetSourceColor (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.SetSourceColor (selection_stroke);
                CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1,
                    Context.Radius, corners, true);
                cr.Stroke ();
            }
        }
Example #17
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            color.A *= 0.85;
            Cairo.Color selection_color = color;
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_stroke.A = color.A;

            if (filled) {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.05);
                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_dark);
                grad.AddColorStop (1, selection_fill_light);

                cr.SetSource (grad);
                cr.Rectangle (x, y, width, height);
                cr.Fill ();
                grad.Dispose ();
            }

            if (stroked && !filled) {
                cr.LineWidth = 1.0;
                cr.SetSourceColor (selection_stroke);
                cr.Rectangle (x + 0.5, y + 0.5, width - 1, height - 1);
                cr.Stroke ();
            }
        }
Example #18
0
 /// <summary>
 /// Draws the Boards picture. 
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="path">Path.</param>
 /// <param name="maxWidth">Max width.</param>
 public static void SetMCUSurface(Cairo.Context context, string path, int maxWidth = int.MaxValue)
 {
     try {
         var surf =	GetImage (path);
         MCUImageXZero = ShiftX - surf.Width / 2;
         MCUImageYZero = ShiftY - surf.Height / 2;
         context.SetSource (
             surf,
             MCUImageXZero,
             MCUImageYZero
         );
         context.Paint ();
         surf.Dispose ();
     } catch (Exception ex) {
         Console.Error.WriteLine (ex);
     }
 }
Example #19
0
        public override void DrawFrameBackground(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color, Cairo.Pattern pattern)
        {
            // Hack to only render the black background for now playing
            if (pattern == null && color.R != 0 && color.G != 0 && color.B != 0) {
                return;
            }

            color.A = Context.FillAlpha;
            if (pattern != null) {
                cr.SetSource (pattern);
            } else {
                cr.SetSourceColor (color);
            }
            cr.Rectangle (alloc.X, alloc.Y, alloc.Width, alloc.Height);
            cr.Fill ();
        }
Example #20
0
		void RenderBackground (Cairo.Context context, Gdk.Rectangle region)
		{
			region.Inflate (-Padding, -Padding);
			context.RenderOuterShadow (new Gdk.Rectangle (region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25);

			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5);
			using (var lg = new LinearGradient (0, region.Y, 0, region.Bottom)) {
				lg.AddColorStop (0, new Cairo.Color (.36, .53, .73));
				lg.AddColorStop (1, new Cairo.Color (.21, .37, .54));

				context.SetSource (lg);
				context.FillPreserve ();
			}

			context.LineWidth = 1;
			context.SetSourceRGB (.29, .47, .67);
			context.Stroke ();
		}
		public override void DrawAfterEol (MonoTextEditor textEditor, Cairo.Context g, EndOfLineMetrics metrics)
		{
			if (!IsVisible)
				return;
			EnsureLayoutCreated (editor);
			int errorCounterWidth = 0, eh = 0;
			if (errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out errorCounterWidth, out eh);
				errorCounterWidth = Math.Max (15, Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4)));
			}

			var sx = metrics.TextRenderEndPosition;
			var width = LayoutWidth + errorCounterWidth + editor.LineHeight;
			var drawLayout = layouts[0].Layout;
			var y = metrics.LineYRenderStartPosition;
			bool customLayout = true; //sx + width > editor.Allocation.Width;
			bool hideText = false;
			bubbleIsReduced = customLayout;
			var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null;
			double roundingRadius = editor.LineHeight / 2 - 1;

			if (customLayout) {
				width = editor.Allocation.Width - sx;
				string text = layouts[0].Layout.Text;
				drawLayout = new Pango.Layout (editor.PangoContext);
				drawLayout.FontDescription = cache.fontDescription;
				var paintWidth = (width - errorCounterWidth - editor.LineHeight + 4);
				var minWidth = Math.Max (25, errorCounterWidth) * editor.Options.Zoom;
				if (paintWidth < minWidth) {
					hideText = true;
					showErrorCount = false;
//					drawLayout.SetMarkup ("<span weight='heavy'>ยทยทยท</span>");
					width = minWidth;
					//roundingRadius = 10 * editor.Options.Zoom;
					sx = Math.Min (sx, editor.Allocation.Width - width);
				} else {
					drawLayout.Ellipsize = Pango.EllipsizeMode.End;
					drawLayout.Width = (int)(paintWidth * Pango.Scale.PangoScale);
					drawLayout.SetText (text);
					int w2, h2;
					drawLayout.GetPixelSize (out w2, out h2);
					width = w2 + errorCounterWidth + editor.LineHeight - 2;
				}
			}

			bubbleDrawX = sx - editor.TextViewMargin.XOffset;
			bubbleDrawY = y + 2;
			bubbleWidth = width;
			var bubbleHeight = editor.LineHeight;

			g.RoundedRectangle (sx, y, width, bubbleHeight, roundingRadius);
			g.SetSourceColor (TagColor.Color);
			g.Fill ();

			// Draw error count icon
			if (showErrorCount) {
				var errorCounterHeight = bubbleHeight - 2;
				var errorCounterX = sx + width - errorCounterWidth - 1;
				var errorCounterY = Math.Round (y + (bubbleHeight - errorCounterHeight) / 2);

				g.RoundedRectangle (
					errorCounterX, 
					errorCounterY, 
					errorCounterWidth, 
					errorCounterHeight, 
					editor.LineHeight / 2 - 2
				);

				using (var lg = new Cairo.LinearGradient (errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) {
					lg.AddColorStop (0, CounterColor.Color);
					lg.AddColorStop (1, CounterColor.Color.AddLight (-0.1));
					g.SetSource (lg);
					g.Fill ();
				}

				g.Save ();

				int ew;
				errorCountLayout.GetPixelSize (out ew, out eh);

				var tx = Math.Round (errorCounterX + (2 + errorCounterWidth - ew) / 2);
				var ty = Math.Round (errorCounterY + (-1 + errorCounterHeight - eh) / 2);

				g.Translate (tx, ty);
				g.SetSourceColor (CounterColor.SecondColor);
				g.ShowLayout (errorCountLayout);
				g.Restore ();
			}

			if (hideText) {
				// Draw dots
				double radius = 2 * editor.Options.Zoom;
				double spacing = 1 * editor.Options.Zoom;

				sx += 1 * editor.Options.Zoom + Math.Ceiling((bubbleWidth - 3 * (radius * 2) - 2 * spacing) / 2);

				for (int i = 0; i < 3; i++) {
					g.Arc (sx, y + bubbleHeight / 2, radius, 0, Math.PI * 2);
					g.SetSourceColor (TagColor.SecondColor);
					g.Fill ();
					sx += radius * 2 + spacing;
				}
			} else {
				// Draw label text
				var tx = Math.Round (sx + editor.LineHeight / 2);
				var ty = Math.Round (y + (editor.LineHeight - layouts [0].Height) / 2) - 1;

				g.Save ();
				g.Translate (tx, ty);

				g.SetSourceColor (TagColor.SecondColor);
				g.ShowLayout (drawLayout);
				g.Restore ();
			}

			if (customLayout)
				drawLayout.Dispose ();
		}
Example #22
0
		void RenderButton (Cairo.Context context, Gdk.Point corner, double opacity, bool hovered)
		{
			Gdk.Rectangle region = new Gdk.Rectangle (corner.X,
			                                          corner.Y,
			                                          ButtonSize.Width, ButtonSize.Height);



			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
			using (var lg = new LinearGradient (0, region.Top, 0, region.Bottom)) {
				if (hovered) {
					lg.AddColorStop (0, new Cairo.Color (.15, .76, .09, opacity));
					lg.AddColorStop (1, new Cairo.Color (.41, .91, .46, opacity));
				} else {
					lg.AddColorStop (0, new Cairo.Color (.41, .91, .46, opacity));
					lg.AddColorStop (1, new Cairo.Color (.15, .76, .09, opacity));
				}

				context.SetSource (lg);
				context.FillPreserve ();
			}

			context.SetSourceRGBA (.29, .79, .28, opacity);
			context.LineWidth = 1;
			context.Stroke ();

			region.Inflate (-1, -1);
			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 2);

			using (var lg = new LinearGradient (0, region.Top, 0, region.Bottom)) {
				lg.AddColorStop (0, new Cairo.Color (1, 1, 1, .74 * opacity));
				lg.AddColorStop (0.1, new Cairo.Color (1, 1, 1, 0));
				lg.AddColorStop (0.9, new Cairo.Color (0, 0, 0, 0));
				lg.AddColorStop (1, new Cairo.Color (0, 0, 0, .34 * opacity));

				context.SetSource (lg);
				context.Stroke ();
			}

			using (var layout = ButtonLayout (PangoContext)) {
				int w, h;
				layout.GetPixelSize (out w, out h);

				RenderShadowedText (context, new Gdk.Point (corner.X + ButtonSize.Width / 2 - w / 2, corner.Y + ButtonSize.Height / 2 - h / 2 - 1), opacity, layout);
			}
		}
Example #23
0
		void DrawBackground (Cairo.Context ctx, Gdk.Rectangle region)
		{
			var h = region.Height;
			ctx.Rectangle (0, 0, region.Width, h);
			using (Cairo.LinearGradient gr = new LinearGradient (0, 0, 0, h)) {
				gr.AddColorStop (0, Styles.TabBarGradientStartColor);
				gr.AddColorStop (1, Styles.TabBarGradientMidColor);
				ctx.SetSource (gr);
				ctx.Fill ();
			}
			
			ctx.MoveTo (region.X, 0.5);
			ctx.LineTo (region.Right + 1, 0.5);
			ctx.LineWidth = 1;
			ctx.SetSourceColor (Styles.TabBarGradientShadowColor);
			ctx.Stroke ();
		}
Example #24
0
 public override void Apply(Cairo.Context cr)
 {
     if (surface != null) {
         cr.SetSource (surface);
     }
 }
Example #25
0
 protected override bool OnDrawn(Cairo.Context cr)
 {
     if (surface != null) {
         cr.Save ();
         Gtk.CairoHelper.TransformToWindow (cr, this, Window);
         cr.SetSource (surface);
         cr.Rectangle (widget_alloc.X, widget_alloc.Y, widget_alloc.Width, widget_alloc.Height);
         cr.Fill ();
         cr.Restore ();
         return true;
     } else {
         return base.OnDrawn (cr);
     }
 }
Example #26
0
File: Boot.cs Project: vdt/AtomOS
        private static unsafe void DrawTaskbar(GuiRequest *request, byte[] xData)
        {
            request->Type  = RequestType.NewWindow;
            request->Error = ErrorType.None;
            var taskbar = (NewWindow *)request;
            int height  = 30;

            taskbar->X      = 0;
            taskbar->Y      = 0;
            taskbar->Width  = VBE.Xres;
            taskbar->Height = height;

            Compositor.Server.Write(xData);

            SystemClient.Read(xData);
            if (request->Error != ErrorType.None)
            {
                Debug.Write("Error4: %d\n", (int)request->Error);
                return;
            }

            string HashCode = new string(taskbar->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);
            int    winID    = taskbar->WindowID;

            Debug.Write("winID: %d\n", winID);

            uint surface = Cairo.ImageSurfaceCreateForData(VBE.Xres * 4, height, VBE.Xres, ColorFormat.ARGB32, aBuffer);
            uint cr      = Cairo.Create(surface);

            uint pattern = Cairo.PatternCreateLinear(height, 0, 0, 0);

            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern);
            Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern);
            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern);

            Cairo.SetOperator(Operator.Over, cr);
            Cairo.Rectangle(height, VBE.Xres, 0, 0, cr);
            Cairo.SetSource(pattern, cr);
            Cairo.Fill(cr);

            Cairo.Rectangle(2, VBE.Xres, height - 2, 0, cr);
            Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, cr);
            Cairo.Fill(cr);

            Cairo.SetSourceRGBA(1, 1, 1, 1, cr);
            Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.SetFontSize(20, cr);
            Cairo.MoveTo(20, 1215, cr);
            Cairo.ShowText(Marshal.C_String("20:10"), cr);

            Cairo.PatternDestroy(pattern);
            Cairo.Destroy(cr);
            Cairo.SurfaceDestroy(surface);

            request->Type = RequestType.Redraw;
            var req = (Redraw *)request;

            req->WindowID = winID;
            req->X        = 0;
            req->Y        = 0;
            req->Width    = VBE.Xres;
            req->Height   = height;
            Compositor.Server.Write(xData);
        }
		void DrawBlockBg (Cairo.Context ctx, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;
			
			var color = block.Type == BlockType.Added ? Styles.LogView.DiffAddBackgroundColor : Styles.LogView.DiffRemoveBackgroundColor;
			double y = block.YStart;
			int height = block.YEnd - block.YStart;
			
			double markerx = x + LeftPaddingBlock;
			double rd = RoundedSectionRadius;
			if (block.SectionStart) {
				ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
				ctx.LineTo (markerx, y);
			} else {
				ctx.MoveTo (markerx, y);
			}
			
			ctx.LineTo (markerx, y + height);
			
			if (block.SectionEnd) {
				ctx.LineTo (x + rd, y + height);
				ctx.Arc (x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
			} else {
				ctx.LineTo (x, y + height);
			}
			if (block.SectionStart) {
				ctx.LineTo (x, y + rd);
			} else {
				ctx.LineTo (x, y);
			}
			ctx.SetSourceColor (color.AddLight (0.1).ToCairoColor ());
			ctx.Fill ();
			
			ctx.Rectangle (markerx, y, width - markerx, height);

			// FIXME: VV: Remove gradient features
			using (Cairo.Gradient pat = new Cairo.LinearGradient (x, y, x + width, y)) {
				pat.AddColorStop (0, color.AddLight (0.21).ToCairoColor ());
				pat.AddColorStop (1, color.AddLight (0.3).ToCairoColor ());
				ctx.SetSource (pat);
				ctx.Fill ();
			}
		}
        protected override void RenderCoverArt (Cairo.Context cr, ImageSurface image)
        {
            if (image == null) {
                return;
            }

            Gdk.Rectangle alloc = RenderAllocation;
            int asr = ArtworkSizeRequest;
            int reflect = (int)(image.Height * 0.2);
            int surface_w = image.Width;
            int surface_h = image.Height + reflect;
            int x = alloc.X + alloc.Width - asr;
            int y = alloc.Y;

            Surface scene = null;
            if (!surfaces.TryGetValue (image, out scene)) {
                scene = CreateScene (cr, image, reflect);
                surfaces.Add (image, scene);
            }

            cr.Rectangle (x, y, asr, alloc.Height);
            cr.Color = BackgroundColor;
            cr.Fill ();

            x += (asr - surface_w) / 2;
            y += surface_h > asr ? 0 : (asr - surface_h) / 2;

            cr.SetSource (scene, x, y);
            cr.Paint ();
        }
Example #29
0
        protected void DrawScaledSurfaceAt(Cairo.Context gr, ImageSurface image, double x, double y, double height, double width)
        {
            //calculate proportional scaling
            var img_height = image.Height;
            var img_width = image.Width;

            var width_ratio = (width) / (img_width);
            var height_ratio = (height) / (img_height);
            var scale_xy = Math.Min(height_ratio, width_ratio);
            //scale image and add it
            gr.Save();
            gr.Scale(scale_xy, scale_xy);
            gr.Translate(x, y);
            gr.SetSource(image,(int)x, (int)y);

            gr.Paint();
            gr.Restore();
        }
			void FillGradient (Cairo.Context cr, double y, double h)
			{
				cr.Rectangle (0.5, y, Allocation.Width, h);
				using (var grad = new Cairo.LinearGradient (0, y, Allocation.Width, y)) {
					var col = (HslColor)Style.Base (StateType.Normal);
					col.L *= 0.95;
					grad.AddColorStop (0, col);
					grad.AddColorStop (0.7, (HslColor)Style.Base (StateType.Normal));
					grad.AddColorStop (1, col);
					cr.SetSource (grad);
					cr.Fill ();
				}
			}
Example #31
0
		void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor)
		{
			var width = Allocation.Width;

			int diameter = Math.Min (width, (int)IndicatorHeight) - indicatorPadding * 2;
			var x1 = Math.Round (width / 2d);
			double y1 = indicatorPadding + diameter / 2;
			if (diameter % 2 == 0) {
				x1 += 0.5;
				y1 += 0.5;
			}

			cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);

			if (Platform.IsWindows) {
				using (var pattern = new Cairo.SolidPattern (color)) {
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			} else {
				using (var pattern = new Cairo.RadialGradient (x1, y1, width / 2, x1 - width, y1 - width, width)) {
					pattern.AddColorStop (0, borderColor);
					pattern.AddColorStop (1, color);
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			}
			
			cr.SetSourceColor (borderColor);
			cr.Stroke ();
		}
Example #32
0
        void Draw(Cairo.Context ctx, List<TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
                return;

            Pango.Layout layout = new Pango.Layout (PangoContext);
            TableRow lastCategory = null;

            foreach (var r in rowList) {
                int w,h;
                layout.SetText (r.Label);
                layout.GetPixelSize (out w, out h);
                int indent = 0;

                if (r.IsCategory) {
                    var rh = h + CategoryTopBottomPadding*2;
                    ctx.Rectangle (0, y, Allocation.Width, rh);
                    using (var gr = new LinearGradient (0, y, 0, rh)) {
                        gr.AddColorStop (0, new Cairo.Color (248d/255d, 248d/255d, 248d/255d));
                        gr.AddColorStop (1, new Cairo.Color (240d/255d, 240d/255d, 240d/255d));
                        ctx.SetSource (gr);
                        ctx.Fill ();
                    }

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand) {
                        ctx.MoveTo (0, y + 0.5);
                        ctx.LineTo (Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo (0, y + rh - 0.5);
                    ctx.LineTo (Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor (DividerColor);
                    ctx.Stroke ();

                    ctx.MoveTo (x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor (CategoryLabelColor);
                    Pango.CairoHelper.ShowLayout (ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage (this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round ((rh - img.Height) / 2));

                    y += rh;
                    lastCategory = r;
                }
                else {
                    var cell = GetCell (r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save ();
                    ctx.Rectangle (0, y, dividerX, h + PropertyTopBottomPadding*2);
                    ctx.Clip ();
                    ctx.MoveTo (x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor (Style.Text (state).ToCairoColor ());
                    Pango.CairoHelper.ShowLayout (ctx, layout);
                    ctx.Restore ();

                    if (r != currentEditorRow)
                        cell.Render (GdkWindow, ctx, r.EditorBounds, state);

                    y += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand)) {
                    int py = y;

                    ctx.Save ();
                    if (r.AnimatingExpand)
                        ctx.Rectangle (0, y, Allocation.Width, r.AnimationHeight);
                    else
                        ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height);

                    ctx.Clip ();
                    Draw (ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore ();

                    if (r.AnimatingExpand) {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle (0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor (LabelBackgroundColor);
                        ctx.Fill ();
                        ctx.Rectangle (dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceRGB (1, 1, 1);
                        ctx.Fill ();
                    }
                }
            }
        }