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

Commit 4710c42

Browse files
committed
[Debugger] Use an actual spinner instead of a static image
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1000551/
1 parent 9949241 commit 4710c42

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ protected override void Dispose (bool disposing)
9494
}
9595

9696
readonly List<NSLayoutConstraint> constraints = new List<NSLayoutConstraint> ();
97+
NSProgressIndicator spinner;
98+
bool spinnerVisible;
9799
NSImageView statusIcon;
98100
bool statusIconVisible;
99101
NSView colorPreview;
@@ -106,11 +108,17 @@ protected override void Dispose (bool disposing)
106108

107109
public MacDebuggerObjectValueView (MacObjectValueTreeView treeView) : base (treeView, "value")
108110
{
111+
spinner = new NSProgressIndicator (new CGRect (0, 0, ImageSize, ImageSize)) {
112+
TranslatesAutoresizingMaskIntoConstraints = false,
113+
Style = NSProgressIndicatorStyle.Spinning,
114+
Indeterminate = true
115+
};
116+
109117
statusIcon = new NSImageView {
110118
TranslatesAutoresizingMaskIntoConstraints = false
111119
};
112120

113-
colorPreview = new NSView (new CGRect (0, 0, 16, 16)) {
121+
colorPreview = new NSView (new CGRect (0, 0, ImageSize, ImageSize)) {
114122
TranslatesAutoresizingMaskIntoConstraints = false
115123
};
116124

@@ -166,6 +174,7 @@ protected override void UpdateContents ()
166174
string valueButtonText = null;
167175
var showViewerButton = false;
168176
Color? previewColor = null;
177+
bool showSpinner = false;
169178
string strval;
170179

171180
if (Node.IsUnknown) {
@@ -189,8 +198,7 @@ protected override void UpdateContents ()
189198
valueButtonText = GettextCatalog.GetString ("Show Value");
190199
} else if (Node.IsEvaluating) {
191200
strval = GettextCatalog.GetString ("Evaluating\u2026");
192-
193-
evaluateStatusIcon = "md-spinner-16";
201+
showSpinner = true;
194202

195203
textColor = NSColor.FromCGColor (GetCGColor (Styles.ObjectValueTreeValueDisabledText));
196204
} else if (Node.IsEnumerable) {
@@ -225,7 +233,7 @@ protected override void UpdateContents ()
225233

226234
OptimalWidth = MarginSize;
227235

228-
// First item: Status Icon
236+
// First item: Status Icon -or- Spinner
229237
if (evaluateStatusIcon != null) {
230238
statusIcon.Image = GetImage (evaluateStatusIcon, Gtk.IconSize.Menu);
231239

@@ -246,6 +254,26 @@ protected override void UpdateContents ()
246254
statusIconVisible = false;
247255
}
248256

257+
if (showSpinner) {
258+
if (!spinnerVisible) {
259+
AddSubview (spinner);
260+
spinner.StartAnimation (this);
261+
spinnerVisible = true;
262+
}
263+
264+
constraints.Add (spinner.CenterYAnchor.ConstraintEqualToAnchor (CenterYAnchor));
265+
constraints.Add (spinner.WidthAnchor.ConstraintEqualToConstant (ImageSize));
266+
constraints.Add (spinner.HeightAnchor.ConstraintEqualToConstant (ImageSize));
267+
views.Add (spinner);
268+
269+
OptimalWidth += ImageSize;
270+
OptimalWidth += RowCellSpacing;
271+
} else if (spinnerVisible) {
272+
spinner.RemoveFromSuperview ();
273+
spinner.StopAnimation (this);
274+
spinnerVisible = false;
275+
}
276+
249277
// Second Item: Color Preview
250278
if (previewColor != null) {
251279
colorPreview.Layer.BackgroundColor = GetCGColor (previewColor.Value);

0 commit comments

Comments
 (0)