void RenderLineNumberIcon(Widget widget, Cairo.Context cr, Gdk.Rectangle cell_area, int markupHeight, int yOffset) { if (!IsStackFrame) { return; } cr.Save(); #if CENTER_ROUNDED_RECTANGLE cr.Translate(cell_area.X + Padding, (cell_area.Y + (cell_area.Height - RoundedRectangleHeight) / 2.0)); #else cr.Translate(cell_area.X + Padding, cell_area.Y + Padding + yOffset); #endif cr.Antialias = Cairo.Antialias.Subpixel; cr.RoundedRectangle(0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); cr.Clip(); if (IsUserCode) { cr.SetSourceRGBA(0.90, 0.60, 0.87, 1.0); // 230, 152, 223 } else { cr.SetSourceRGBA(0.77, 0.77, 0.77, 1.0); // 197, 197, 197 } cr.RoundedRectangle(0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); cr.Fill(); cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.11); cr.RoundedRectangle(0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); cr.LineWidth = 2; cr.Stroke(); using (var layout = PangoUtil.CreateLayout(widget, LineNumber != -1 ? LineNumber.ToString() : "???")) { layout.Alignment = Pango.Alignment.Left; layout.FontDescription = LineNumberFont; int width, height; layout.GetPixelSize(out width, out height); double y_offset = (RoundedRectangleHeight - height) / 2.0; double x_offset = (RoundedRectangleWidth - width) / 2.0; // render the text shadow cr.Save(); cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.34); cr.Translate(x_offset, y_offset + 1); cr.ShowLayout(layout); cr.Restore(); cr.SetSourceRGBA(1.0, 1.0, 1.0, 1.0); cr.Translate(x_offset, y_offset); cr.ShowLayout(layout); } cr.Restore(); }
void RenderLineNumberIcon(Widget widget, Cairo.Context cr, Gdk.Rectangle cell_area, int markupHeight, int yOffset) { if (Frame == null) { return; } cr.Save(); #if CENTER_ROUNDED_RECTANGLE cr.Translate(cell_area.X + Padding, (cell_area.Y + (cell_area.Height - RoundedRectangleHeight) / 2.0)); #else cr.Translate(cell_area.X + Padding, cell_area.Y + Padding + yOffset); #endif cr.Antialias = Cairo.Antialias.Subpixel; cr.RoundedRectangle(0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); cr.Clip(); if (IsUserCode) { cr.SetSourceColor(Styles.ExceptionCaughtDialog.LineNumberInUserCodeBackgroundColor.ToCairoColor()); // 230, 152, 223 } else { cr.SetSourceColor(Styles.ExceptionCaughtDialog.LineNumberBackgroundColor.ToCairoColor()); // 197, 197, 197 } cr.RoundedRectangle(0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); cr.Fill(); var lineNumber = !string.IsNullOrEmpty(Frame.File) ? Frame.Line : -1; using (var layout = PangoUtil.CreateLayout(widget, lineNumber != -1 ? lineNumber.ToString() : "???")) { layout.Alignment = Pango.Alignment.Left; layout.FontDescription = LineNumberFont; int width, height; layout.GetPixelSize(out width, out height); double y_offset = (RoundedRectangleHeight - height) / 2.0; double x_offset = (RoundedRectangleWidth - width) / 2.0; cr.SetSourceColor(Styles.ExceptionCaughtDialog.LineNumberTextColor.ToCairoColor()); cr.Translate(x_offset, y_offset); cr.ShowLayout(layout); } cr.Restore(); }
public override void DrawBackground(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { this.editor = editor; int markerStart = base.Offset; int markerEnd = base.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) { return; } double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max(@from, editor.TextViewMargin.XOffset); to = Math.Max(to, editor.TextViewMargin.XOffset); if (@from < to) { cr.SetSourceColor(background(editor).Color); cr.RoundedRectangle(@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2); // 2.5 to make space for the column guideline if (background(editor).HasBorderColor) { cr.FillPreserve(); cr.SetSourceColor(background(editor).BorderColor); cr.Stroke(); } else { cr.Fill(); } } }
public override bool DrawBackground(TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics) { // check, if a message bubble is active in that line. if (LineSegment != null && LineSegment.Markers.Any(m => m != this && (m is IExtendingTextLineMarker))) { return(false); } var sidePadding = 4; var rounding = editor.LineHeight / 2 - 1; var d = metrics.TextRenderEndPosition - metrics.TextRenderStartPosition; if (d > 0) { cr.LineWidth = 1; cr.RoundedRectangle(metrics.TextRenderStartPosition, Math.Floor(y) + 0.5, d + sidePadding, metrics.LineHeight - 1, rounding); cr.SetSourceColor(BackgroundColor); cr.FillPreserve(); cr.SetSourceColor(BorderColor); cr.Stroke(); } return(base.DrawBackground(editor, cr, y, metrics)); }
protected override bool OnExposeEvent(EventExpose evnt) { Gdk.Rectangle rectangle = new Gdk.Rectangle(this.alignment.Allocation.X, this.box.Allocation.Y, this.alignment.Allocation.Width, this.box.Allocation.Height); if (this.hasFrame && (!this.roundedShape || this.roundedShape && !this.customRoundedShapeDrawing)) { Gtk.Style.PaintShadow(this.entry.Style, (Drawable)this.GdkWindow, StateType.Normal, ShadowType.In, evnt.Area, (Widget)this.entry, "entry", rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } else if (!this.roundedShape) { using (Cairo.Context cr = Gdk.CairoHelper.Create((Drawable)this.GdkWindow)) { cr.RoundedRectangle((double)rectangle.X + 0.5, (double)rectangle.Y + 0.5, (double)(rectangle.Width - 1), (double)(rectangle.Height - 1), 4.0); HelperMethods.SetSourceColor(cr, this.entry.Style.Base(StateType.Normal).ToCairoColor()); cr.Fill(); } } else { using (Cairo.Context context = Gdk.CairoHelper.Create((Drawable)this.GdkWindow)) { SearchEntry.RoundBorder(context, (double)rectangle.X + 0.5, (double)rectangle.Y + 0.5, (double)(rectangle.Width - 1), (double)(rectangle.Height - 1)); HelperMethods.SetSourceColor(context, this.entry.Style.Base(StateType.Normal).ToCairoColor()); context.Fill(); } } this.PropagateExpose(this.Child, evnt); if (this.hasFrame && this.roundedShape && this.customRoundedShapeDrawing) { using (Cairo.Context context = Gdk.CairoHelper.Create((Drawable)this.GdkWindow)) { SearchEntry.RoundBorder(context, (double)rectangle.X + 0.5, (double)rectangle.Y + 0.5, (double)(rectangle.Width - 1), (double)(rectangle.Height - 1)); HelperMethods.SetSourceColor(context, Styles.WidgetBorderColor); context.LineWidth = 1.0; context.Stroke(); } } return(true); }
protected virtual void DrawHoverBackground(Cairo.Context ctx) { if (BorderPadding <= 0) { ctx.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBackgroundColor)); ctx.Fill(); ctx.MoveTo(Allocation.X, Allocation.Y + 0.5); ctx.RelLineTo(Allocation.Width, 0); ctx.MoveTo(Allocation.X, Allocation.Y + Allocation.Height - 0.5); ctx.RelLineTo(Allocation.Width, 0); if (DrawRightBorder) { ctx.MoveTo(Allocation.Right + 0.5, Allocation.Y + 0.5); ctx.LineTo(Allocation.Right + 0.5, Allocation.Bottom - 0.5); } if (DrawLeftBorder) { ctx.MoveTo(Allocation.Left + 0.5, Allocation.Y + 0.5); ctx.LineTo(Allocation.Left + 0.5, Allocation.Bottom - 0.5); } ctx.LineWidth = 1; ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBorderColor)); ctx.Stroke(); } else { Gdk.Rectangle region = Allocation; region.Inflate(-BorderPadding, -BorderPadding); ctx.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3); ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBackgroundColor)); ctx.FillPreserve(); ctx.LineWidth = 1; ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBorderColor)); ctx.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 ); // FIXME: VV: Remove gradient features 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(); } }
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); } } 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(); } }
public override void DrawAfterEol(TextEditor textEditor, Cairo.Context g, double y, EndOfLineMetrics metrics) { EnsureLayoutCreated(editor); int errorCounterWidth = 0, eh = 0; if (errorCountLayout != null) { errorCountLayout.GetPixelSize(out errorCounterWidth, out eh); errorCounterWidth = 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 = sx + width > editor.Allocation.Width; bool hideText = false; bubbleIsReduced = customLayout; if (customLayout) { width = editor.Allocation.Width - sx; string text = layouts[0].Layout.Text; drawLayout = new Pango.Layout(editor.PangoContext); drawLayout.FontDescription = cache.fontDescription; for (int j = text.Length - 4; j > 0; j--) { drawLayout.SetText(text.Substring(0, j) + "..."); drawLayout.GetPixelSize(out ex, out ey); if (ex + (errorCountLayout != null ? errorCounterWidth : 0) + editor.LineHeight < width) { break; } } if (ex + (errorCountLayout != null ? errorCounterWidth : 0) + editor.LineHeight > width) { hideText = true; drawLayout.SetMarkup("<span weight='heavy'>···</span>"); width = Math.Max(17, errorCounterWidth) + editor.LineHeight; sx = Math.Min(sx, editor.Allocation.Width - width); } } bubbleDrawX = sx - editor.TextViewMargin.XOffset; bubbleDrawY = y; bubbleWidth = width; g.RoundedRectangle(sx, y + 1, width, editor.LineHeight - 2, editor.LineHeight / 2 - 1); g.SetSourceColor(TagColor.Color); g.Fill(); if (errorCounterWidth > 0 && errorCountLayout != null) { g.RoundedRectangle(sx + width - errorCounterWidth - editor.LineHeight / 2, y + 2, errorCounterWidth, editor.LineHeight - 4, editor.LineHeight / 2 - 3); g.SetSourceColor(CounterColor.Color); g.Fill(); g.Save(); int ew; errorCountLayout.GetPixelSize(out ew, out eh); g.Translate(sx + width - errorCounterWidth - editor.LineHeight / 2 + (errorCounterWidth - ew) / 2, y + 1); g.SetSourceColor(CounterColor.SecondColor); g.ShowLayout(errorCountLayout); g.Restore(); } if (errorCounterWidth <= 0 || errorCountLayout == null || !hideText) { g.Save(); g.Translate(sx + editor.LineHeight / 2, y + (editor.LineHeight - layouts [0].Height) / 2 + layouts [0].Height % 2); g.SetSourceColor(TagColor.SecondColor); g.ShowLayout(drawLayout); g.Restore(); } if (customLayout) { drawLayout.Dispose(); } }