public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "") { float widthRatio = 1f; float heightRatio = 1f; if (Scaled) { widthRatio = (float)rect.Width / Dimensions.Width; heightRatio = (float)rect.Height / Dimensions.Height; } if (KeepProportions) { if (widthRatio < heightRatio) heightRatio = widthRatio; else widthRatio = heightRatio; } gr.Save (); gr.Translate (rect.Left,rect.Top); gr.Scale (widthRatio, heightRatio); gr.Translate (((float)rect.Width/widthRatio - Dimensions.Width)/2f, ((float)rect.Height/heightRatio - Dimensions.Height)/2f); if (string.IsNullOrEmpty (subPart)) hSVG.RenderCairo (gr); else hSVG.RenderCairoSub (gr, "#" + subPart); gr.Restore (); }
public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius, Cairo.Color color, Cairo.Color borderColor) { gr.Save(); if((radius > height / 2) || (radius > width / 2)) radius = Math.Min(height / 2, width / 2); gr.MoveTo(x, y + radius); gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); gr.LineTo(x + width - radius, y); gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); gr.LineTo(x + width, y + height - radius); gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); gr.LineTo(x + radius, y + height); gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); gr.ClosePath(); gr.Restore(); gr.LineJoin = LineJoin.Round; gr.Color = borderColor; gr.StrokePreserve(); gr.Color = color; gr.Fill(); }
public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "") { float widthRatio = 1f; float heightRatio = 1f; if (Scaled){ widthRatio = (float)rect.Width / Dimensions.Width; heightRatio = (float)rect.Height / Dimensions.Height; } if (KeepProportions) { if (widthRatio < heightRatio) heightRatio = widthRatio; else widthRatio = heightRatio; } gr.Save (); gr.Translate (rect.Left,rect.Top); gr.Scale (widthRatio, heightRatio); gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2); using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32, Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) { gr.SetSourceSurface (imgSurf, 0,0); gr.Paint (); } gr.Restore (); }
protected override void onDraw(Cairo.Context gr) { Rectangle rBack = new Rectangle (Slot.Size); //rBack.Inflate (-Margin); // if (BorderWidth > 0) // rBack.Inflate (-BorderWidth / 2); Background.SetAsSource (gr, rBack); CairoHelpers.CairoRectangle(gr, rBack, CornerRadius); gr.Fill (); if (BorderWidth > 0) { Foreground.SetAsSource (gr, rBack); CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth); } gr.Save (); if (ClipToClientRect) { //clip to client zone CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin)); gr.Clip (); } if (child != null) child.Paint (ref gr); gr.Restore (); }
public void Render(Cairo.Context c, MonoReports.Model.Controls.Control control) { Section section = control as Section; Rectangle borderRect; c.Save (); borderRect = new Rectangle (section.Location.X * unitMulitipier , section.Location.Y * unitMulitipier , section.Width * unitMulitipier, section.Height * unitMulitipier); c.FillRectangle (borderRect, section.BackgroundColor.ToCairoColor()); c.Restore (); }
public static void RenderLine(Cairo.Context g, Cairo.Color c, double lw, double x0, double y0, double x1, double y1) { g.Save(); g.Color = c; g.LineWidth = 3; g.MoveTo(x0, y0); g.LineTo(x1, y1); g.Stroke(); g.Restore(); }
/// <summary> /// The draw curved rectangle. /// </summary> protected void DrawCurvedRectangle(Cairo.Context gr, double x, double y, double width, double height) { gr.Save(); gr.MoveTo(x, y + height / 2); gr.CurveTo(x, y, x, y, x + width / 2, y); gr.CurveTo(x + width, y, x + width, y, x + width, y + height / 2); gr.CurveTo(x + width, y + height, x + width, y + height, x + width / 2, y + height); gr.CurveTo(x, y + height, x, y + height, x, y + height / 2); gr.Restore(); }
static void DrawCurvedRectangle(Cairo.Context gr, int x, int y, int width, int height) { gr.Save (); gr.MoveTo (x, y + height / 2); gr.CurveTo (x, y, x, y, x + width / 2, y); gr.CurveTo (x + width, y, x + width, y, x + width, y + height / 2); gr.CurveTo (x + width, y + height, x + width, y + height, x + width / 2, y + height); gr.CurveTo (x, y + height, x, y + height, x, y + height / 2); gr.Restore (); }
protected override bool OnDrawn(Cairo.Context cr) { cr.Save (); Gdk.RGBA color = Hyena.Gui.GtkUtilities.ColorBlend ( StyleContext.GetBackgroundColor (StateFlags.Normal), StyleContext.GetColor (StateFlags.Normal)); cr.SetSourceRGBA (color.Red, color.Green, color.Blue, color.Alpha); DrawCairo (cr); cr.Restore (); return false; }
public void Render(Cairo.Context c, MonoReports.Model.Controls.Control control) { SubReport subreport = control as SubReport; Rectangle borderRect; c.Save (); borderRect = new Rectangle (subreport.Location.X, subreport.Location.Y, subreport.Width, subreport.Height); c.ClipRectangle (borderRect); borderRect = new Rectangle (subreport.Location.X, subreport.Location.Y, subreport.Width, subreport.Height); c.FillRectangle (borderRect, subreport.BackgroundColor.ToCairoColor ()); c.Restore (); }
public static void RenderCircle(Cairo.Context g, Cairo.Color c, double r, double x, double y) { g.Save(); g.Color = c; g.MoveTo(x, y); g.Arc(x, y, r, 0, 6.28); g.LineWidth = 3; g.ClosePath(); g.Fill(); g.Restore(); }
public override void Draw(Cairo.Context cr) { cr.Save(); cr.Color = new Color(1.0, 1.0, 1.0); cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0); cr.Fill(); cr.Color = new Color(0.0, 0.0, 0.0); cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0); cr.Stroke(); cr.Restore(); }
public static void RenderInvertedTriangle(Cairo.Context g, Cairo.Color c, double x, double y, int side) { g.Save(); g.Color = c; g.MoveTo(x, y); g.LineTo(x - side / 2, y - side); g.LineTo(x + side / 2, y - side); g.LineTo(x, y); g.Fill(); g.Restore(); }
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y) { g.Save(); g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING); g.Color = Colors.BLACK; g.ShowText(text); g.MoveTo(x, y); g.Color = c; g.ShowText(text); g.Restore(); }
void IIconBarMarker.DrawIcon (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height) { cr.Save (); cr.Translate ( x + 0.5 + (width - cache.errorPixbuf.Width) / 2, y + 0.5 + (height - cache.errorPixbuf.Height) / 2 ); Gdk.CairoHelper.SetSourcePixbuf ( cr, errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0); cr.Paint (); cr.Restore (); }
public override void Draw (Cairo.Context context, IDrawingView view) { context.Save(); base.Draw(context, view); context.LineWidth = 1.0; if (Active) { DrawOn(context, view); } else { DrawOff(context, view); } context.Restore(); }
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y, string font, int point) { g.Save(); g.SelectFontFace(font, FontSlant.Normal, FontWeight.Normal); g.SetFontSize(point); g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING); g.Color = Colors.BLACK; g.ShowText(text); g.MoveTo(x, y); g.Color = c; g.ShowText(text); g.Restore(); }
public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity) { cr.Save (); cr.Translate (rect.X, rect.Y); var x = rect.Width / 2.0; var y = rect.Height / 2.0; 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 (); }
static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius) { gr.Save (); if ((radius > height / 2) || (radius > width / 2)) radius = min (height / 2, width / 2); gr.Color = new Color (200, 10, 210, 1); gr.MoveTo (x, y + radius); gr.Arc (x + radius, y + radius, radius, Math.PI, -Math.PI / 2); gr.LineTo (x + width - radius, y); gr.Arc (x + width - radius, y + radius, radius, -Math.PI / 2, 0); gr.LineTo (x + width, y + height - radius); gr.Arc (x + width - radius, y + height - radius, radius, 0, Math.PI / 2); gr.LineTo (x + radius, y + height); gr.Arc (x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); gr.ClosePath (); gr.Restore (); }
// Used by the workspace drawing area expose render loop. // Takes care of the clipping. public void RenderLivePreviewLayer (Cairo.Context ctx, double opacity) { if (!IsEnabled) throw new InvalidOperationException ("Tried to render a live preview after live preview has ended."); // TODO remove seam around selection during live preview. ctx.Save (); if (selection_path != null) { // Paint area outsize of the selection path, with the pre-effect image. var imageSize = PintaCore.Workspace.ImageSize; ctx.Rectangle (0, 0, imageSize.Width, imageSize.Height); ctx.AppendPath (selection_path); ctx.Clip (); layer.Draw(ctx, layer.Surface, opacity); ctx.ResetClip (); // Paint area inside the selection path, with the post-effect image. ctx.AppendPath (selection_path); ctx.Clip (); layer.Draw(ctx, live_preview_surface, opacity); ctx.PaintWithAlpha (opacity); ctx.AppendPath (selection_path); ctx.FillRule = Cairo.FillRule.EvenOdd; ctx.Clip (); } else { layer.Draw(ctx, live_preview_surface, opacity); } ctx.Restore (); }
protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g) { g.Rectangle (0, 0, Allocation.Width, Allocation.Height); g.Color = marker.LineColor.SecondColor; g.Fill (); double y = 8; double x = 4; foreach (var layout in marker.Layouts) { g.Save (); g.Translate (x, y); g.Color = marker.TagColor.SecondColor; g.ShowLayout (layout.Layout); g.Restore (); y += layout.Height; } }
public override void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics layout, int startOffset, int endOffset) { if (DebuggingService.IsDebugging) return; int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double drawFrom; double drawTo; double y = layout.LineYRenderStartPosition; double startXPos = layout.TextRenderStartPosition; double endXPos = layout.TextRenderEndPosition; if (markerStart < startOffset && endOffset < markerEnd) { drawTo = endXPos; var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; drawFrom = startXPos + (layout.Layout.Layout.IndexToPos (offset).X / Pango.Scale.PangoScale); } else { int start; if (startOffset < markerStart) { start = markerStart; } else { var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; start = startOffset + offset; } int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos; x_pos = layout.Layout.Layout.IndexToPos (start - startOffset).X; drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.Layout.Layout.IndexToPos (end - startOffset).X; drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } drawFrom = Math.Max (drawFrom, editor.TextViewMargin.XOffset); drawTo = Math.Max (drawTo, editor.TextViewMargin.XOffset); if (drawFrom >= drawTo) return; double height = editor.LineHeight / 5; cr.SetSourceColor (color); if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine) { Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height); } else if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine) { cr.Save (); cr.LineWidth = 1; cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5); cr.RelLineTo (Math.Min (drawTo - drawFrom, 4 * 3), 0); cr.SetDash (new double[] { 2, 2 }, 0); cr.Stroke (); cr.Restore (); } else { cr.MoveTo (drawFrom, y + editor.LineHeight - 1); cr.LineTo (drawTo, y + editor.LineHeight - 1); cr.Stroke (); } }
public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics) { cr.Save (); cr.Translate ( metrics.X + 0.5 + (metrics.Width - 2 - cache.errorPixbuf.Width) / 2, metrics.Y + 0.5 + (metrics.Height - cache.errorPixbuf.Height) / 2 ); Gdk.CairoHelper.SetSourcePixbuf ( cr, errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0); cr.Paint (); cr.Restore (); }
public override void DrawAfterEol (TextEditor textEditor, Cairo.Context g, double y, 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; int ex = 0 , ey = 0; bool customLayout = true; //sx + width > editor.Allocation.Width; bool hideText = false; bubbleIsReduced = customLayout; var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null; 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 (17, errorCounterWidth) + editor.LineHeight; if (paintWidth < minWidth) { hideText = true; drawLayout.SetMarkup ("<span weight='heavy'>ยทยทยท</span>"); width = minWidth; showErrorCount = false; 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; } } bubbleDrawX = sx - editor.TextViewMargin.XOffset; bubbleDrawY = y; bubbleWidth = width; var bubbleHeight = editor.LineHeight - 1; g.RoundedRectangle (sx, y + 1, width, bubbleHeight, editor.LineHeight / 2 - 1); g.SetSourceColor (TagColor.Color); g.Fill (); // Draw error count icon if (showErrorCount) { var errorCounterHeight = bubbleHeight - 2; var errorCounterX = sx + width - errorCounterWidth - 3; var errorCounterY = y + 1 + (bubbleHeight - errorCounterHeight) / 2; g.RoundedRectangle ( errorCounterX - 1, errorCounterY - 1, errorCounterWidth + 2, errorCounterHeight + 2, editor.LineHeight / 2 - 3 ); g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.081)); g.Fill (); g.RoundedRectangle ( errorCounterX, errorCounterY, errorCounterWidth, errorCounterHeight, editor.LineHeight / 2 - 3 ); 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.Pattern = lg; g.Fill (); } g.Save (); int ew; errorCountLayout.GetPixelSize (out ew, out eh); g.Translate ( errorCounterX + (errorCounterWidth - ew) / 2, errorCounterY + (errorCounterHeight - eh) / 2 ); g.SetSourceColor (CounterColor.SecondColor); g.ShowLayout (errorCountLayout); g.Restore (); } // Draw label text if (!showErrorCount || !hideText) { g.Save (); g.Translate (sx + editor.LineHeight / 2, y + (editor.LineHeight - layouts [0].Height) / 2 + 1); // draw shadow g.SetSourceColor (MessageBubbleCache.ShadowColor); g.ShowLayout (drawLayout); g.Translate (0, -1); g.SetSourceColor (TagColor.SecondColor); g.ShowLayout (drawLayout); g.Restore (); } if (customLayout) drawLayout.Dispose (); }
void DrawString (string text, bool isMarkup, Cairo.Context context, int x, int y, int width, double opacity, Pango.Context pango, StatusArea.RenderArg arg) { Pango.Layout pl = new Pango.Layout (pango); if (isMarkup) pl.SetMarkup (text); else pl.SetText (text); pl.FontDescription = Styles.StatusFont; pl.FontDescription.AbsoluteSize = Pango.Units.FromPixels (Styles.StatusFontPixelHeight); pl.Ellipsize = Pango.EllipsizeMode.End; pl.Width = Pango.Units.FromPixels(width); int w, h; pl.GetPixelSize (out w, out h); context.Save (); // use widget height instead of message box height as message box does not have a true height when no widgets are packed in it // also ensures animations work properly instead of getting clipped context.Rectangle (new Rectangle (x, arg.Allocation.Y, width, arg.Allocation.Height)); context.Clip (); // Subtract off remainder instead of drop to prefer higher centering when centering an odd number of pixels context.MoveTo (x, y - h / 2 - (h % 2)); context.Color = Styles.WithAlpha (FontColor (), opacity); Pango.CairoHelper.ShowLayout (context, pl); pl.Dispose (); context.Restore (); }
private static unsafe void Renderer() { int tmp_mouse_X, tmp_mouse_Y; int old_mouse_X = -1, old_mouse_Y = -1; bool update; while (true) { tmp_mouse_X = Mouse_X; tmp_mouse_Y = Mouse_Y; update = false; Cairo.Save(MainContext); Cairo.Save(VideoContext); if (tmp_mouse_X != old_mouse_X || tmp_mouse_Y != old_mouse_Y) { update = true; Cairo.Rectangle(32, 32, old_mouse_Y, old_mouse_X, MainContext); Cairo.Rectangle(32, 32, old_mouse_Y, old_mouse_X, VideoContext); Cairo.Rectangle(32, 32, tmp_mouse_Y, tmp_mouse_X, VideoContext); } old_mouse_X = tmp_mouse_X; old_mouse_Y = tmp_mouse_Y; var queue = RedrawRects; Monitor.AcquireLock(ref RedrawRectsLock); while (queue.Count > 0) { var rect = (Rect *)queue.Dequeue(); Cairo.Rectangle(rect->Height, rect->Width, rect->Y, rect->X, MainContext); Cairo.Rectangle(rect->Height, rect->Width, rect->Y, rect->X, VideoContext); Libc.free((uint)rect); update = true; } Monitor.ReleaseLock(ref RedrawRectsLock); if (update) { Cairo.Clip(MainContext); var list = Stacking; Monitor.AcquireLock(ref StackingLock); int count = list.Count; for (int index = 0; index < count; index++) { var win = list[index]; Cairo.Save(MainContext); Cairo.Translate(win.Y, win.X, MainContext); Cairo.SetSourceSurface(0, 0, win.Surface, MainContext); Cairo.Paint(MainContext); Cairo.Restore(MainContext); } Monitor.ReleaseLock(ref StackingLock); } if (update) { Cairo.Clip(VideoContext); Cairo.Translate(0, 0, VideoContext); Cairo.SetOperator(Operator.Source, VideoContext); Cairo.SetSourceSurface(0, 0, MainSurface, VideoContext); Cairo.Paint(VideoContext); Cairo.Translate(old_mouse_Y, old_mouse_X, VideoContext); Cairo.SetOperator(Operator.Over, VideoContext); Cairo.SetSourceSurface(0, 0, MouseSurface, VideoContext); Cairo.Paint(VideoContext); } Cairo.Restore(MainContext); Cairo.Restore(VideoContext); Task.Switch(); } }
void DrawBuildEffect (Cairo.Context context, Gdk.Rectangle area, double progress, double opacity) { context.Save (); LayoutRoundedRectangle (context, area); context.Clip (); Gdk.Point center = new Gdk.Point (area.Left + 19, (area.Top + area.Bottom) / 2); context.Translate (center.X, center.Y); var circles = new [] { new { Radius = 200, Thickness = 12, Speed = 1, ArcLength = Math.PI * 1.50 }, new { Radius = 195, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 240, Thickness = 12, Speed = 3, ArcLength = Math.PI * 1.50 }, new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 }, new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 }, new { Radius = 215, Thickness = 20, Speed = 2, ArcLength = Math.PI * 1.25 } }; double zmod = 1.0d; double zporg = progress; foreach (var arc in circles) { double zoom = 1.0d; zoom = (double) Math.Sin (zporg * Math.PI * 2 + zmod); zoom = ((zoom + 1) / 6.0d) + .05d; context.Rotate (Math.PI * 2 * progress * arc.Speed); context.MoveTo (arc.Radius * zoom, 0); context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.Color = CairoExtensions.ParseColor ("B1DDED", 0.35 * opacity); context.Stroke (); context.Rotate (Math.PI * 2 * -progress * arc.Speed); progress = -progress; context.Rotate (Math.PI * 2 * progress * arc.Speed); context.MoveTo (arc.Radius * zoom, 0); context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength); context.LineWidth = arc.Thickness * zoom; context.Stroke (); context.Rotate (Math.PI * 2 * -progress * arc.Speed); progress = -progress; zmod += (float)Math.PI / circles.Length; } context.LineWidth = 1; context.ResetClip (); context.Restore (); }
protected virtual void DrawBackground (Cairo.Context context, Gdk.Rectangle region) { LayoutRoundedRectangle (context, region); context.ClipPreserve (); using (LinearGradient lg = new LinearGradient (region.X, region.Y, region.X, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarFill1Color); lg.AddColorStop (1, Styles.StatusBarFill4Color); context.Pattern = lg; context.FillPreserve (); } context.Save (); double midX = region.X + region.Width / 2.0; double midY = region.Y + region.Height; context.Translate (midX, midY); using (RadialGradient rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) { rg.AddColorStop (0, Styles.StatusBarFill1Color); rg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarFill1Color, 0)); context.Scale (region.Width / (double)region.Height, 1.0); context.Pattern = rg; context.Fill (); } context.Restore (); using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarShadowColor1); lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2)); LayoutRoundedRectangle (context, region, 0, -1); context.LineWidth = 1; context.Pattern = lg; context.Stroke (); } using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarShadowColor2); lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2)); LayoutRoundedRectangle (context, region, 0, -2); context.LineWidth = 1; context.Pattern = lg; context.Stroke (); } context.ResetClip (); }
public void Draw(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged) { if (!_visible) { return; } if (_w > 0 && _h > 0) { Gdk.GC gc = new Gdk.GC(d); d.DrawPixbuf(gc, _background, 0, 0, _x, _y, _w, _h, Gdk.RgbDither.None, 0, 0); int x0 = _x, x1 = _x + _w; int y0 = _y, y1 = _y + _h; g.MoveTo(x0 + 3, y0); g.LineTo(x1 - 3, y0); g.LineTo(x1, y0 + 3); g.LineTo(x1, y1 - 3); g.LineTo(x1 - 3, y1); g.LineTo(x0 + 3, y1); g.LineTo(x0, y1 - 3); g.LineTo(x0, y0 + 3); g.LineTo(x0 + 3, y0); g.ClosePath(); g.LineWidth = 6; g.Color = BorderColor; g.Stroke(); } g.Save(); DrawContents(d, g, width, height, screenChanged); g.Restore(); }
protected override void onDraw(Cairo.Context gr) { gr.Save (); int spacing = (Parent as TabView).Spacing; gr.MoveTo (0.5, TabTitle.Slot.Bottom-0.5); gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom-0.5); gr.CurveTo ( TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom-0.5, TabTitle.Slot.Left - spacing / 2, 0.5, TabTitle.Slot.Left, 0.5); gr.LineTo (TabTitle.Slot.Right, 0.5); gr.CurveTo ( TabTitle.Slot.Right + spacing / 2, 0.5, TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom-0.5, TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom-0.5); gr.LineTo (Slot.Width-0.5, TabTitle.Slot.Bottom-0.5); gr.LineTo (Slot.Width-0.5, Slot.Height-0.5); gr.LineTo (0.5, Slot.Height-0.5); gr.ClosePath (); gr.LineWidth = 2; Foreground.SetAsSource (gr); gr.StrokePreserve (); gr.Clip (); base.onDraw (gr); gr.Restore (); }
protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g) { g.Rectangle (0, 0, Allocation.Width, Allocation.Height); g.SetSourceColor (marker.TooltipColor.Color); g.Fill (); using (var drawingLayout = new Pango.Layout (this.PangoContext)) { drawingLayout.FontDescription = cache.tooltipFontDescription; double y = verticalTextBorder; var showBulletedList = marker.Errors.Count > 1; foreach (var msg in marker.Errors) { var icon = msg.IsError ? errorPixbuf : warningPixbuf; int w, h; if (!showBulletedList) drawingLayout.Width = maxTextWidth; drawingLayout.SetText (GetFirstLine (msg)); drawingLayout.GetPixelSize (out w, out h); if (showBulletedList) { g.Save (); g.Translate (textBorder, y + verticalTextSpace / 2 + Math.Max (0, (h - icon.Height) / 2)); g.DrawImage (this, icon, 0, 0); g.Restore (); } g.Save (); g.Translate (showBulletedList ? textBorder + iconTextSpacing + icon.Width: textBorder, y + verticalTextSpace / 2); g.SetSourceColor (marker.TagColor.SecondColor); g.ShowLayout (drawingLayout); g.Restore (); y += h + verticalTextSpace; } } }