Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2013-08-21 12:20:47 +0400
committerMike Krüger <mkrueger@xamarin.com>2013-08-21 12:20:47 +0400
commit9b1c783d9794fc4a153e9891e7144146c62a33e4 (patch)
treeedfdec9dfd5c2bd758c2d1c85ddf58d2a720e55a /main/src/addins
parent4231d11d3849865f637f3869af920dd7945924ed (diff)
[SourceEditor] Improved message bubble theming.
Diffstat (limited to 'main/src/addins')
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml1
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleCache.cs96
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs57
3 files changed, 132 insertions, 22 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
index d1f3430bda..1efe81dd69 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml
@@ -219,6 +219,7 @@
<Extension path = "/MonoDevelop/Ide/Fonts">
<Font name ="MessageBubbles" _displayName="Message bubbles" default ="_DEFAULT_SANS" defaultMac = "Lucida Grande 10"/>
+ <Font name ="MessageBubbleTooltip" _displayName="Message bubbles tooltip" default ="_DEFAULT_SANS" defaultMac = "Lucida Grande Bold 10"/>
<Font name ="LanguageTooltips" _displayName="Editor tooltips" default ="_DEFAULT_SANS"/>
</Extension>
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleCache.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleCache.cs
index 3bd907b994..f1055f5318 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleCache.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleCache.cs
@@ -44,6 +44,7 @@ namespace MonoDevelop.SourceEditor
internal TextEditor editor;
internal Pango.FontDescription fontDescription;
+ internal Pango.FontDescription tooltipFontDescription;
public MessageBubbleTextMarker CurrentSelectedTextMarker;
@@ -58,6 +59,7 @@ namespace MonoDevelop.SourceEditor
editor.MotionNotifyEvent += HandleMotionNotifyEvent;
editor.TextArea.BeginHover += HandleBeginHover;
fontDescription = FontService.GetFontDescription ("MessageBubbles");
+ tooltipFontDescription = FontService.GetFontDescription ("MessageBubbleTooltip");
}
void HandleMotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args)
@@ -89,17 +91,42 @@ namespace MonoDevelop.SourceEditor
this.marker = marker;
ShowArrow = true;
Opacity = 0.9;
+ Theme.ArrowLength = 7;
}
+ // Layout constants
+ const int verticalTextBorder = 10;
+ const int verticalTextSpace = 6;
+
+ const int textBorder = 12;
+ const int iconTextSpacing = 8;
+
+ readonly int maxTextWidth = (int)(260 * Pango.Scale.PangoScale);
+
protected override void OnSizeRequested (ref Gtk.Requisition requisition)
{
base.OnSizeRequested (ref requisition);
- double y = 0;
- foreach (var layout in marker.Layouts) {
- requisition.Width = Math.Max (layout.Width + 8, requisition.Width);
- y += layout.Height;
+ double y = verticalTextBorder * 2 - verticalTextSpace; // one space get's added too much
+
+ using (var drawingLayout = new Pango.Layout (this.PangoContext)) {
+ drawingLayout.FontDescription = cache.tooltipFontDescription;
+
+ foreach (var msg in marker.Errors) {
+ if (marker.Layouts.Count == 1)
+ drawingLayout.Width = maxTextWidth;
+ drawingLayout.SetText (GetFirstLine (msg));
+ int w;
+ int h;
+ drawingLayout.GetPixelSize (out w, out h);
+ if (marker.Layouts.Count > 1)
+ w += cache.warningPixbuf.Width + iconTextSpacing;
+
+ requisition.Width = Math.Max (w + textBorder * 2, requisition.Width);
+ y += h + verticalTextSpace;
+ }
}
- requisition.Height = (int)y + 12;
+
+ requisition.Height = (int)y;
}
protected override bool OnEnterNotifyEvent (Gdk.EventCrossing evnt)
@@ -110,20 +137,56 @@ namespace MonoDevelop.SourceEditor
protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g)
{
- Theme.BorderColor = marker.TagColor.Color;
+ Theme.BorderColor = marker.TooltipColor.Color;
g.Rectangle (0, 0, Allocation.Width, Allocation.Height);
- g.SetSourceColor (marker.TagColor.Color);
+ g.SetSourceColor (marker.TooltipColor.Color);
g.Fill ();
- double y = 8;
- double x = 4;
- foreach (var layout in marker.Layouts) {
- g.Save ();
- g.Translate (x, y);
- g.SetSourceColor (marker.TagColor.SecondColor);
- g.ShowLayout (layout.Layout);
- g.Restore ();
- y += layout.Height;
+ 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 ? cache.errorPixbuf : cache.warningPixbuf;
+
+ if (!showBulletedList)
+ drawingLayout.Width = maxTextWidth;
+ drawingLayout.SetText (GetFirstLine (msg));
+ int w;
+ int h;
+ drawingLayout.GetPixelSize (out w, out h);
+
+ if (showBulletedList) {
+ g.Save ();
+
+ g.Translate (
+ textBorder,
+ y + verticalTextSpace / 2
+ );
+ Gdk.CairoHelper.SetSourcePixbuf (g, icon, 0, 0);
+ g.Paint ();
+ g.Restore ();
+ }
+
+ g.Save ();
+
+ g.Translate (showBulletedList ? textBorder + iconTextSpacing + icon.Width + 1: textBorder, y + verticalTextSpace / 2 + 1);
+
+ g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.1));
+ g.ShowLayout (drawingLayout);
+
+ g.Translate (-1, -1);
+
+ g.SetSourceColor (marker.TagColor.SecondColor);
+ g.ShowLayout (drawingLayout);
+
+ g.Restore ();
+
+
+ y += h + verticalTextSpace;
+ }
}
}
@@ -146,6 +209,7 @@ namespace MonoDevelop.SourceEditor
if (marker.Layouts == null || marker.Layouts.Count < 2 && !isReduced)
return false;
popoverWindow = new MessageBubblePopoverWindow (this, marker);
+ popoverWindow.ShowWindowShadow = true;
popoverWindow.ShowPopup (editor, new Gdk.Rectangle ((int)(bubbleX + editor.TextViewMargin.XOffset), (int)bubbleY, (int)bubbleWidth, (int)editor.LineHeight) ,PopupPosition.Top);
return false;
});
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs
index 66be3b2d79..658f85af57 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs
@@ -197,6 +197,12 @@ namespace MonoDevelop.SourceEditor
}
}
+ internal AmbientColor TooltipColor {
+ get {
+ return isError ? editor.ColorStyle.MessageBubbleErrorTooltip : editor.ColorStyle.MessageBubbleWarningTooltip;
+ }
+ }
+
internal AmbientColor LineColor {
get {
return isError ? editor.ColorStyle.MessageBubbleErrorLine : editor.ColorStyle.MessageBubbleWarningLine;
@@ -362,7 +368,7 @@ namespace MonoDevelop.SourceEditor
int errorCounterWidth = 0, eh = 0;
if (errorCountLayout != null) {
errorCountLayout.GetPixelSize (out errorCounterWidth, out eh);
- errorCounterWidth = Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4));
+ errorCounterWidth = Math.Max (15, Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4)));
}
var sx = metrics.TextRenderEndPosition;
@@ -393,28 +399,67 @@ namespace MonoDevelop.SourceEditor
bubbleDrawX = sx - editor.TextViewMargin.XOffset;
bubbleDrawY = y;
bubbleWidth = width;
- g.RoundedRectangle (sx, y + 1, width, editor.LineHeight - 2, editor.LineHeight / 2 - 1);
+
+ 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 (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);
+ 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 (sx + width - errorCounterWidth - editor.LineHeight / 2 + (errorCounterWidth - ew) / 2, y + 1);
+ g.Translate (
+ errorCounterX + (errorCounterWidth - ew) / 2,
+ errorCounterY + (errorCounterHeight - eh) / 2
+ );
g.SetSourceColor (CounterColor.SecondColor);
g.ShowLayout (errorCountLayout);
g.Restore ();
}
+ // Draw label text
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.Translate (sx + editor.LineHeight / 2 + 1, y + (editor.LineHeight - layouts [0].Height) / 2 + 1);
+
+ // draw shadow
+ g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.1));
+ g.ShowLayout (drawLayout);
+ g.Translate (-1, -1);
+
g.SetSourceColor (TagColor.SecondColor);
g.ShowLayout (drawLayout);
g.Restore ();