this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

vxfw(Spinner): redraw after last spin

+16 -1
+16 -1
src/vxfw/Spinner.zig
··· 15 15 /// The frame index 16 16 frame: u4 = 0, 17 17 18 + /// If the last time we handled a tick we were spinning. This is used to draw one time after we stop 19 + /// spinning 20 + was_spinning: bool = false, 21 + 18 22 /// Start, or add one, to the spinner counter. Thread safe. 19 23 pub fn start(self: *Spinner) ?vxfw.Command { 20 24 const count = self.count.fetchAdd(1, .monotonic); ··· 22 26 return vxfw.Tick.in(time_lapse, self.widget()); 23 27 } 24 28 return null; 29 + } 30 + 31 + pub fn isSpinning(self: *Spinner) bool { 32 + return self.count.load(.unordered) > 0; 25 33 } 26 34 27 35 /// Reduce one from the spinner counter. The spinner will stop when it reaches 0. Thread safe ··· 47 55 .tick => { 48 56 const count = self.count.load(.unordered); 49 57 50 - if (count == 0) return; 58 + if (count == 0) { 59 + if (self.was_spinning) { 60 + ctx.redraw = true; 61 + self.was_spinning = false; 62 + } 63 + return; 64 + } 65 + self.was_spinning = true; 51 66 // Update frame 52 67 self.frame += 1; 53 68 if (self.frame >= frames.len) self.frame = 0;