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:
authorLluis Sanchez <llsan@microsoft.com>2019-04-04 19:39:28 +0300
committerLluis Sanchez <llsan@microsoft.com>2019-04-04 19:39:28 +0300
commitb06d9a720a565a6be32c15bed2c752e1459b61a8 (patch)
treef080a3a29f2f80d4670b3514d221cb4ecb970dc9 /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView
parent93a6afefc0d8bb6b9bbdced179ee8eed2adec6d7 (diff)
parenta38d6ef3c1aacb3c783d3d12d6ab0a8dc2eb85db (diff)
Merge branch 'new-service-model' into new-doc-model
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView')
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs94
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtProvider.cs31
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Glyphs/BreakpointGlyphMouseProcessor.cs5
3 files changed, 99 insertions, 31 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs
index e6a218a605..8977d8e830 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtAdornmentManager.cs
@@ -1,13 +1,31 @@
-#if !WINDOWS
+//
+// Copyright (c) Microsoft Corp. (https://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
using System;
using AppKit;
using CoreGraphics;
using Foundation;
using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Text.Editor;
-using Microsoft.VisualStudio.UI;
-using Microsoft.VisualStudio.UI.Controls;
using Mono.Debugging.Client;
using MonoDevelop.Components;
using MonoDevelop.Components.Mac;
@@ -20,19 +38,24 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
{
public class ExceptionCaughtAdornmentManager : IDisposable
{
+ readonly ICocoaViewFactory cocoaViewFactory;
readonly ICocoaTextView textView;
private readonly string filePath;
readonly IXPlatAdornmentLayer _exceptionCaughtLayer;
FileLineExtension extension;
- public ExceptionCaughtAdornmentManager (ICocoaTextView textView)
+ public ExceptionCaughtAdornmentManager (ICocoaViewFactory cocoaViewFactory, ICocoaTextView textView)
{
filePath = textView.TextBuffer.GetFilePathOrNull ();
if (filePath == null)
return;
+
IdeServices.TextEditorService.FileExtensionAdded += FileExtensionAdded;
IdeServices.TextEditorService.FileExtensionRemoved += FileExtensionRemoved;
_exceptionCaughtLayer = textView.GetXPlatAdornmentLayer ("ExceptionCaught");
+
+ this.cocoaViewFactory = cocoaViewFactory;
+
this.textView = textView;
this.textView.LayoutChanged += TextView_LayoutChanged;
@@ -59,9 +82,9 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
{
NSView view;
if (fileLineExtension is ExceptionCaughtButton button)
- view = CreateButton (button);
+ view = CreateButton (cocoaViewFactory, button);
else if (fileLineExtension is ExceptionCaughtMiniButton miniButton)
- view = CreateMiniButton (miniButton);
+ view = CreateMiniButton (cocoaViewFactory, miniButton);
else
return;
if (extension != fileLineExtension) {
@@ -93,7 +116,7 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
if (image != null) {
image.Template = true;
if (tint)
- image = image.WithTint (NSColor.SystemOrangeColor);
+ image = WithTint (image, NSColor.SystemOrangeColor);
}
return image;
}
@@ -132,9 +155,9 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
}
}
- class ExceptionCaughtPopoverView : VSPopoverView
+ class ExceptionCaughtPopoverViewContentView : NSView
{
- public ExceptionCaughtPopoverView()
+ public ExceptionCaughtPopoverViewContentView (NSView contentView)
{
AcceptsTouchEvents = true;
@@ -147,6 +170,13 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
NSTrackingAreaOptions.CursorUpdate,
this,
null));
+
+ AddSubview (contentView);
+ contentView.TranslatesAutoresizingMaskIntoConstraints = false;
+ LeadingAnchor.ConstraintEqualToAnchor (contentView.LeadingAnchor).Active = true;
+ TrailingAnchor.ConstraintEqualToAnchor (contentView.TrailingAnchor).Active = true;
+ TopAnchor.ConstraintEqualToAnchor (contentView.TopAnchor).Active = true;
+ BottomAnchor.ConstraintEqualToAnchor (contentView.BottomAnchor).Active = true;
}
public override void CursorUpdate (NSEvent theEvent)
@@ -160,7 +190,7 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
public override void MouseMoved (NSEvent theEvent) { }
}
- static NSView CreateMiniButton (ExceptionCaughtMiniButton miniButton)
+ static NSView CreateMiniButton (ICocoaViewFactory cocoaViewFactory, ExceptionCaughtMiniButton miniButton)
{
var image = GetIcon ("md-exception-caught-template", tint: true);
@@ -178,14 +208,14 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
miniButton.dlg.ShowButton ();
};
- return new ExceptionCaughtPopoverView {
- ContentView = nsButton,
- CornerRadius = 3,
- Material = NSVisualEffectMaterial.WindowBackground
- };
+ var materialView = cocoaViewFactory.CreateMaterialView ();
+ materialView.ContentView = new ExceptionCaughtPopoverViewContentView (nsButton);
+ materialView.CornerRadius = 3;
+ materialView.Material = NSVisualEffectMaterial.WindowBackground;
+ return (NSView)materialView;
}
- static NSView CreateButton (ExceptionCaughtButton button)
+ static NSView CreateButton (ICocoaViewFactory cocoaViewFactory, ExceptionCaughtButton button)
{
var box = new NSGridView {
ColumnSpacing = 8,
@@ -231,11 +261,11 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
1, 0)
};
- return new ExceptionCaughtPopoverView {
- CornerRadius = 6,
- Padding = new Padding (12),
- ContentView = box
- };
+ var materialView = cocoaViewFactory.CreateMaterialView ();
+ materialView.ContentView = new ExceptionCaughtPopoverViewContentView (box);
+ materialView.CornerRadius = 6;
+ materialView.EdgeInsets = new NSEdgeInsets (6, 6, 6, 6);
+ return (NSView)materialView;
}
static NSTextField CreateTextField ()
@@ -281,7 +311,23 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
IdeServices.TextEditorService.FileExtensionAdded -= FileExtensionAdded;
IdeServices.TextEditorService.FileExtensionRemoved -= FileExtensionRemoved;
}
- }
-}
-#endif \ No newline at end of file
+ // FIXME: move to an extensions class in MD.IDE or something
+ static NSImage WithTint (NSImage sourceImage, NSColor tintColor)
+ {
+ if (tintColor == null)
+ throw new ArgumentNullException (nameof (tintColor));
+
+ if (sourceImage == null)
+ return null;
+
+ return NSImage.ImageWithSize (sourceImage.Size, false, rect =>
+ {
+ sourceImage.DrawInRect (rect, CGRect.Empty, NSCompositingOperation.SourceOver, 1f);
+ tintColor.Set ();
+ NSGraphics.RectFill (rect, NSCompositingOperation.SourceAtop);
+ return true;
+ });
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtProvider.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtProvider.cs
index 888e872ae9..19c34167a9 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtProvider.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/ExceptionCaught/ExceptionCaughtProvider.cs
@@ -1,7 +1,27 @@
-#if !WINDOWS
+//
+// Copyright (c) Microsoft Corp. (https://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
using System;
using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
@@ -12,9 +32,12 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
[TextViewRole (PredefinedTextViewRoles.Debuggable)]
sealed class ExceptionCaughtProvider : ICocoaTextViewCreationListener
{
+ [Import]
+ internal ICocoaViewFactory cocoaViewFactory;
+
public void TextViewCreated (ICocoaTextView textView)
{
- var manager = new ExceptionCaughtAdornmentManager (textView);
+ var manager = new ExceptionCaughtAdornmentManager (cocoaViewFactory, textView);
textView.Closed += (s, e) => manager.Dispose ();
}
@@ -23,6 +46,4 @@ namespace MonoDevelop.Debugger.VSTextView.ExceptionCaught
[Order (After = PredefinedAdornmentLayers.Caret)]
internal AdornmentLayerDefinition visibleWhitespaceLayer;
}
-}
-
-#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Glyphs/BreakpointGlyphMouseProcessor.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Glyphs/BreakpointGlyphMouseProcessor.cs
index 2e310cfa83..a2fa1a36aa 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Glyphs/BreakpointGlyphMouseProcessor.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Glyphs/BreakpointGlyphMouseProcessor.cs
@@ -261,8 +261,9 @@ namespace MonoDevelop.Debugger
}
// if the view does not have any focus, grab it
- if (!textViewHost.TextView.HasAggregateFocus) {
- textViewHost.TextView.VisualElement.BecomeFirstResponder ();
+ if (!textViewHost.TextView.HasAggregateFocus) {
+ var viewToFocus = textViewHost.TextView.VisualElement;
+ viewToFocus.Window.MakeFirstResponder (viewToFocus);
}
// Position the drag/drop caret and ensure it's visible.