diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2013-08-21 12:20:47 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2013-08-21 12:20:47 +0400 |
commit | 9b1c783d9794fc4a153e9891e7144146c62a33e4 (patch) | |
tree | edfdec9dfd5c2bd758c2d1c85ddf58d2a720e55a /main/src | |
parent | 4231d11d3849865f637f3869af920dd7945924ed (diff) |
[SourceEditor] Improved message bubble theming.
Diffstat (limited to 'main/src')
11 files changed, 164 insertions, 29 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 (); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs index c02a9c43c7..1a50ca254f 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs @@ -164,6 +164,9 @@ namespace Mono.TextEditor.Highlighting [ColorDescription("Message Bubble Error Tag")] public AmbientColor MessageBubbleErrorTag { get; private set; } + [ColorDescription("Message Bubble Error Tooltip")] + public AmbientColor MessageBubbleErrorTooltip { get; private set; } + [ColorDescription("Message Bubble Error Line")] public AmbientColor MessageBubbleErrorLine { get; private set; } @@ -179,6 +182,9 @@ namespace Mono.TextEditor.Highlighting [ColorDescription("Message Bubble Warning Tag")] public AmbientColor MessageBubbleWarningTag { get; private set; } + [ColorDescription("Message Bubble Warning Tooltip")] + public AmbientColor MessageBubbleWarningTooltip { get; private set; } + [ColorDescription("Message Bubble Warning Line")] public AmbientColor MessageBubbleWarningLine { get; private set; } diff --git a/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json b/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json index 70b14e8adb..154471f193 100644 --- a/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json @@ -92,12 +92,14 @@ { "name": "Message Bubble Error Counter", "color":"white", "secondcolor":"#d83f3f"}, { "name": "Message Bubble Error IconMargin", "color":"#d83f3f", "bordercolor":"#b12a2a"}, { "name": "Message Bubble Error Line", "color":"#fbe4e6"}, + { "name": "Message Bubble Error Tooltip", "color":"#d11b1b"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#e68100", "secondcolor":"white"}, { "name": "Message Bubble Warning Counter", "color":"white", "secondcolor":"#e68100"}, { "name": "Message Bubble Warning IconMargin", "color":"#e68100", "bordercolor":"#c76f00"}, - { "name": "Message Bubble Warning Line", "color":"#fff1da"} + { "name": "Message Bubble Warning Line", "color":"#fff1da"}, + { "name": "Message Bubble Warning Tooltip", "color":"#d4641c"} ], "text":[ diff --git a/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json b/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json index ab7f364b9a..44153e8e5f 100644 --- a/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json @@ -80,12 +80,14 @@ { "name": "Message Bubble Error Counter", "color":"black", "secondcolor":"#e3a6a1"}, { "name": "Message Bubble Error IconMargin", "color":"#735c54", "bordercolor":"#805b4d"}, { "name": "Message Bubble Error Line", "color":"#7b645c"}, + { "name": "Message Bubble Error Tooltip", "color":"#e3a6a1"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#efe89d", "secondcolor":"black"}, { "name": "Message Bubble Warning Counter", "color":"black", "secondcolor":"#efe89d"}, { "name": "Message Bubble Warning IconMargin", "color":"#777553", "bordercolor":"#948e51"}, - { "name": "Message Bubble Warning Line", "color":"#807e5c"} + { "name": "Message Bubble Warning Line", "color":"#807e5c"}, + { "name": "Message Bubble Warning Tooltip", "color":"#efe89d"} ], "text":[ diff --git a/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json b/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json index 433dc63eb1..d1ac64131d 100644 --- a/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json @@ -120,12 +120,15 @@ { "name": "Message Bubble Error Counter", "color":"black", "secondcolor":"#e3a6a1"}, { "name": "Message Bubble Error IconMargin", "color":"#735c54", "bordercolor":"#805b4d"}, { "name": "Message Bubble Error Line", "color":"#7b645c"}, + { "name": "Message Bubble Error Tooltip", "color":"#e3a6a1"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#efe89d", "secondcolor":"black"}, { "name": "Message Bubble Warning Counter", "color":"black", "secondcolor":"#efe89d"}, { "name": "Message Bubble Warning IconMargin", "color":"#777553", "bordercolor":"#948e51"}, - { "name": "Message Bubble Warning Line", "color":"#807e5c"} + { "name": "Message Bubble Warning Line", "color":"#807e5c"}, + { "name": "Message Bubble Warning Tooltip", "color":"#efe89d"} + ], "text":[ diff --git a/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json b/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json index 7fb7e80358..68db281088 100644 --- a/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json @@ -95,12 +95,14 @@ { "name": "Message Bubble Error Counter", "color":"black", "secondcolor":"#e3a6a1"}, { "name": "Message Bubble Error IconMargin", "color":"#735c54", "bordercolor":"#805b4d"}, { "name": "Message Bubble Error Line", "color":"#7b645c"}, + { "name": "Message Bubble Error Tooltip", "color":"#e3a6a1"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#efe89d", "secondcolor":"black"}, { "name": "Message Bubble Warning Counter", "color":"black", "secondcolor":"#efe89d"}, { "name": "Message Bubble Warning IconMargin", "color":"#777553", "bordercolor":"#948e51"}, - { "name": "Message Bubble Warning Line", "color":"#807e5c"} + { "name": "Message Bubble Warning Line", "color":"#807e5c"}, + { "name": "Message Bubble Warning Tooltip", "color":"#efe89d"} ], "text":[ diff --git a/main/src/core/Mono.Texteditor/Styles/SolarizedDarkStyle.json b/main/src/core/Mono.Texteditor/Styles/SolarizedDarkStyle.json index 4c1b5a4792..1f7e7b1da3 100644 --- a/main/src/core/Mono.Texteditor/Styles/SolarizedDarkStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/SolarizedDarkStyle.json @@ -84,12 +84,14 @@ { "name": "Message Bubble Error Counter", "color":"black", "secondcolor":"#e3a6a1"}, { "name": "Message Bubble Error IconMargin", "color":"#735c54", "bordercolor":"#805b4d"}, { "name": "Message Bubble Error Line", "color":"#7b645c"}, + { "name": "Message Bubble Error Tooltip", "color":"#e3a6a1"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#efe89d", "secondcolor":"black"}, { "name": "Message Bubble Warning Counter", "color":"black", "secondcolor":"#efe89d"}, { "name": "Message Bubble Warning IconMargin", "color":"#777553", "bordercolor":"#948e51"}, - { "name": "Message Bubble Warning Line", "color":"#807e5c"} + { "name": "Message Bubble Warning Line", "color":"#807e5c"}, + { "name": "Message Bubble Warning Tooltip", "color":"#efe89d"} ], "text":[ diff --git a/main/src/core/Mono.Texteditor/Styles/SolarizedLightStyle.json b/main/src/core/Mono.Texteditor/Styles/SolarizedLightStyle.json index 14c9b4aa97..0ffd992dd9 100644 --- a/main/src/core/Mono.Texteditor/Styles/SolarizedLightStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/SolarizedLightStyle.json @@ -84,12 +84,14 @@ { "name": "Message Bubble Error Counter", "color":"black", "secondcolor":"#e3a6a1"}, { "name": "Message Bubble Error IconMargin", "color":"#735c54", "bordercolor":"#805b4d"}, { "name": "Message Bubble Error Line", "color":"#7b645c"}, + { "name": "Message Bubble Error Tooltip", "color":"#e3a6a1"}, { "name": "Message Bubble Warning Marker", "color":"#b28d37"}, { "name": "Message Bubble Warning Tag", "color":"#efe89d", "secondcolor":"black"}, { "name": "Message Bubble Warning Counter", "color":"black", "secondcolor":"#efe89d"}, { "name": "Message Bubble Warning IconMargin", "color":"#777553", "bordercolor":"#948e51"}, - { "name": "Message Bubble Warning Line", "color":"#807e5c"} + { "name": "Message Bubble Warning Line", "color":"#807e5c"}, + { "name": "Message Bubble Warning Tooltip", "color":"#efe89d"} ], "text":[ diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs index a29e7b3418..b5f4de70e1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs @@ -315,7 +315,8 @@ namespace MonoDevelop.Components Move (x, y); Show (); - DesktopService.RemoveWindowShadow (this); + if (!ShowWindowShadow) + DesktopService.RemoveWindowShadow (this); } public bool SupportsAlpha { @@ -323,6 +324,11 @@ namespace MonoDevelop.Components private set; } + public bool ShowWindowShadow { + get; + set; + } + void CheckScreenColormap () { SupportsAlpha = Screen.IsComposited; |