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

Commit b383559

Browse files
authored
Merge pull request #8894 from mono/jstedfast-debugger-spinner
[Debugger] Use an actual spinner instead of a static image
2 parents cb68f03 + 4710c42 commit b383559

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
@@ -112,6 +112,8 @@ protected override void Dispose (bool disposing)
112112
}
113113

114114
readonly List<NSLayoutConstraint> constraints = new List<NSLayoutConstraint> ();
115+
NSProgressIndicator spinner;
116+
bool spinnerVisible;
115117
NSImageView statusIcon;
116118
bool statusIconVisible;
117119
NSView colorPreview;
@@ -124,11 +126,17 @@ protected override void Dispose (bool disposing)
124126

125127
public MacDebuggerObjectValueView (MacObjectValueTreeView treeView) : base (treeView, "value")
126128
{
129+
spinner = new NSProgressIndicator (new CGRect (0, 0, ImageSize, ImageSize)) {
130+
TranslatesAutoresizingMaskIntoConstraints = false,
131+
Style = NSProgressIndicatorStyle.Spinning,
132+
Indeterminate = true
133+
};
134+
127135
statusIcon = new NSImageView {
128136
TranslatesAutoresizingMaskIntoConstraints = false
129137
};
130138

131-
colorPreview = new NSView (new CGRect (0, 0, 16, 16)) {
139+
colorPreview = new NSView (new CGRect (0, 0, ImageSize, ImageSize)) {
132140
TranslatesAutoresizingMaskIntoConstraints = false
133141
};
134142

@@ -184,6 +192,7 @@ protected override void UpdateContents ()
184192
string valueButtonText = null;
185193
var showViewerButton = false;
186194
Color? previewColor = null;
195+
bool showSpinner = false;
187196
string strval;
188197

189198
if (Node.IsUnknown) {
@@ -207,8 +216,7 @@ protected override void UpdateContents ()
207216
valueButtonText = GettextCatalog.GetString ("Show Value");
208217
} else if (Node.IsEvaluating) {
209218
strval = GettextCatalog.GetString ("Evaluating\u2026");
210-
211-
evaluateStatusIcon = "md-spinner-16";
219+
showSpinner = true;
212220

213221
textColor = NSColor.FromCGColor (GetCGColor (Styles.ObjectValueTreeValueDisabledText));
214222
} else if (Node.IsEnumerable) {
@@ -243,7 +251,7 @@ protected override void UpdateContents ()
243251

244252
OptimalWidth = MarginSize;
245253

246-
// First item: Status Icon
254+
// First item: Status Icon -or- Spinner
247255
if (evaluateStatusIcon != null) {
248256
statusIcon.Image = GetImage (evaluateStatusIcon, Gtk.IconSize.Menu);
249257

@@ -264,6 +272,26 @@ protected override void UpdateContents ()
264272
statusIconVisible = false;
265273
}
266274

275+
if (showSpinner) {
276+
if (!spinnerVisible) {
277+
AddSubview (spinner);
278+
spinner.StartAnimation (this);
279+
spinnerVisible = true;
280+
}
281+
282+
constraints.Add (spinner.CenterYAnchor.ConstraintEqualToAnchor (CenterYAnchor));
283+
constraints.Add (spinner.WidthAnchor.ConstraintEqualToConstant (ImageSize));
284+
constraints.Add (spinner.HeightAnchor.ConstraintEqualToConstant (ImageSize));
285+
views.Add (spinner);
286+
287+
OptimalWidth += ImageSize;
288+
OptimalWidth += RowCellSpacing;
289+
} else if (spinnerVisible) {
290+
spinner.RemoveFromSuperview ();
291+
spinner.StopAnimation (this);
292+
spinnerVisible = false;
293+
}
294+
267295
// Second Item: Color Preview
268296
if (previewColor != null) {
269297
colorPreview.Layer.BackgroundColor = GetCGColor (previewColor.Value);

0 commit comments

Comments
 (0)