Skip to content

Commit

Permalink
IDesignable for SpinnerView
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Oct 26, 2024
1 parent 6bfa8ba commit 320ff8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Terminal.Gui/Views/SpinnerView/SpinnerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Terminal.Gui;
/// By default animation only occurs when you call <see cref="SpinnerView.AdvanceAnimation()"/>. Use
/// <see cref="AutoSpin"/> to make the automate calls to <see cref="SpinnerView.AdvanceAnimation()"/>.
/// </remarks>
public class SpinnerView : View
public class SpinnerView : View, IDesignable
{
private const int DEFAULT_DELAY = 130;
private static readonly SpinnerStyle DEFAULT_STYLE = new SpinnerStyle.Line ();
Expand Down Expand Up @@ -289,4 +289,12 @@ private void SetStyle (SpinnerStyle style)
Width = GetSpinnerWidth ();
}
}

bool IDesignable.EnableForDesign ()
{
Style = new SpinnerStyle.Points ();
SpinReverse = true;
AutoSpin = true;
return true;
}
}
4 changes: 2 additions & 2 deletions UICatalog/Scenarios/AllViewsTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public override void Main ()
// We have two choices:
// 1) Call Layout explicitly
// 2) Throw LayoutException so Layout tries again
//_eventLog.Layout ();
throw new LayoutException ("_eventLog");
_eventLog.Layout ();
//throw new LayoutException ("_eventLog");
}
return _eventLog.Frame.Width;
Expand Down
4 changes: 1 addition & 3 deletions UICatalog/Scenarios/SpinnerStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class SpinnerViewStyles : Scenario
{
public override void Main ()
{

Application.Init ();

Window app = new ()
Expand All @@ -28,7 +27,7 @@ public override void Main ()

foreach (Type style in typeof (SpinnerStyle).GetNestedTypes ())
{
styleDict.Add (i, new KeyValuePair<string, Type> (style.Name, style));
styleDict.Add (i, new (style.Name, style));
i++;
}

Expand Down Expand Up @@ -212,7 +211,6 @@ void App_Unloaded (object sender, EventArgs args)
app.Unloaded -= App_Unloaded;
}


Application.Run (app);
app.Dispose ();

Expand Down

0 comments on commit 320ff8b

Please sign in to comment.