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

Commit 5e49a6f

Browse files
authored
Merge pull request #9342 from mono/jstedfast-debugger-pinnedwatch-selection-glitch
[Debugger] Don't allow selection of the pinned watch row
2 parents 9f70394 + 00cf41a commit 5e49a6f

File tree

10 files changed

+55
-35
lines changed

10 files changed

+55
-35
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public PinnedWatchView (PinnedWatch watch, StackFrame frame)
5656
controller.AllowEditing = true;
5757
controller.AllowExpanding = false;
5858

59-
treeView = controller.GetMacControl (headersVisible: false, compactView: true, allowPinning: true);
59+
treeView = controller.GetMacControl (ObjectValueTreeViewFlags.PinnedWatchFlags);
6060

6161
controller.PinnedWatch = watch;
6262

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public MacDebuggerTooltipWindow (PinnedWatchLocation location, StackFrame frame,
5252
controller.PinnedWatch = watch;
5353
controller.PinnedWatchLocation = location;
5454

55-
treeView = controller.GetMacControl (headersVisible: false, allowPinning: true, compactView: true, rootPinVisible: true);
55+
treeView = controller.GetMacControl (ObjectValueTreeViewFlags.TooltipFlags);
5656
treeView.NodePinned += OnPinStatusChanged;
5757
treeView.StartEditing += OnStartEditing;
5858
treeView.EndEditing += OnEndEditing;

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebugValueWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public DebugValueWindow (Gtk.Window transientFor, PinnedWatchLocation location,
106106
controller.PinnedWatch = watch;
107107
controller.PinnedWatchLocation = location;
108108

109-
treeView = controller.GetGtkControl (headersVisible: false, allowPinning: true, compactView: true, rootPinVisible: true);
109+
treeView = controller.GetGtkControl (ObjectValueTreeViewFlags.TooltipFlags);
110110

111111
if (treeView is IObjectValueTreeView ovtv) {
112112
ovtv.StartEditing += OnStartEditing;

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Widget CreateExceptionValueTreeView ()
186186
controller.SetStackFrame (DebuggingService.CurrentFrame);
187187
controller.AllowExpanding = true;
188188

189-
exceptionValueTreeView = controller.GetGtkControl (allowPopupMenu: false);
189+
exceptionValueTreeView = controller.GetGtkControl (ObjectValueTreeViewFlags.ExceptionCaughtFlags);
190190
} else {
191191
var objValueTreeView = new ObjectValueTreeView ();
192192
objValueTreeView.Frame = DebuggingService.CurrentFrame;

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Gtk/GtkObjectValueTreeView.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,12 @@ public GtkObjectValueTreeView (
171171
IObjectValueDebuggerService debuggerService,
172172
ObjectValueTreeViewController controller,
173173
bool allowEditing,
174-
bool headersVisible,
175-
bool compactView,
176-
bool allowPinning,
177-
bool allowPopupMenu,
178-
bool rootPinVisible)
174+
ObjectValueTreeViewFlags flags)
179175
{
180-
this.compactView = compactView;
181-
this.allowPinning = allowPinning;
182-
this.allowPopupMenu = allowPopupMenu;
183-
this.rootPinVisible = rootPinVisible;
176+
this.compactView = (flags & ObjectValueTreeViewFlags.CompactView) != 0;
177+
this.allowPinning = (flags & ObjectValueTreeViewFlags.AllowPinning) != 0;
178+
this.allowPopupMenu = (flags & ObjectValueTreeViewFlags.AllowPopupMenu) != 0;
179+
this.rootPinVisible = (flags & ObjectValueTreeViewFlags.RootPinVisible) != 0;
184180

185181
// ensure this is set when we set up the view, don't try and refresh just yet
186182
this.allowEditing = allowEditing;
@@ -193,7 +189,7 @@ public GtkObjectValueTreeView (
193189
Model = store;
194190
SearchColumn = -1; // disable the interactive search
195191
RulesHint = true;
196-
HeadersVisible = headersVisible;
192+
HeadersVisible = (flags & ObjectValueTreeViewFlags.HeadersVisible) != 0;
197193
EnableSearch = false;
198194
Selection.Mode = Gtk.SelectionMode.Multiple;
199195
Selection.Changed += HandleSelectionChanged;

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,25 @@ public MacObjectValueTreeView (
7070
IObjectValueDebuggerService debuggerService,
7171
ObjectValueTreeViewController controller,
7272
bool allowEditing,
73-
bool headersVisible,
74-
bool compactView,
75-
bool allowPinning,
76-
bool allowPopupMenu,
77-
bool rootPinVisible)
73+
ObjectValueTreeViewFlags flags)
7874
{
7975
DebuggerService = debuggerService;
8076
Controller = controller;
8177

82-
this.rootPinVisible = rootPinVisible;
83-
this.allowPopupMenu = allowPopupMenu;
78+
this.rootPinVisible = (flags & ObjectValueTreeViewFlags.RootPinVisible) != 0;
79+
this.allowPopupMenu = (flags & ObjectValueTreeViewFlags.AllowPopupMenu) != 0;
80+
this.compactView = (flags & ObjectValueTreeViewFlags.CompactView) != 0;
8481
this.allowEditing = allowEditing;
85-
this.compactView = compactView;
8682

8783
DataSource = dataSource = new MacObjectValueTreeViewDataSource (this, controller.Root, controller.AllowWatchExpressions);
8884
Delegate = treeViewDelegate = new MacObjectValueTreeViewDelegate (this);
8985
ColumnAutoresizingStyle = compactView ? NSTableViewColumnAutoresizingStyle.None : NSTableViewColumnAutoresizingStyle.Uniform;
86+
AllowsSelection = (flags & ObjectValueTreeViewFlags.AllowSelection) != 0;
9087
treeViewDelegate.SelectionChanged += OnSelectionChanged;
9188
UsesAlternatingRowBackgroundColors = true;
9289
FocusRingType = NSFocusRingType.None;
93-
AutoresizesOutlineColumn = false;
9490
AllowsColumnResizing = !compactView;
91+
AutoresizesOutlineColumn = false;
9592
SetCustomFont (null);
9693

9794
var resizingMask = compactView ? NSTableColumnResizing.None : NSTableColumnResizing.UserResizingMask | NSTableColumnResizing.Autoresizing;
@@ -117,13 +114,13 @@ public MacObjectValueTreeView (
117114
AddColumn (typeColumn);
118115
}
119116

120-
if (allowPinning) {
117+
if ((flags & ObjectValueTreeViewFlags.AllowPinning) != 0) {
121118
pinColumn = new NSTableColumn ("pin") { Editable = false, ResizingMask = NSTableColumnResizing.None };
122119
pinColumn.MinWidth = pinColumn.MaxWidth = pinColumn.Width = MacDebuggerObjectPinView.MinWidth;
123120
AddColumn (pinColumn);
124121
}
125122

126-
if (headersVisible) {
123+
if ((flags & ObjectValueTreeViewFlags.HeadersVisible) != 0) {
127124
HeaderView.AlphaValue = 1.0f;
128125
} else {
129126
HeaderView = null;
@@ -150,6 +147,10 @@ public ObjectValueTreeViewController Controller {
150147
get; private set;
151148
}
152149

150+
public bool AllowsSelection {
151+
get; private set;
152+
}
153+
153154
public bool CompactView {
154155
get { return compactView; }
155156
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ public override bool ShouldExpandItem (NSOutlineView outlineView, NSObject item)
140140
return node != null && node.HasChildren;
141141
}
142142

143+
public override bool ShouldSelectItem (NSOutlineView outlineView, NSObject item)
144+
{
145+
return treeView.AllowsSelection;
146+
}
147+
143148
public event EventHandler SelectionChanged;
144149

145150
public override void SelectionDidChange (NSNotification notification)

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/ObjectValueTreeViewController.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ public interface IObjectValueDebuggerService
5454
Task<CompletionData> GetCompletionDataAsync (string expression, CancellationToken token);
5555
}
5656

57+
[Flags]
58+
public enum ObjectValueTreeViewFlags
59+
{
60+
None = 0,
61+
AllowPinning = 1 << 0,
62+
AllowPopupMenu = 1 << 1,
63+
AllowSelection = 1 << 2,
64+
CompactView = 1 << 3,
65+
HeadersVisible = 1 << 4,
66+
RootPinVisible = 1 << 5,
67+
68+
// Macros
69+
ObjectValuePadFlags = AllowPopupMenu | AllowSelection | HeadersVisible,
70+
TooltipFlags = AllowPinning | AllowPopupMenu | AllowSelection | CompactView | RootPinVisible,
71+
PinnedWatchFlags = AllowPinning | AllowPopupMenu | CompactView,
72+
ExceptionCaughtFlags = AllowSelection | HeadersVisible
73+
}
74+
5775
public class ObjectValueTreeViewController : IObjectValueDebuggerService
5876
{
5977
readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource ();
@@ -174,36 +192,36 @@ protected void ConfigureView (IObjectValueTreeView control)
174192
view.NodeShowVisualiser += OnViewNodeShowVisualiser;
175193
}
176194

177-
public GtkObjectValueTreeView GetGtkControl (bool headersVisible = true, bool compactView = false, bool allowPinning = false, bool allowPopupMenu = true, bool rootPinVisible = false)
195+
public GtkObjectValueTreeView GetGtkControl (ObjectValueTreeViewFlags flags)
178196
{
179197
if (view != null)
180198
throw new InvalidOperationException ("You can only get the control once for each controller instance");
181199

182-
var control = new GtkObjectValueTreeView (this, this, AllowEditing, headersVisible, compactView, allowPinning, allowPopupMenu, rootPinVisible);
200+
var control = new GtkObjectValueTreeView (this, this, AllowEditing, flags);
183201

184202
ConfigureView (control);
185203

186204
return control;
187205
}
188206

189-
public MacObjectValueTreeView GetMacControl (bool headersVisible = true, bool compactView = false, bool allowPinning = false, bool allowPopupMenu = true, bool rootPinVisible = false)
207+
public MacObjectValueTreeView GetMacControl (ObjectValueTreeViewFlags flags)
190208
{
191209
if (view != null)
192210
throw new InvalidOperationException ("You can only get the control once for each controller instance");
193211

194-
var control = new MacObjectValueTreeView (this, this, AllowEditing, headersVisible, compactView, allowPinning, allowPopupMenu, rootPinVisible);
212+
var control = new MacObjectValueTreeView (this, this, AllowEditing, flags);
195213

196214
ConfigureView (control);
197215

198216
return control;
199217
}
200218

201-
public Control GetControl (bool headersVisible = true, bool compactView = false, bool allowPinning = false, bool allowPopupMenu = true, bool rootPinVisible = false)
219+
public Control GetControl (ObjectValueTreeViewFlags flags)
202220
{
203221
if (Platform.IsMac)
204-
return GetMacControl (headersVisible, compactView, allowPinning, allowPopupMenu, rootPinVisible);
222+
return GetMacControl (flags);
205223

206-
return GetGtkControl (headersVisible, compactView, allowPinning, allowPopupMenu, rootPinVisible);
224+
return GetGtkControl (flags);
207225
}
208226

209227
public void CancelAsyncTasks ()

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValuePad.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public ObjectValuePad (bool allowWatchExpressions = false)
7070

7171
if (Platform.IsMac) {
7272
LoggingService.LogInfo ("Using MacObjectValueTreeView for {0}", allowWatchExpressions ? "Watch Pad" : "Locals Pad");
73-
var treeView = controller.GetMacControl ();
73+
var treeView = controller.GetMacControl (ObjectValueTreeViewFlags.ObjectValuePadFlags);
7474
_treeview = treeView;
7575

7676
fontChanger = new PadFontChanger (treeView, treeView.SetCustomFont, treeView.QueueResize);
@@ -102,7 +102,7 @@ public ObjectValuePad (bool allowWatchExpressions = false)
102102
control = host;
103103
} else {
104104
LoggingService.LogInfo ("Using GtkObjectValueTreeView for {0}", allowWatchExpressions ? "Watch Pad" : "Locals Pad");
105-
var treeView = controller.GetGtkControl ();
105+
var treeView = controller.GetGtkControl (ObjectValueTreeViewFlags.ObjectValuePadFlags);
106106
treeView.Show ();
107107

108108
fontChanger = new PadFontChanger (treeView, treeView.SetCustomFont, treeView.QueueResize);

main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/PinnedWatchWidget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public PinnedWatchWidget (MonoTextEditor editor, PinnedWatch watch)
8989
controller = new ObjectValueTreeViewController ();
9090
controller.AllowEditing = true;
9191

92-
treeView = (TreeView) controller.GetGtkControl (headersVisible: false, compactView: true, allowPinning: true);
92+
treeView = (TreeView) controller.GetGtkControl (ObjectValueTreeViewFlags.PinnedWatchFlags);
9393

9494
controller.PinnedWatch = watch;
9595
valueTree = null;

0 commit comments

Comments
 (0)