Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 1758e1a

Browse files
sandyarmstrongmonojenkins
authored andcommitted
[Debugger] Simplify PinnedWatchView, allow scrolling children via popover
Currently, the editor intercepts scrolling events that an adornment such as the PinnedWatchView might want to receive. This prevents such an adornment from being properly scrollable. Looking at how pinned watches work on Windows, however, the watch itself cannot be expanded. Rather, the user can click an expand button to see the child items in a popup. Inspired by this, I have removed scrolling and expansion from the PinnedWatchView, and made it so hovering a watch shows the same popover tooltip (which _is_ scrollable, as it's a child window) that one sees when hovering a value in the editor. A few notes: * Changed the data source to not add child nodes at all when `AllowExpanding` is not set on the tree view. This ensures there will be no disclosure triangle. * Pinned watches whose values do not have children will not get a tooltip. * When hovering a pinned watch, the root node will always be expanded. * The only way to dismiss the watch's popover tooltip is to press ESC or click elsewhere. This actually feels pretty good. * Child expansion state in the tooltip is preserved as long as the watch remains pinned. Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/999603
1 parent 380cef8 commit 1758e1a

File tree

3 files changed

+47
-38
lines changed

3 files changed

+47
-38
lines changed

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/PinnedWatches/PinnedWatchView.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,43 @@
3232

3333
namespace MonoDevelop.Debugger.VSTextView.PinnedWatches
3434
{
35-
sealed class PinnedWatchView : NSScrollView
35+
sealed class PinnedWatchView : NSView
3636
{
37+
readonly PinnedWatch watch;
38+
readonly StackFrame frame;
3739
readonly ObjectValueTreeViewController controller;
3840
readonly NSLayoutConstraint heightConstraint;
3941
readonly NSLayoutConstraint widthConstraint;
4042
readonly MacObjectValueTreeView treeView;
43+
MacDebuggerTooltipWindow popover;
4144
NSLayoutConstraint superHeightConstraint;
4245
NSLayoutConstraint superWidthConstraint;
4346
ObjectValue objectValue;
4447
bool disposed;
4548

4649
public PinnedWatchView (PinnedWatch watch, StackFrame frame)
4750
{
48-
HasVerticalScroller = true;
49-
AutohidesScrollers = true;
51+
this.watch = watch ?? throw new ArgumentNullException (nameof (watch));
52+
this.frame = frame;
5053

5154
controller = new ObjectValueTreeViewController ();
5255
controller.SetStackFrame (frame);
5356
controller.AllowEditing = true;
57+
controller.AllowExpanding = false;
5458

5559
treeView = controller.GetMacControl (headersVisible: false, compactView: true, allowPinning: true);
5660

5761
controller.PinnedWatch = watch;
5862

5963
if (watch.Value != null)
60-
controller.AddValue (watch.Value);
64+
controller.AddValue (objectValue = watch.Value);
6165

6266
var rect = treeView.Frame;
6367

6468
if (rect.Height < 1)
6569
treeView.Frame = new CoreGraphics.CGRect (rect.X, rect.Y, rect.Width, 19);
6670

67-
DocumentView = treeView;
71+
AddSubview (treeView);
6872
Frame = treeView.Frame;
6973

7074
heightConstraint = HeightAnchor.ConstraintEqualToConstant (treeView.Frame.Height);
@@ -76,6 +80,27 @@ public PinnedWatchView (PinnedWatch watch, StackFrame frame)
7680
DebuggingService.ResumedEvent += OnDebuggerResumed;
7781
DebuggingService.PausedEvent += OnDebuggerPaused;
7882
treeView.Resized += OnTreeViewResized;
83+
84+
AddTrackingArea (new NSTrackingArea (
85+
default,
86+
NSTrackingAreaOptions.ActiveInActiveApp |
87+
NSTrackingAreaOptions.InVisibleRect |
88+
NSTrackingAreaOptions.MouseEnteredAndExited,
89+
this,
90+
null));
91+
}
92+
93+
public override void MouseEntered (NSEvent theEvent)
94+
{
95+
if (popover != null && popover.Shown)
96+
return;
97+
98+
if (objectValue != null && objectValue.HasChildren) {
99+
if (popover == null)
100+
popover = new MacDebuggerTooltipWindow (watch.Location, frame, objectValue, watch);
101+
popover.Show (treeView.Frame, this, NSRectEdge.MaxXEdge);
102+
popover.Expand ();
103+
}
79104
}
80105

81106
public void SetObjectValue (ObjectValue value)
@@ -136,41 +161,16 @@ void OnTreeViewResized (object sender, EventArgs e)
136161

137162
superHeightConstraint.Constant = height;
138163
superWidthConstraint.Constant = width;
139-
140-
#if REPARENT_SO_SCROLLING_WORKS
141-
// Find our parent CocoaEditorGridView
142-
var gridView = textView.Superview;
143-
while (gridView != null && gridView.GetType ().Name != CocoaEditorGridView)
144-
gridView = gridView.Superview;
145-
146-
if (gridView == null)
147-
return;
148-
149-
// Find the CocoaTextViewScrollView
150-
NSView textViewScrollView = null;
151-
foreach (var child in gridView.Subviews) {
152-
if (child.GetType ().Name == CocoaTextViewScrollView) {
153-
textViewScrollView = child;
154-
break;
155-
}
156-
}
157-
158-
materialView.RemoveFromSuperview ();
159-
160-
gridView.AddSubview (materialView, NSWindowOrderingMode.Above, textViewScrollView);
161-
#endif
162164
}
163165

164166
void OnDebuggerResumed (object sender, EventArgs e)
165167
{
166168
controller.ChangeCheckpoint ();
167-
controller.AllowExpanding = false;
168169
controller.AllowEditing = false;
169170
}
170171

171172
void OnDebuggerPaused (object sender, EventArgs e)
172173
{
173-
controller.AllowExpanding = true;
174174
controller.AllowEditing = true;
175175
}
176176

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/QuickInfo/MacDebuggerTooltipWindow.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ public MacDebuggerTooltipWindow (PinnedWatchLocation location, StackFrame frame,
7878
treeView.Resized += OnTreeViewResized;
7979
}
8080

81+
public void Expand ()
82+
{
83+
treeView.ExpandItem (treeView.ItemAtRow (0), false);
84+
}
85+
8186
public DebuggerSession GetDebuggerSession ()
8287
{
8388
return controller.GetStackFrame ()?.DebuggerSession;

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeViewDataSource.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ void Add (MacObjectValueNode parent, ObjectValueNode node)
7575

7676
parent.Children.Add (value);
7777

78-
foreach (var child in node.Children)
79-
Add (value, child);
78+
if (treeView.AllowExpanding) {
79+
foreach (var child in node.Children)
80+
Add (value, child);
8081

81-
if (node.HasChildren && !node.ChildrenLoaded)
82-
Add (value, new LoadingObjectValueNode (node));
82+
if (node.HasChildren && !node.ChildrenLoaded)
83+
Add (value, new LoadingObjectValueNode (node));
84+
}
8385
}
8486

8587
void Insert (MacObjectValueNode parent, int index, ObjectValueNode node)
@@ -89,11 +91,13 @@ void Insert (MacObjectValueNode parent, int index, ObjectValueNode node)
8991

9092
parent.Children.Insert (index, value);
9193

92-
foreach (var child in node.Children)
93-
Add (value, child);
94+
if (treeView.AllowExpanding) {
95+
foreach (var child in node.Children)
96+
Add (value, child);
9497

95-
if (node.HasChildren && !node.ChildrenLoaded)
96-
Add (value, new LoadingObjectValueNode (node));
98+
if (node.HasChildren && !node.ChildrenLoaded)
99+
Add (value, new LoadingObjectValueNode (node));
100+
}
97101
}
98102

99103
void Remove (MacObjectValueNode node, List<MacObjectValueNode> removed)

0 commit comments

Comments
 (0)