Terminal.Gui
Terminal.Gui copied to clipboard
`SpinnerView` Calling `AdvanceAnimation` in Constructor
Discussed in https://github.com/gui-cs/Terminal.Gui/discussions/3731
Originally posted by dasien September 5, 2024 Hello,
As part of my migration from v1 -> v2, i replaced my custom 'spinner' control with a SpinnerView
. My implementation is as follows
private readonly string[] _spinFrames = [
"01100010", "01101001", "01110100", "01110111", "01100001", "01110010", "01100100", "01100101",
"01101110"
];
_spnAnimation = new SpinnerView()
{
X = 3, Y = 2, Width = 10, Height = 1, CanFocus = false, Visible = true,
AutoSpin = true, SpinDelay = 80, Sequence = _spinFrames, Data = "spnAnimation"
};
What i have noticed is that the first animation frame that appears is the default SpinnerStyle
for the control, which is SpinnerStyle.Line
. After that first frame, i see my sequence of characters. When i looked at the constructor for the SpinnerView
i see that it is calling AdvanceAnimation()
and that is setting an index of 1, which is getting the "\" character from the SpinnerStyle
(the 2nd element in the list). I have two questions.
-
Can we remove the call to
AdvanceAnimation()
from the constructor? (I am happy to do it) I don't see the purpose for doing it there, but i could be missing something. -
It seems like this code, given the default values for
_bounceReverse
andSpinReverse
, will start with the [1] element in the array, skipping the [0] element the first time through.
var d = 1;
if ((_bounceReverse && !SpinReverse) || (!_bounceReverse && SpinReverse))
{
d = -1;
}
_currentIdx += d;