Fix Spinner

This commit is contained in:
2026-01-23 09:04:33 -06:00
parent 197df3e029
commit d442b7d6a8

View File

@@ -37,6 +37,8 @@ type Spinner struct {
lastTick time.Time lastTick time.Time
tickInterval time.Duration tickInterval time.Duration
keyMap *KeyMap keyMap *KeyMap
visible bool
} }
var _ Widget = (*Spinner)(nil) var _ Widget = (*Spinner)(nil)
@@ -70,34 +72,37 @@ func (w *Spinner) HandleTime(ev *tcell.EventTime) {
} }
func (w *Spinner) Draw(screen tcell.Screen) { func (w *Spinner) Draw(screen tcell.Screen) {
if !w.visible {
return
}
screen.SetContent(w.x, w.y, w.frames[w.currentFrame], nil, w.style) screen.SetContent(w.x, w.y, w.frames[w.currentFrame], nil, w.style)
} }
func (w *Spinner) Active() bool { return false } func (w *Spinner) Active() bool { return false }
func (w *Spinner) SetActive(a bool) {} func (w *Spinner) SetActive(a bool) {}
func (w *Spinner) Visible() bool { return true } func (w *Spinner) Visible() bool { return w.visible }
func (w *Spinner) SetVisible(v bool) {} func (w *Spinner) SetVisible(v bool) { w.visible = v }
func (w *Spinner) Focusable() bool { return false } func (w *Spinner) Focusable() bool { return false }
func (w *Spinner) SetFocusable(t bool) {} func (w *Spinner) SetFocusable(t bool) {}
func (w *Spinner) SetX(x int) {} func (w *Spinner) SetX(x int) { w.x = x }
func (w *Spinner) SetY(y int) {} func (w *Spinner) SetY(y int) { w.y = y }
func (w *Spinner) GetX() int { return w.x } func (w *Spinner) GetX() int { return w.x }
func (w *Spinner) GetY() int { return w.y } func (w *Spinner) GetY() int { return w.y }
func (w *Spinner) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Spinner) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Spinner) SetPos(pos Coord) {} func (w *Spinner) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y }
func (w *Spinner) SetSize(size Coord) {} func (w *Spinner) SetSize(size Coord) {}
func (w *Spinner) SetW(wd int) {} func (w *Spinner) SetW(wd int) {}
func (w *Spinner) SetH(h int) {} func (w *Spinner) SetH(h int) {}
func (w *Spinner) GetW() int { return 0 } func (w *Spinner) GetW() int { return 1 }
func (w *Spinner) GetH() int { return 0 } func (w *Spinner) GetH() int { return 1 }
func (w *Spinner) WantW() int { return 0 } func (w *Spinner) WantW() int { return 1 }
func (w *Spinner) WantH() int { return 0 } func (w *Spinner) WantH() int { return 1 }
func (w *Spinner) MinW() int { return 0 } func (w *Spinner) MinW() int { return 1 }
func (w *Spinner) MinH() int { return 0 } func (w *Spinner) MinH() int { return 1 }
func (w *Spinner) SetFrames(frames []rune) { func (w *Spinner) SetFrames(frames []rune) {
w.frames = frames w.frames = frames
w.currentFrame = 0 w.currentFrame = 0
} }
func (w *Spinner) SetTickInterface(d time.Duration) { w.tickInterval = d } func (w *Spinner) SetTickInterval(d time.Duration) { w.tickInterval = d }