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

Commit 3b7961b

Browse files
Merge pull request #9301 from mono/backport-pr-9284-to-release-8.4
[release-8.4] [Debugger] Simplify PinnedWatchView, allow scrolling children via popover
2 parents 0ada790 + 1758e1a commit 3b7961b

File tree

4 files changed

+50
-39
lines changed

4 files changed

+50
-39
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 Refresh()
@@ -141,41 +166,16 @@ void OnTreeViewResized (object sender, EventArgs e)
141166

142167
superHeightConstraint.Constant = height;
143168
superWidthConstraint.Constant = width;
144-
145-
#if REPARENT_SO_SCROLLING_WORKS
146-
// Find our parent CocoaEditorGridView
147-
var gridView = textView.Superview;
148-
while (gridView != null && gridView.GetType ().Name != CocoaEditorGridView)
149-
gridView = gridView.Superview;
150-
151-
if (gridView == null)
152-
return;
153-
154-
// Find the CocoaTextViewScrollView
155-
NSView textViewScrollView = null;
156-
foreach (var child in gridView.Subviews) {
157-
if (child.GetType ().Name == CocoaTextViewScrollView) {
158-
textViewScrollView = child;
159-
break;
160-
}
161-
}
162-
163-
materialView.RemoveFromSuperview ();
164-
165-
gridView.AddSubview (materialView, NSWindowOrderingMode.Above, textViewScrollView);
166-
#endif
167169
}
168170

169171
void OnDebuggerResumed (object sender, EventArgs e)
170172
{
171173
controller.ChangeCheckpoint ();
172-
controller.AllowExpanding = false;
173174
controller.AllowEditing = false;
174175
}
175176

176177
void OnDebuggerPaused (object sender, EventArgs e)
177178
{
178-
controller.AllowExpanding = true;
179179
controller.AllowEditing = true;
180180
}
181181

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/MacObjectValueTreeView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ public bool AllowWatchExpressions {
191191
public PinnedWatch PinnedWatch {
192192
get => pinnedWatch;
193193
set {
194-
if (pinnedWatch != value) {
194+
if (pinnedWatch != value && pinColumn != null) {
195195
pinnedWatch = value;
196196
Runtime.RunInMainThread (() => {
197+
if (pinColumn == null)
198+
return;
197199
if (value == null) {
198200
pinColumn.MinWidth = pinColumn.MaxWidth = pinColumn.Width = MacDebuggerObjectPinView.MinWidth;
199201
} else {

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)