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) { 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(); } }
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(Mono.TextEditor.TextEditor textEditor, Cairo.Context cr, double y, EndOfLineMetrics lineHeight) { using (var pango = cr.CreateLayout()) { pango.FontDescription = textEditor.Options.Font; cr.SetSourceColor(bg); pango.SetText(hits.ToString()); cr.MoveTo(lineHeight.TextRenderEndPosition, y); cr.ShowLayout(pango); } base.DrawAfterEol(textEditor, cr, y, lineHeight); }