···1515/// The frame index
1616frame: u4 = 0,
17171818-/// If the last time we handled a tick we were spinning. This is used to draw one time after we stop
1919-/// spinning
2020-was_spinning: bool = false,
1818+/// Turns true when we start the spinner. Only turns false during a draw if the count == 0. This
1919+/// ensures we draw one more time past the spinner stopping to clear the state
2020+was_spinning: std.atomic.Value(bool) = .{ .raw = false },
21212222/// Start, or add one, to the spinner counter. Thread safe.
2323pub fn start(self: *Spinner) ?vxfw.Command {
2424+ self.was_spinning.store(true, .unordered);
2425 const count = self.count.fetchAdd(1, .monotonic);
2526 if (count == 0) {
2627 return vxfw.Tick.in(time_lapse, self.widget());
···2829 return null;
2930}
30313131-pub fn isSpinning(self: *Spinner) bool {
3232- return self.count.load(.unordered) > 0;
3333-}
3434-3532/// Reduce one from the spinner counter. The spinner will stop when it reaches 0. Thread safe
3633pub fn stop(self: *Spinner) void {
3734 self.count.store(self.count.load(.unordered) -| 1, .unordered);
3535+}
3636+3737+pub fn wasSpinning(self: *Spinner) bool {
3838+ return self.was_spinning.load(.unordered);
3839}
39404041pub fn widget(self: *Spinner) vxfw.Widget {
···5657 const count = self.count.load(.unordered);
57585859 if (count == 0) {
5959- if (self.was_spinning) {
6060+ if (self.wasSpinning()) {
6061 ctx.redraw = true;
6161- self.was_spinning = false;
6262+ self.was_spinning.store(false, .unordered);
6263 }
6364 return;
6465 }