8 Commits

Author SHA1 Message Date
4b51c5b00f Show/Hide Menu Functions 2026-02-18 15:56:20 -06:00
46a87f913b Bug Fixes 2026-02-02 13:38:33 -06:00
5581cf14c1 Bug Fixes 2026-02-02 13:35:13 -06:00
16a92c8f99 Changed 'Tabbable/Focusable' logic to use Active 2026-02-02 13:29:51 -06:00
62ef3b5d44 Add 'Has' to layout flags 2026-01-29 06:12:52 -06:00
16f7e7466a Bug Fix 2026-01-23 14:58:18 -06:00
b04cc91245 Check bounds of list 2026-01-23 14:56:00 -06:00
c821a8fa06 Style bugfix 2026-01-23 09:38:53 -06:00
32 changed files with 458 additions and 382 deletions

View File

@@ -75,8 +75,9 @@ const (
LFSizeAll = LayoutFlag(0x11110000) LFSizeAll = LayoutFlag(0x11110000)
) )
func (f LayoutFlag) Add(fl LayoutFlag) { f |= fl } func (f LayoutFlag) Has(fl LayoutFlag) bool { return f&fl != 0 }
func (f LayoutFlag) Remove(fl LayoutFlag) { f = f &^ fl } func (f LayoutFlag) Add(fl LayoutFlag) { f |= fl }
func (f LayoutFlag) Remove(fl LayoutFlag) { f = f &^ fl }
func (f LayoutFlag) ClearAll() { func (f LayoutFlag) ClearAll() {
f.ClearAllAlign() f.ClearAllAlign()
f.ClearAllSize() f.ClearAllSize()

View File

@@ -94,8 +94,7 @@ func (w *AbsoluteLayout) HandleKey(ev *tcell.EventKey) bool {
continue continue
} }
} else { } else {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -105,8 +104,7 @@ func (w *AbsoluteLayout) HandleKey(ev *tcell.EventKey) bool {
return false return false
} }
for i := 0; i < fndP; i++ { for i := 0; i < fndP; i++ {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -141,24 +139,27 @@ func (w *AbsoluteLayout) Draw(screen tcell.Screen) {
func (w *AbsoluteLayout) SetStyle(s tcell.Style) { w.style = s } func (w *AbsoluteLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *AbsoluteLayout) Active() bool { return w.active } func (w *AbsoluteLayout) Active() bool { return w.active }
func (w *AbsoluteLayout) SetActive(a bool) { w.active = a } func (w *AbsoluteLayout) SetActive(a bool) bool {
func (w *AbsoluteLayout) Visible() bool { return w.visible } w.active = a
func (w *AbsoluteLayout) SetVisible(a bool) { w.visible = a } return w.Active()
func (w *AbsoluteLayout) Focusable() bool { return w.focusable } }
func (w *AbsoluteLayout) SetFocusable(b bool) { w.focusable = b } func (w *AbsoluteLayout) Visible() bool { return w.visible }
func (w *AbsoluteLayout) SetX(x int) { w.x = x } func (w *AbsoluteLayout) SetVisible(a bool) { w.visible = a }
func (w *AbsoluteLayout) SetY(y int) { w.y = y } func (w *AbsoluteLayout) Focusable() bool { return w.focusable }
func (w *AbsoluteLayout) GetX() int { return w.x } func (w *AbsoluteLayout) SetFocusable(b bool) { w.focusable = b }
func (w *AbsoluteLayout) GetY() int { return w.y } func (w *AbsoluteLayout) SetX(x int) { w.x = x }
func (w *AbsoluteLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *AbsoluteLayout) SetY(y int) { w.y = y }
func (w *AbsoluteLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *AbsoluteLayout) GetX() int { return w.x }
func (w *AbsoluteLayout) GetW() int { return w.w } func (w *AbsoluteLayout) GetY() int { return w.y }
func (w *AbsoluteLayout) GetH() int { return w.h } func (w *AbsoluteLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *AbsoluteLayout) SetW(wd int) { w.w = wd } func (w *AbsoluteLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *AbsoluteLayout) SetH(h int) { w.h = h } func (w *AbsoluteLayout) GetW() int { return w.w }
func (w *AbsoluteLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *AbsoluteLayout) GetH() int { return w.h }
func (w *AbsoluteLayout) WantW() int { return w.w } func (w *AbsoluteLayout) SetW(wd int) { w.w = wd }
func (w *AbsoluteLayout) WantH() int { return w.h } func (w *AbsoluteLayout) SetH(h int) { w.h = h }
func (w *AbsoluteLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *AbsoluteLayout) WantW() int { return w.w }
func (w *AbsoluteLayout) WantH() int { return w.h }
func (w *AbsoluteLayout) MinW() int { func (w *AbsoluteLayout) MinW() int {
// Find the highest value for x in all widgets GetX() + MinW() // Find the highest value for x in all widgets GetX() + MinW()
var minW int var minW int

View File

@@ -127,22 +127,25 @@ func (w *Alert) Draw(screen tcell.Screen) {
func (w *Alert) SetStyle(s tcell.Style) { w.style = s } func (w *Alert) SetStyle(s tcell.Style) { w.style = s }
func (w *Alert) Active() bool { return w.active } func (w *Alert) Active() bool { return w.active }
func (w *Alert) SetActive(a bool) { w.active = a } func (w *Alert) SetActive(a bool) bool {
func (w *Alert) Visible() bool { return w.visible } w.active = a
func (w *Alert) SetVisible(a bool) { w.visible = a } return w.active
func (w *Alert) SetX(x int) { w.x = x } }
func (w *Alert) SetY(y int) { w.y = y } func (w *Alert) Visible() bool { return w.visible }
func (w *Alert) GetX() int { return w.x } func (w *Alert) SetVisible(a bool) { w.visible = a }
func (w *Alert) GetY() int { return w.y } func (w *Alert) SetX(x int) { w.x = x }
func (w *Alert) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Alert) SetY(y int) { w.y = y }
func (w *Alert) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Alert) GetX() int { return w.x }
func (w *Alert) SetW(x int) { w.w = x } func (w *Alert) GetY() int { return w.y }
func (w *Alert) SetH(y int) { w.h = y } func (w *Alert) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Alert) GetW() int { return w.w } func (w *Alert) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Alert) GetH() int { return w.y } func (w *Alert) SetW(x int) { w.w = x }
func (w *Alert) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Alert) SetH(y int) { w.h = y }
func (w *Alert) Focusable() bool { return w.focusable } func (w *Alert) GetW() int { return w.w }
func (w *Alert) SetFocusable(b bool) { w.focusable = b } func (w *Alert) GetH() int { return w.y }
func (w *Alert) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Alert) Focusable() bool { return w.focusable }
func (w *Alert) SetFocusable(b bool) { w.focusable = b }
func (w *Alert) WantW() int { func (w *Alert) WantW() int {
return 4 + wh.Max(w.message.WantW(), (w.btnOk.WantW()+w.btnCancel.WantW())) return 4 + wh.Max(w.message.WantW(), (w.btnOk.WantW()+w.btnCancel.WantW()))
} }

View File

@@ -82,22 +82,25 @@ func (w *ArtWidget) Draw(screen tcell.Screen) {
func (w *ArtWidget) SetStyle(s tcell.Style) { w.style = s } func (w *ArtWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *ArtWidget) Active() bool { return w.active } func (w *ArtWidget) Active() bool { return w.active }
func (w *ArtWidget) SetActive(a bool) { w.active = a } func (w *ArtWidget) SetActive(a bool) bool {
func (w *ArtWidget) Visible() bool { return w.visible } w.active = a
func (w *ArtWidget) SetVisible(v bool) { w.visible = v } return w.active
func (w *ArtWidget) Focusable() bool { return w.focusable } }
func (w *ArtWidget) SetFocusable(t bool) { w.focusable = t } func (w *ArtWidget) Visible() bool { return w.visible }
func (w *ArtWidget) SetX(x int) { w.x = x } func (w *ArtWidget) SetVisible(v bool) { w.visible = v }
func (w *ArtWidget) SetY(y int) { w.y = y } func (w *ArtWidget) Focusable() bool { return w.focusable }
func (w *ArtWidget) GetX() int { return w.x } func (w *ArtWidget) SetFocusable(t bool) { w.focusable = t }
func (w *ArtWidget) GetY() int { return w.y } func (w *ArtWidget) SetX(x int) { w.x = x }
func (w *ArtWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *ArtWidget) SetY(y int) { w.y = y }
func (w *ArtWidget) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y } func (w *ArtWidget) GetX() int { return w.x }
func (w *ArtWidget) SetSize(size Coord) { w.w, w.h = size.X, size.Y } func (w *ArtWidget) GetY() int { return w.y }
func (w *ArtWidget) SetW(wd int) { w.w = wd } func (w *ArtWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *ArtWidget) SetH(h int) { w.h = h } func (w *ArtWidget) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y }
func (w *ArtWidget) GetW() int { return w.w } func (w *ArtWidget) SetSize(size Coord) { w.w, w.h = size.X, size.Y }
func (w *ArtWidget) GetH() int { return w.h } func (w *ArtWidget) SetW(wd int) { w.w = wd }
func (w *ArtWidget) SetH(h int) { w.h = h }
func (w *ArtWidget) GetW() int { return w.w }
func (w *ArtWidget) GetH() int { return w.h }
func (w *ArtWidget) WantW() int { return w.buffer.Width() } func (w *ArtWidget) WantW() int { return w.buffer.Width() }
func (w *ArtWidget) WantH() int { return w.buffer.Height() } func (w *ArtWidget) WantH() int { return w.buffer.Height() }

View File

@@ -51,9 +51,9 @@ func (w *BlankWidget) HandleKey(ev *tcell.EventKey) bool { return false }
func (w *BlankWidget) HandleTime(ev *tcell.EventTime) {} func (w *BlankWidget) HandleTime(ev *tcell.EventTime) {}
func (w *BlankWidget) Draw(screen tcell.Screen) {} func (w *BlankWidget) Draw(screen tcell.Screen) {}
func (w *BlankWidget) SetStyle(s tcell.Style) { w.style = s } func (w *BlankWidget) SetStyle(s tcell.Style) {}
func (w *BlankWidget) Active() bool { return false } func (w *BlankWidget) Active() bool { return false }
func (w *BlankWidget) SetActive(a bool) {} func (w *BlankWidget) SetActive(a bool) bool { return false }
func (w *BlankWidget) Visible() bool { return true } func (w *BlankWidget) Visible() bool { return true }
func (w *BlankWidget) SetVisible(v bool) {} func (w *BlankWidget) SetVisible(v bool) {}
func (w *BlankWidget) Focusable() bool { return false } func (w *BlankWidget) Focusable() bool { return false }

View File

@@ -58,7 +58,6 @@ func (w *BorderedWidget) Init(id string, s tcell.Style) {
w.style = s w.style = s
w.widget.SetVisible(true) w.widget.SetVisible(true)
w.border = wh.BRD_CSIMPLE w.border = wh.BRD_CSIMPLE
w.widget.SetFocusable(true)
} }
func (w *BorderedWidget) Id() string { return w.id } func (w *BorderedWidget) Id() string { return w.id }
@@ -93,11 +92,9 @@ func (w *BorderedWidget) Draw(screen tcell.Screen) {
func (w *BorderedWidget) SetStyle(s tcell.Style) { w.style = s } func (w *BorderedWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *BorderedWidget) Active() bool { return w.widget.Active() } func (w *BorderedWidget) Active() bool { return w.widget.Active() }
func (w *BorderedWidget) SetActive(a bool) { w.widget.SetActive(a) } func (w *BorderedWidget) SetActive(a bool) bool { return w.widget.SetActive(a) }
func (w *BorderedWidget) Visible() bool { return w.widget.Visible() } func (w *BorderedWidget) Visible() bool { return w.widget.Visible() }
func (w *BorderedWidget) SetVisible(a bool) { w.SetVisible(a) } func (w *BorderedWidget) SetVisible(a bool) { w.SetVisible(a) }
func (w *BorderedWidget) Focusable() bool { return w.widget.Focusable() }
func (w *BorderedWidget) SetFocusable(b bool) { w.widget.SetFocusable(b) }
func (w *BorderedWidget) SetX(x int) { w.x = x } func (w *BorderedWidget) SetX(x int) { w.x = x }
func (w *BorderedWidget) SetY(y int) { w.y = y } func (w *BorderedWidget) SetY(y int) { w.y = y }
func (w *BorderedWidget) GetX() int { return w.x } func (w *BorderedWidget) GetX() int { return w.x }

View File

@@ -78,22 +78,25 @@ func (w *BufferWidget) Draw(screen tcell.Screen) { w.buffer.Draw(w.x, w.y,
func (w *BufferWidget) SetStyle(s tcell.Style) { w.style = s } func (w *BufferWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *BufferWidget) Active() bool { return w.active } func (w *BufferWidget) Active() bool { return w.active }
func (w *BufferWidget) SetActive(a bool) { w.active = a } func (w *BufferWidget) SetActive(a bool) bool {
func (w *BufferWidget) Visible() bool { return w.visible } w.active = a
func (w *BufferWidget) SetVisible(a bool) { w.visible = a } return w.active
func (w *BufferWidget) Focusable() bool { return w.focusable } }
func (w *BufferWidget) SetFocusable(b bool) { w.focusable = b } func (w *BufferWidget) Visible() bool { return w.visible }
func (w *BufferWidget) SetX(x int) { w.x = x } func (w *BufferWidget) SetVisible(a bool) { w.visible = a }
func (w *BufferWidget) SetY(y int) { w.y = y } func (w *BufferWidget) Focusable() bool { return w.focusable }
func (w *BufferWidget) GetX() int { return w.x } func (w *BufferWidget) SetFocusable(b bool) { w.focusable = b }
func (w *BufferWidget) GetY() int { return w.y } func (w *BufferWidget) SetX(x int) { w.x = x }
func (w *BufferWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *BufferWidget) SetY(y int) { w.y = y }
func (w *BufferWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *BufferWidget) GetX() int { return w.x }
func (w *BufferWidget) GetW() int { return w.buffer.Width() } func (w *BufferWidget) GetY() int { return w.y }
func (w *BufferWidget) GetH() int { return w.buffer.Height() } func (w *BufferWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *BufferWidget) SetW(wd int) { w.w = wd } func (w *BufferWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *BufferWidget) SetH(h int) { w.h = h } func (w *BufferWidget) GetW() int { return w.buffer.Width() }
func (w *BufferWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *BufferWidget) GetH() int { return w.buffer.Height() }
func (w *BufferWidget) SetW(wd int) { w.w = wd }
func (w *BufferWidget) SetH(h int) { w.h = h }
func (w *BufferWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *BufferWidget) WantW() int { return w.buffer.Width() } func (w *BufferWidget) WantW() int { return w.buffer.Width() }
func (w *BufferWidget) WantH() int { return w.buffer.Height() } func (w *BufferWidget) WantH() int { return w.buffer.Height() }

View File

@@ -121,26 +121,29 @@ func (w *Button) Draw(screen tcell.Screen) {
func (w *Button) SetStyle(s tcell.Style) { w.style = s } func (w *Button) SetStyle(s tcell.Style) { w.style = s }
func (w *Button) Active() bool { return w.active } func (w *Button) Active() bool { return w.active }
func (w *Button) SetActive(a bool) { w.active = a } func (w *Button) SetActive(a bool) bool {
func (w *Button) Visible() bool { return w.visible } w.active = a
func (w *Button) SetVisible(a bool) { w.visible = a } return w.active
func (w *Button) SetX(x int) { w.x = x } }
func (w *Button) SetY(y int) { w.y = y } func (w *Button) Visible() bool { return w.visible }
func (w *Button) GetX() int { return w.x } func (w *Button) SetVisible(a bool) { w.visible = a }
func (w *Button) GetY() int { return w.y } func (w *Button) SetX(x int) { w.x = x }
func (w *Button) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Button) SetY(y int) { w.y = y }
func (w *Button) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Button) GetX() int { return w.x }
func (w *Button) SetW(x int) { w.w = x } func (w *Button) GetY() int { return w.y }
func (w *Button) SetH(y int) { w.h = y } func (w *Button) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Button) GetW() int { return w.w } func (w *Button) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Button) GetH() int { return w.h } func (w *Button) SetW(x int) { w.w = x }
func (w *Button) WantW() int { return 4 + len(w.label) } func (w *Button) SetH(y int) { w.h = y }
func (w *Button) WantH() int { return 3 } func (w *Button) GetW() int { return w.w }
func (w *Button) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Button) GetH() int { return w.h }
func (w *Button) Focusable() bool { return w.focusable } func (w *Button) WantW() int { return 4 + len(w.label) }
func (w *Button) SetFocusable(b bool) { w.focusable = b } func (w *Button) WantH() int { return 3 }
func (w *Button) MinW() int { return len(w.label) + 2 } func (w *Button) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Button) MinH() int { return 1 } func (w *Button) Focusable() bool { return w.focusable }
func (w *Button) SetFocusable(b bool) { w.focusable = b }
func (w *Button) MinW() int { return len(w.label) + 2 }
func (w *Button) MinH() int { return 1 }
func (w *Button) SetLabel(l string) { w.label = l } func (w *Button) SetLabel(l string) { w.label = l }
func (w *Button) SetOnPressed(p func() bool) { w.onPressed = p } func (w *Button) SetOnPressed(p func() bool) { w.onPressed = p }

View File

@@ -160,26 +160,29 @@ func (w *Chat) Draw(screen tcell.Screen) {
func (w *Chat) SetStyle(s tcell.Style) { w.style = s } func (w *Chat) SetStyle(s tcell.Style) { w.style = s }
func (w *Chat) Active() bool { return w.active } func (w *Chat) Active() bool { return w.active }
func (w *Chat) SetActive(a bool) { w.active = a } func (w *Chat) SetActive(a bool) bool {
func (w *Chat) Visible() bool { return w.visible } w.active = a
func (w *Chat) SetVisible(a bool) { w.visible = a } return w.active
func (w *Chat) Focusable() bool { return w.focusable } }
func (w *Chat) SetFocusable(b bool) { w.focusable = b } func (w *Chat) Visible() bool { return w.visible }
func (w *Chat) SetX(x int) { w.x = x } func (w *Chat) SetVisible(a bool) { w.visible = a }
func (w *Chat) SetY(y int) { w.y = y } func (w *Chat) Focusable() bool { return w.focusable }
func (w *Chat) GetX() int { return w.x } func (w *Chat) SetFocusable(b bool) { w.focusable = b }
func (w *Chat) GetY() int { return w.y } func (w *Chat) SetX(x int) { w.x = x }
func (w *Chat) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Chat) SetY(y int) { w.y = y }
func (w *Chat) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Chat) GetX() int { return w.x }
func (w *Chat) GetW() int { return w.w } func (w *Chat) GetY() int { return w.y }
func (w *Chat) GetH() int { return w.h } func (w *Chat) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Chat) SetW(wd int) { w.w = wd } func (w *Chat) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Chat) SetH(h int) { w.h = h } func (w *Chat) GetW() int { return w.w }
func (w *Chat) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Chat) GetH() int { return w.h }
func (w *Chat) WantW() int { return wh.MaxInt } func (w *Chat) SetW(wd int) { w.w = wd }
func (w *Chat) WantH() int { return wh.MaxInt } func (w *Chat) SetH(h int) { w.h = h }
func (w *Chat) MinW() int { return 2 + 20 } func (w *Chat) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Chat) MinH() int { return 6 } func (w *Chat) WantW() int { return wh.MaxInt }
func (w *Chat) WantH() int { return wh.MaxInt }
func (w *Chat) MinW() int { return 2 + 20 }
func (w *Chat) MinH() int { return 6 }
func (w *Chat) initKeyMap() { func (w *Chat) initKeyMap() {
w.keyMap = NewKeyMap( w.keyMap = NewKeyMap(

View File

@@ -94,19 +94,22 @@ func (w *Checkbox) Draw(screen tcell.Screen) {
func (w *Checkbox) SetStyle(s tcell.Style) { w.style = s } func (w *Checkbox) SetStyle(s tcell.Style) { w.style = s }
func (w *Checkbox) Active() bool { return w.active } func (w *Checkbox) Active() bool { return w.active }
func (w *Checkbox) SetActive(a bool) { w.active = a } func (w *Checkbox) SetActive(a bool) bool {
func (w *Checkbox) Visible() bool { return w.visible } w.active = a
func (w *Checkbox) SetVisible(a bool) { w.visible = a } return w.active
func (w *Checkbox) SetX(x int) { w.x = x } }
func (w *Checkbox) SetY(y int) { w.y = y } func (w *Checkbox) Visible() bool { return w.visible }
func (w *Checkbox) GetX() int { return w.x } func (w *Checkbox) SetVisible(a bool) { w.visible = a }
func (w *Checkbox) GetY() int { return w.y } func (w *Checkbox) SetX(x int) { w.x = x }
func (w *Checkbox) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Checkbox) SetY(y int) { w.y = y }
func (w *Checkbox) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Checkbox) GetX() int { return w.x }
func (w *Checkbox) SetW(x int) { w.w = x } func (w *Checkbox) GetY() int { return w.y }
func (w *Checkbox) SetH(y int) { w.h = y } func (w *Checkbox) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Checkbox) GetW() int { return w.w } func (w *Checkbox) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Checkbox) GetH() int { return w.y } func (w *Checkbox) SetW(x int) { w.w = x }
func (w *Checkbox) SetH(y int) { w.h = y }
func (w *Checkbox) GetW() int { return w.w }
func (w *Checkbox) GetH() int { return w.y }
func (w *Checkbox) WantW() int { func (w *Checkbox) WantW() int {
return len(fmt.Sprintf("[%s] %s", string(w.state), w.label)) return len(fmt.Sprintf("[%s] %s", string(w.state), w.label))
} }

View File

@@ -174,23 +174,26 @@ func (w *Cli) Draw(screen tcell.Screen) {
func (w *Cli) SetStyle(s tcell.Style) { w.style = s } func (w *Cli) SetStyle(s tcell.Style) { w.style = s }
func (w *Cli) Active() bool { return w.active } func (w *Cli) Active() bool { return w.active }
func (w *Cli) SetActive(a bool) { w.active = a } func (w *Cli) SetActive(a bool) bool {
func (w *Cli) Visible() bool { return w.visible } w.active = a
func (w *Cli) SetVisible(a bool) { w.visible = a } return w.active
func (w *Cli) Focusable() bool { return true } }
func (w *Cli) SetFocusable(b bool) { w.focusable = b } func (w *Cli) Visible() bool { return w.visible }
func (w *Cli) SetX(x int) { w.x = x } func (w *Cli) SetVisible(a bool) { w.visible = a }
func (w *Cli) SetY(y int) { w.y = y } func (w *Cli) Focusable() bool { return true }
func (w *Cli) GetX() int { return w.x } func (w *Cli) SetFocusable(b bool) { w.focusable = b }
func (w *Cli) GetY() int { return w.y } func (w *Cli) SetX(x int) { w.x = x }
func (w *Cli) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Cli) SetY(y int) { w.y = y }
func (w *Cli) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Cli) GetX() int { return w.x }
func (w *Cli) GetW() int { return w.w } func (w *Cli) GetY() int { return w.y }
func (w *Cli) GetH() int { return w.h } func (w *Cli) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Cli) SetW(wd int) { w.w = wd } func (w *Cli) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Cli) SetH(h int) { w.h = h } func (w *Cli) GetW() int { return w.w }
func (w *Cli) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Cli) GetH() int { return w.h }
func (w *Cli) WantW() int { return wh.MaxInt } func (w *Cli) SetW(wd int) { w.w = wd }
func (w *Cli) SetH(h int) { w.h = h }
func (w *Cli) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Cli) WantW() int { return wh.MaxInt }
func (w *Cli) WantH() int { func (w *Cli) WantH() int {
if w.minimized { if w.minimized {
return 3 return 3

View File

@@ -131,12 +131,13 @@ func (w *DatePicker) Draw(screen tcell.Screen) {
func (w *DatePicker) SetStyle(s tcell.Style) { w.style = s } func (w *DatePicker) SetStyle(s tcell.Style) { w.style = s }
func (w *DatePicker) Active() bool { return w.active } func (w *DatePicker) Active() bool { return w.active }
func (w *DatePicker) SetActive(a bool) { func (w *DatePicker) SetActive(a bool) bool {
if !w.active && a { if !w.active && a {
// Wasn't active, but turning on // Wasn't active, but turning on
w.dateFld.SetActive(true) w.dateFld.SetActive(true)
} }
w.active = a w.active = a
return w.active
} }
func (w *DatePicker) Visible() bool { return w.visible } func (w *DatePicker) Visible() bool { return w.visible }
func (w *DatePicker) SetVisible(a bool) { w.visible = a } func (w *DatePicker) SetVisible(a bool) { w.visible = a }

View File

@@ -167,9 +167,9 @@ func (w *DebugWidget) Draw(screen tcell.Screen) {
func (w *DebugWidget) SetStyle(s tcell.Style) { w.style = s } func (w *DebugWidget) SetStyle(s tcell.Style) { w.style = s }
func (w *DebugWidget) Active() bool { return w.active } func (w *DebugWidget) Active() bool { return w.active }
func (w *DebugWidget) SetActive(a bool) { func (w *DebugWidget) SetActive(a bool) bool {
w.active = a w.active = a
w.widget.SetActive(a) return w.widget.SetActive(a)
} }
func (w *DebugWidget) Visible() bool { return w.visible } func (w *DebugWidget) Visible() bool { return w.visible }
func (w *DebugWidget) SetVisible(a bool) { w.visible = a } func (w *DebugWidget) SetVisible(a bool) { w.visible = a }

View File

@@ -157,19 +157,22 @@ func (w *Field) Draw(screen tcell.Screen) {
func (w *Field) SetStyle(s tcell.Style) { w.style = s } func (w *Field) SetStyle(s tcell.Style) { w.style = s }
func (w *Field) Active() bool { return w.active } func (w *Field) Active() bool { return w.active }
func (w *Field) SetActive(a bool) { w.active = a } func (w *Field) SetActive(a bool) bool {
func (w *Field) Visible() bool { return w.visible } w.active = a
func (w *Field) SetVisible(a bool) { w.visible = a } return w.active
func (w *Field) SetX(x int) { w.x = x } }
func (w *Field) SetY(y int) { w.y = y } func (w *Field) Visible() bool { return w.visible }
func (w *Field) GetX() int { return w.x } func (w *Field) SetVisible(a bool) { w.visible = a }
func (w *Field) GetY() int { return w.y } func (w *Field) SetX(x int) { w.x = x }
func (w *Field) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Field) SetY(y int) { w.y = y }
func (w *Field) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Field) GetX() int { return w.x }
func (w *Field) SetW(wd int) { w.w = wd } func (w *Field) GetY() int { return w.y }
func (w *Field) SetH(h int) { w.h = h } func (w *Field) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Field) GetW() int { return w.w } func (w *Field) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Field) GetH() int { return w.h } func (w *Field) SetW(wd int) { w.w = wd }
func (w *Field) SetH(h int) { w.h = h }
func (w *Field) GetW() int { return w.w }
func (w *Field) GetH() int { return w.h }
func (w *Field) WantW() int { func (w *Field) WantW() int {
vM := wh.Max(40, len(w.value)) vM := wh.Max(40, len(w.value))
if len(w.label) > 0 { if len(w.label) > 0 {

View File

@@ -123,22 +123,25 @@ func (w *FilePicker) Draw(screen tcell.Screen) {
func (w *FilePicker) SetStyle(s tcell.Style) { w.style = s } func (w *FilePicker) SetStyle(s tcell.Style) { w.style = s }
func (w *FilePicker) Active() bool { return w.active } func (w *FilePicker) Active() bool { return w.active }
func (w *FilePicker) SetActive(a bool) { w.active = a } func (w *FilePicker) SetActive(a bool) bool {
func (w *FilePicker) Visible() bool { return w.visible } w.active = a
func (w *FilePicker) SetVisible(a bool) { w.visible = a } return w.active
func (w *FilePicker) SetX(x int) { w.x = x } }
func (w *FilePicker) SetY(y int) { w.y = y } func (w *FilePicker) Visible() bool { return w.visible }
func (w *FilePicker) GetX() int { return w.x } func (w *FilePicker) SetVisible(a bool) { w.visible = a }
func (w *FilePicker) GetY() int { return w.y } func (w *FilePicker) SetX(x int) { w.x = x }
func (w *FilePicker) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *FilePicker) SetY(y int) { w.y = y }
func (w *FilePicker) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *FilePicker) GetX() int { return w.x }
func (w *FilePicker) SetW(x int) { w.w = x } func (w *FilePicker) GetY() int { return w.y }
func (w *FilePicker) SetH(y int) { w.h = y } func (w *FilePicker) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *FilePicker) GetW() int { return w.w } func (w *FilePicker) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *FilePicker) GetH() int { return w.y } func (w *FilePicker) SetW(x int) { w.w = x }
func (w *FilePicker) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *FilePicker) SetH(y int) { w.h = y }
func (w *FilePicker) Focusable() bool { return w.focusable } func (w *FilePicker) GetW() int { return w.w }
func (w *FilePicker) SetFocusable(b bool) { w.focusable = b } func (w *FilePicker) GetH() int { return w.y }
func (w *FilePicker) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *FilePicker) Focusable() bool { return w.focusable }
func (w *FilePicker) SetFocusable(b bool) { w.focusable = b }
func (w *FilePicker) WantW() int { func (w *FilePicker) WantW() int {
// borders + the greater of the buttons next to each other or the list width // borders + the greater of the buttons next to each other or the list width
return wh.Max((w.btnSelect.WantW()+w.btnCancel.WantW()), w.fileList.WantW()) + 2 return wh.Max((w.btnSelect.WantW()+w.btnCancel.WantW()), w.fileList.WantW()) + 2

View File

@@ -148,9 +148,10 @@ func (w *Form) Draw(screen tcell.Screen) {
func (w *Form) SetStyle(s tcell.Style) { w.style = s } func (w *Form) SetStyle(s tcell.Style) { w.style = s }
func (w *Form) Active() bool { return w.active } func (w *Form) Active() bool { return w.active }
func (w *Form) SetActive(a bool) { func (w *Form) SetActive(a bool) bool {
w.active = a w.active = a
w.updateWidgets() w.updateWidgets()
return w.active
} }
func (w *Form) Visible() bool { return w.visible } func (w *Form) Visible() bool { return w.visible }
func (w *Form) SetVisible(a bool) { w.visible = a } func (w *Form) SetVisible(a bool) { w.visible = a }

View File

@@ -52,7 +52,6 @@ type LinearLayout struct {
active bool active bool
visible bool visible bool
focusable bool
disableTab bool disableTab bool
insetBorder bool insetBorder bool
@@ -80,7 +79,6 @@ func (w *LinearLayout) Init(id string, s tcell.Style) {
w.id = id w.id = id
w.style = s w.style = s
w.visible = true w.visible = true
w.focusable = true
w.defFlags = LayoutFlag(LFAlignHCenter | LFAlignVCenter) w.defFlags = LayoutFlag(LFAlignHCenter | LFAlignVCenter)
w.layoutFlags = make(map[Widget]LayoutFlag) w.layoutFlags = make(map[Widget]LayoutFlag)
w.layoutWeights = make(map[Widget]int) w.layoutWeights = make(map[Widget]int)
@@ -89,8 +87,7 @@ func (w *LinearLayout) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := range w.widgets { for i := range w.widgets {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -103,8 +100,7 @@ func (w *LinearLayout) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -162,7 +158,7 @@ func (w *LinearLayout) Draw(screen tcell.Screen) {
func (w *LinearLayout) SetStyle(s tcell.Style) { w.style = s } func (w *LinearLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *LinearLayout) Active() bool { return w.active } func (w *LinearLayout) Active() bool { return w.active }
func (w *LinearLayout) SetActive(a bool) { func (w *LinearLayout) SetActive(a bool) bool {
w.active = a w.active = a
if w.active { if w.active {
act := w.findActiveOrFirst() act := w.findActiveOrFirst()
@@ -170,23 +166,22 @@ func (w *LinearLayout) SetActive(a bool) {
act.SetActive(true) act.SetActive(true)
} }
} }
return w.active
} }
func (w *LinearLayout) Visible() bool { return w.visible } func (w *LinearLayout) Visible() bool { return w.visible }
func (w *LinearLayout) SetVisible(a bool) { w.visible = a } func (w *LinearLayout) SetVisible(a bool) { w.visible = a }
func (w *LinearLayout) Focusable() bool { return w.focusable } func (w *LinearLayout) SetX(x int) { w.x = x }
func (w *LinearLayout) SetFocusable(b bool) { w.focusable = b } func (w *LinearLayout) SetY(y int) { w.y = y }
func (w *LinearLayout) SetX(x int) { w.x = x } func (w *LinearLayout) GetX() int { return w.x }
func (w *LinearLayout) SetY(y int) { w.y = y } func (w *LinearLayout) GetY() int { return w.y }
func (w *LinearLayout) GetX() int { return w.x } func (w *LinearLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *LinearLayout) GetY() int { return w.y } func (w *LinearLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *LinearLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *LinearLayout) GetW() int { return w.w }
func (w *LinearLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *LinearLayout) GetH() int { return w.h }
func (w *LinearLayout) GetW() int { return w.w } func (w *LinearLayout) SetW(wd int) { w.w = wd }
func (w *LinearLayout) GetH() int { return w.h } func (w *LinearLayout) SetH(h int) { w.h = h }
func (w *LinearLayout) SetW(wd int) { w.w = wd } func (w *LinearLayout) getSize() Coord { return Coord{X: w.w, Y: w.h} }
func (w *LinearLayout) SetH(h int) { w.h = h } func (w *LinearLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *LinearLayout) getSize() Coord { return Coord{X: w.w, Y: w.h} }
func (w *LinearLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *LinearLayout) WantW() int { func (w *LinearLayout) WantW() int {
var wantW int var wantW int
for _, wd := range w.widgets { for _, wd := range w.widgets {
@@ -290,8 +285,7 @@ func (w *LinearLayout) ActivateWidget(n Widget) {
func (w *LinearLayout) ActivateNext() bool { func (w *LinearLayout) ActivateNext() bool {
var found bool var found bool
for i := range w.widgets { for i := range w.widgets {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true
@@ -304,8 +298,7 @@ func (w *LinearLayout) ActivateNext() bool {
func (w *LinearLayout) ActivatePrev() bool { func (w *LinearLayout) ActivatePrev() bool {
var found bool var found bool
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true

View File

@@ -227,22 +227,25 @@ func (w *Menu) drawVMenu(screen tcell.Screen) {
func (w *Menu) SetStyle(s tcell.Style) { w.style = s } func (w *Menu) SetStyle(s tcell.Style) { w.style = s }
func (w *Menu) Active() bool { return w.active } func (w *Menu) Active() bool { return w.active }
func (w *Menu) SetActive(a bool) { w.active = a } func (w *Menu) SetActive(a bool) bool {
func (w *Menu) Visible() bool { return w.visible } w.active = a
func (w *Menu) SetVisible(a bool) { w.visible = a } return w.active
func (w *Menu) SetX(x int) { w.x = x } }
func (w *Menu) SetY(y int) { w.y = y } func (w *Menu) Visible() bool { return w.visible }
func (w *Menu) GetX() int { return w.x } func (w *Menu) SetVisible(a bool) { w.visible = a }
func (w *Menu) GetY() int { return w.y } func (w *Menu) SetX(x int) { w.x = x }
func (w *Menu) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Menu) SetY(y int) { w.y = y }
func (w *Menu) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Menu) GetX() int { return w.x }
func (w *Menu) SetW(x int) { w.w = x } func (w *Menu) GetY() int { return w.y }
func (w *Menu) SetH(y int) { w.h = y } func (w *Menu) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Menu) GetW() int { return w.w } func (w *Menu) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Menu) GetH() int { return w.y } func (w *Menu) SetW(x int) { w.w = x }
func (w *Menu) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Menu) SetH(y int) { w.h = y }
func (w *Menu) Focusable() bool { return true } func (w *Menu) GetW() int { return w.w }
func (w *Menu) SetFocusable(b bool) { w.focusable = b } func (w *Menu) GetH() int { return w.y }
func (w *Menu) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Menu) Focusable() bool { return true }
func (w *Menu) SetFocusable(b bool) { w.focusable = b }
func (w *Menu) WantW() int { func (w *Menu) WantW() int {
var maxW int var maxW int

View File

@@ -199,11 +199,12 @@ func (w *MenuItem) Draw(screen tcell.Screen) {
func (w *MenuItem) SetStyle(s tcell.Style) { w.style = s } func (w *MenuItem) SetStyle(s tcell.Style) { w.style = s }
func (w *MenuItem) Active() bool { return w.active } func (w *MenuItem) Active() bool { return w.active }
func (w *MenuItem) SetActive(a bool) { func (w *MenuItem) SetActive(a bool) bool {
w.active = a w.active = a
if !w.manualExpand { if !w.manualExpand {
w.expanded = a w.expanded = a
} }
return w.active
} }
func (w *MenuItem) Visible() bool { return w.visible } func (w *MenuItem) Visible() bool { return w.visible }
func (w *MenuItem) SetVisible(a bool) { w.visible = a } func (w *MenuItem) SetVisible(a bool) { w.visible = a }

View File

@@ -116,22 +116,25 @@ func (w *Prompt) Draw(screen tcell.Screen) {
func (w *Prompt) SetStyle(s tcell.Style) { w.style = s } func (w *Prompt) SetStyle(s tcell.Style) { w.style = s }
func (w *Prompt) Active() bool { return w.active } func (w *Prompt) Active() bool { return w.active }
func (w *Prompt) SetActive(a bool) { w.active = a } func (w *Prompt) SetActive(a bool) bool {
func (w *Prompt) Visible() bool { return w.visible } w.active = a
func (w *Prompt) SetVisible(a bool) { w.visible = a } return w.active
func (w *Prompt) SetX(x int) { w.x = x } }
func (w *Prompt) SetY(y int) { w.y = y } func (w *Prompt) Visible() bool { return w.visible }
func (w *Prompt) GetX() int { return w.x } func (w *Prompt) SetVisible(a bool) { w.visible = a }
func (w *Prompt) GetY() int { return w.y } func (w *Prompt) SetX(x int) { w.x = x }
func (w *Prompt) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Prompt) SetY(y int) { w.y = y }
func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Prompt) GetX() int { return w.x }
func (w *Prompt) SetW(x int) { w.w = x } func (w *Prompt) GetY() int { return w.y }
func (w *Prompt) SetH(y int) { w.h = y } func (w *Prompt) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Prompt) GetW() int { return w.w } func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Prompt) GetH() int { return w.y } func (w *Prompt) SetW(x int) { w.w = x }
func (w *Prompt) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Prompt) SetH(y int) { w.h = y }
func (w *Prompt) Focusable() bool { return w.focusable } func (w *Prompt) GetW() int { return w.w }
func (w *Prompt) SetFocusable(b bool) { w.focusable = b } func (w *Prompt) GetH() int { return w.y }
func (w *Prompt) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Prompt) Focusable() bool { return w.focusable }
func (w *Prompt) SetFocusable(b bool) { w.focusable = b }
func (w *Prompt) WantW() int { func (w *Prompt) WantW() int {
return w.btnOk.WantW() + w.btnCancel.WantW() + 4 return w.btnOk.WantW() + w.btnCancel.WantW() + 4
} }

View File

@@ -114,24 +114,27 @@ func (w *RelativeLayout) Draw(screen tcell.Screen) {
func (w *RelativeLayout) SetStyle(s tcell.Style) { w.style = s } func (w *RelativeLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *RelativeLayout) Active() bool { return w.active } func (w *RelativeLayout) Active() bool { return w.active }
func (w *RelativeLayout) SetActive(a bool) { w.active = a } func (w *RelativeLayout) SetActive(a bool) bool {
func (w *RelativeLayout) Visible() bool { return w.visible } w.active = a
func (w *RelativeLayout) SetVisible(a bool) { w.visible = a } return w.active
func (w *RelativeLayout) Focusable() bool { return w.focusable } }
func (w *RelativeLayout) SetFocusable(b bool) { w.focusable = b } func (w *RelativeLayout) Visible() bool { return w.visible }
func (w *RelativeLayout) SetX(x int) { w.x = x } func (w *RelativeLayout) SetVisible(a bool) { w.visible = a }
func (w *RelativeLayout) SetY(y int) { w.y = y } func (w *RelativeLayout) Focusable() bool { return w.focusable }
func (w *RelativeLayout) GetX() int { return w.x } func (w *RelativeLayout) SetFocusable(b bool) { w.focusable = b }
func (w *RelativeLayout) GetY() int { return w.y } func (w *RelativeLayout) SetX(x int) { w.x = x }
func (w *RelativeLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *RelativeLayout) SetY(y int) { w.y = y }
func (w *RelativeLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *RelativeLayout) GetX() int { return w.x }
func (w *RelativeLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *RelativeLayout) GetY() int { return w.y }
func (w *RelativeLayout) SetW(wd int) { w.w = wd } func (w *RelativeLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *RelativeLayout) SetH(h int) { w.h = h } func (w *RelativeLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *RelativeLayout) GetW() int { return w.w } func (w *RelativeLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *RelativeLayout) GetH() int { return w.h } func (w *RelativeLayout) SetW(wd int) { w.w = wd }
func (w *RelativeLayout) WantW() int { return 1 } func (w *RelativeLayout) SetH(h int) { w.h = h }
func (w *RelativeLayout) WantH() int { return 1 } func (w *RelativeLayout) GetW() int { return w.w }
func (w *RelativeLayout) GetH() int { return w.h }
func (w *RelativeLayout) WantW() int { return 1 }
func (w *RelativeLayout) WantH() int { return 1 }
func (w *RelativeLayout) MinW() int { func (w *RelativeLayout) MinW() int {
// Find the highest value for x in all widgets GetX() + MinW() // Find the highest value for x in all widgets GetX() + MinW()
var minW int var minW int

View File

@@ -259,9 +259,10 @@ func (w *Searcher) buildBuffer() {
func (w *Searcher) SetStyle(s tcell.Style) { w.style = s } func (w *Searcher) SetStyle(s tcell.Style) { w.style = s }
func (w *Searcher) Active() bool { return w.active } func (w *Searcher) Active() bool { return w.active }
func (w *Searcher) SetActive(a bool) { func (w *Searcher) SetActive(a bool) bool {
w.active = a w.active = a
w.search.SetActive(a) w.search.SetActive(a)
return w.active
} }
func (w *Searcher) Visible() bool { return w.visible } func (w *Searcher) Visible() bool { return w.visible }
func (w *Searcher) SetVisible(a bool) { w.visible = a } func (w *Searcher) SetVisible(a bool) { w.visible = a }

View File

@@ -46,25 +46,25 @@ func (w *ShrinkWrap) HandleKey(ev *tcell.EventKey) bool { return w.widget.Handle
func (w *ShrinkWrap) HandleTime(ev *tcell.EventTime) { w.widget.HandleTime(ev) } func (w *ShrinkWrap) HandleTime(ev *tcell.EventTime) { w.widget.HandleTime(ev) }
func (w *ShrinkWrap) Draw(screen tcell.Screen) { w.widget.Draw(screen) } func (w *ShrinkWrap) Draw(screen tcell.Screen) { w.widget.Draw(screen) }
func (w *ShrinkWrap) SetStyle(s tcell.Style) { w.style = s } func (w *ShrinkWrap) SetStyle(s tcell.Style) { w.widget.SetStyle(s) }
func (w *ShrinkWrap) Active() bool { return w.widget.Active() } func (w *ShrinkWrap) Active() bool { return w.widget.Active() }
func (w *ShrinkWrap) SetActive(a bool) { w.widget.SetActive(a) } func (w *ShrinkWrap) SetActive(a bool) bool {
func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() } return w.widget.SetActive(a)
func (w *ShrinkWrap) SetVisible(v bool) { w.widget.SetVisible(v) } }
func (w *ShrinkWrap) Focusable() bool { return w.widget.Focusable() } func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() }
func (w *ShrinkWrap) SetFocusable(t bool) { w.widget.SetFocusable(t) } func (w *ShrinkWrap) SetVisible(v bool) { w.widget.SetVisible(v) }
func (w *ShrinkWrap) SetX(x int) { w.widget.SetX(x) } func (w *ShrinkWrap) SetX(x int) { w.widget.SetX(x) }
func (w *ShrinkWrap) SetY(y int) { w.widget.SetY(y) } func (w *ShrinkWrap) SetY(y int) { w.widget.SetY(y) }
func (w *ShrinkWrap) GetX() int { return w.widget.GetX() } func (w *ShrinkWrap) GetX() int { return w.widget.GetX() }
func (w *ShrinkWrap) GetY() int { return w.widget.GetY() } func (w *ShrinkWrap) GetY() int { return w.widget.GetY() }
func (w *ShrinkWrap) GetPos() Coord { return w.widget.GetPos() } func (w *ShrinkWrap) GetPos() Coord { return w.widget.GetPos() }
func (w *ShrinkWrap) SetPos(pos Coord) { w.widget.SetPos(pos) } func (w *ShrinkWrap) SetPos(pos Coord) { w.widget.SetPos(pos) }
func (w *ShrinkWrap) SetSize(size Coord) { w.widget.SetSize(size) } func (w *ShrinkWrap) SetSize(size Coord) { w.widget.SetSize(size) }
func (w *ShrinkWrap) SetW(wd int) { w.widget.SetW(wd) } func (w *ShrinkWrap) SetW(wd int) { w.widget.SetW(wd) }
func (w *ShrinkWrap) SetH(h int) { w.widget.SetH(h) } func (w *ShrinkWrap) SetH(h int) { w.widget.SetH(h) }
func (w *ShrinkWrap) GetW() int { return w.widget.GetW() } func (w *ShrinkWrap) GetW() int { return w.widget.GetW() }
func (w *ShrinkWrap) GetH() int { return w.widget.GetH() } func (w *ShrinkWrap) GetH() int { return w.widget.GetH() }
func (w *ShrinkWrap) WantW() int { return w.widget.MinW() } func (w *ShrinkWrap) WantW() int { return w.widget.MinW() }
func (w *ShrinkWrap) WantH() int { return w.widget.MinH() } func (w *ShrinkWrap) WantH() int { return w.widget.MinH() }
func (w *ShrinkWrap) MinW() int { return w.widget.MinW() } func (w *ShrinkWrap) MinW() int { return w.widget.MinW() }
func (w *ShrinkWrap) MinH() int { return w.widget.MinH() } func (w *ShrinkWrap) MinH() int { return w.widget.MinH() }

View File

@@ -187,22 +187,25 @@ func (w *SimpleList) Draw(screen tcell.Screen) {
func (w *SimpleList) SetStyle(s tcell.Style) { w.style = s } func (w *SimpleList) SetStyle(s tcell.Style) { w.style = s }
func (w *SimpleList) Active() bool { return w.active } func (w *SimpleList) Active() bool { return w.active }
func (w *SimpleList) SetActive(a bool) { w.active = a } func (w *SimpleList) SetActive(a bool) bool {
func (w *SimpleList) Visible() bool { return w.visible } w.active = a
func (w *SimpleList) SetVisible(a bool) { w.visible = a } return w.active
func (w *SimpleList) SetX(x int) { w.x = x } }
func (w *SimpleList) SetY(y int) { w.y = y } func (w *SimpleList) Visible() bool { return w.visible }
func (w *SimpleList) GetX() int { return w.x } func (w *SimpleList) SetVisible(a bool) { w.visible = a }
func (w *SimpleList) GetY() int { return w.y } func (w *SimpleList) SetX(x int) { w.x = x }
func (w *SimpleList) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *SimpleList) SetY(y int) { w.y = y }
func (w *SimpleList) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *SimpleList) GetX() int { return w.x }
func (w *SimpleList) SetW(x int) { w.w = x } func (w *SimpleList) GetY() int { return w.y }
func (w *SimpleList) SetH(y int) { w.h = y } func (w *SimpleList) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *SimpleList) GetW() int { return w.w } func (w *SimpleList) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *SimpleList) GetH() int { return w.y } func (w *SimpleList) SetW(x int) { w.w = x }
func (w *SimpleList) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *SimpleList) SetH(y int) { w.h = y }
func (w *SimpleList) Focusable() bool { return w.focusable } func (w *SimpleList) GetW() int { return w.w }
func (w *SimpleList) SetFocusable(b bool) { w.focusable = b } func (w *SimpleList) GetH() int { return w.y }
func (w *SimpleList) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *SimpleList) Focusable() bool { return w.focusable }
func (w *SimpleList) SetFocusable(b bool) { w.focusable = b }
func (w *SimpleList) WantW() int { func (w *SimpleList) WantW() int {
lng := wh.Longest(w.list) lng := wh.Longest(w.list)
if len(w.border) > 0 { if len(w.border) > 0 {
@@ -227,6 +230,12 @@ func (w *SimpleList) MinW() int {
func (w *SimpleList) MinH() int { return 4 } func (w *SimpleList) MinH() int { return 4 }
func (w *SimpleList) getItemAt(idx int) {
for idx >= len(w.list) {
idx--
}
}
func (w *SimpleList) SetCursorWrap(b bool) { w.cursorWrap = b } func (w *SimpleList) SetCursorWrap(b bool) { w.cursorWrap = b }
func (w *SimpleList) MoveUp() bool { func (w *SimpleList) MoveUp() bool {
if w.cursor > 0 { if w.cursor > 0 {
@@ -328,7 +337,12 @@ func (w *SimpleList) SetItem(idx int, txt string) {
w.list[idx] = txt w.list[idx] = txt
} }
} }
func (w *SimpleList) SelectedIndex() int { return w.cursor } func (w *SimpleList) SelectedIndex() int {
if w.cursor >= len(w.list) {
w.cursor = len(w.list) - 1
}
return w.cursor
}
func (w *SimpleList) SetSelectedIndex(i int) { func (w *SimpleList) SetSelectedIndex(i int) {
if i < 0 { if i < 0 {
i = 0 i = 0
@@ -350,6 +364,11 @@ func (w *SimpleList) Log(txt string, args ...any) {
func (w *SimpleList) SetOnChange(c func(int, string) bool) { w.onChange = c } func (w *SimpleList) SetOnChange(c func(int, string) bool) { w.onChange = c }
func (w *SimpleList) GetSelectedItem() string { return w.list[w.cursor] } func (w *SimpleList) GetSelectedItem() string {
if w.cursor >= len(w.list) {
w.cursor = len(w.list) - 1
}
return w.list[w.cursor]
}
func (w *SimpleList) GetAllItems() []string { return w.list } func (w *SimpleList) GetAllItems() []string { return w.list }
func (w *SimpleList) GetAllItemStyles() map[int]tcell.Style { return w.itemsStyle } func (w *SimpleList) GetAllItemStyles() map[int]tcell.Style { return w.itemsStyle }

View File

@@ -86,9 +86,9 @@ func (w *SimpleListWithHelp) Draw(screen tcell.Screen) {
func (w *SimpleListWithHelp) SetStyle(s tcell.Style) { w.style = s } func (w *SimpleListWithHelp) SetStyle(s tcell.Style) { w.style = s }
func (w *SimpleListWithHelp) Active() bool { return w.list.Active() } func (w *SimpleListWithHelp) Active() bool { return w.list.Active() }
func (w *SimpleListWithHelp) SetActive(a bool) { func (w *SimpleListWithHelp) SetActive(a bool) bool {
w.list.SetActive(a)
w.help.SetVisible(a) w.help.SetVisible(a)
return w.list.SetActive(a)
} }
func (w *SimpleListWithHelp) Visible() bool { return w.visible } func (w *SimpleListWithHelp) Visible() bool { return w.visible }
func (w *SimpleListWithHelp) SetVisible(a bool) { w.visible = a } func (w *SimpleListWithHelp) SetVisible(a bool) { w.visible = a }

View File

@@ -80,7 +80,7 @@ func (w *Spinner) Draw(screen tcell.Screen) {
func (w *Spinner) SetStyle(s tcell.Style) { w.style = s } func (w *Spinner) SetStyle(s tcell.Style) { w.style = s }
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) bool { return false }
func (w *Spinner) Visible() bool { return w.visible } func (w *Spinner) Visible() bool { return w.visible }
func (w *Spinner) SetVisible(v bool) { w.visible = v } func (w *Spinner) SetVisible(v bool) { w.visible = v }
func (w *Spinner) Focusable() bool { return false } func (w *Spinner) Focusable() bool { return false }

View File

@@ -79,8 +79,7 @@ func (w *ScrollingWidgetList) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := range w.widgets { for i := range w.widgets {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -93,8 +92,7 @@ func (w *ScrollingWidgetList) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -155,7 +153,7 @@ func (w *ScrollingWidgetList) Draw(screen tcell.Screen) {
func (w *ScrollingWidgetList) SetStyle(s tcell.Style) { w.style = s } func (w *ScrollingWidgetList) SetStyle(s tcell.Style) { w.style = s }
func (w *ScrollingWidgetList) Active() bool { return w.active } func (w *ScrollingWidgetList) Active() bool { return w.active }
func (w *ScrollingWidgetList) SetActive(a bool) { func (w *ScrollingWidgetList) SetActive(a bool) bool {
w.active = a w.active = a
if w.active { if w.active {
act := w.findActiveOrFirst() act := w.findActiveOrFirst()
@@ -163,23 +161,22 @@ func (w *ScrollingWidgetList) SetActive(a bool) {
act.SetActive(true) act.SetActive(true)
} }
} }
return w.active
} }
func (w *ScrollingWidgetList) Visible() bool { return w.visible } func (w *ScrollingWidgetList) Visible() bool { return w.visible }
func (w *ScrollingWidgetList) SetVisible(a bool) { w.visible = a } func (w *ScrollingWidgetList) SetVisible(a bool) { w.visible = a }
func (w *ScrollingWidgetList) Focusable() bool { return w.focusable } func (w *ScrollingWidgetList) SetX(x int) { w.x = x }
func (w *ScrollingWidgetList) SetFocusable(b bool) { w.focusable = b } func (w *ScrollingWidgetList) SetY(y int) { w.y = y }
func (w *ScrollingWidgetList) SetX(x int) { w.x = x } func (w *ScrollingWidgetList) GetX() int { return w.x }
func (w *ScrollingWidgetList) SetY(y int) { w.y = y } func (w *ScrollingWidgetList) GetY() int { return w.y }
func (w *ScrollingWidgetList) GetX() int { return w.x } func (w *ScrollingWidgetList) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *ScrollingWidgetList) GetY() int { return w.y } func (w *ScrollingWidgetList) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *ScrollingWidgetList) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *ScrollingWidgetList) GetW() int { return w.w }
func (w *ScrollingWidgetList) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *ScrollingWidgetList) GetH() int { return w.h }
func (w *ScrollingWidgetList) GetW() int { return w.w } func (w *ScrollingWidgetList) SetW(wd int) { w.w = wd }
func (w *ScrollingWidgetList) GetH() int { return w.h } func (w *ScrollingWidgetList) SetH(h int) { w.h = h }
func (w *ScrollingWidgetList) SetW(wd int) { w.w = wd } func (w *ScrollingWidgetList) getSize() Coord { return Coord{X: w.w, Y: w.h} }
func (w *ScrollingWidgetList) SetH(h int) { w.h = h } func (w *ScrollingWidgetList) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *ScrollingWidgetList) getSize() Coord { return Coord{X: w.w, Y: w.h} }
func (w *ScrollingWidgetList) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *ScrollingWidgetList) WantW() int { func (w *ScrollingWidgetList) WantW() int {
var wantW int var wantW int
for _, wd := range w.widgets { for _, wd := range w.widgets {
@@ -283,8 +280,7 @@ func (w *ScrollingWidgetList) ActivateWidget(n Widget) {
func (w *ScrollingWidgetList) ActivateNext() bool { func (w *ScrollingWidgetList) ActivateNext() bool {
var found bool var found bool
for i := range w.widgets { for i := range w.widgets {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true
@@ -297,8 +293,7 @@ func (w *ScrollingWidgetList) ActivateNext() bool {
func (w *ScrollingWidgetList) ActivatePrev() bool { func (w *ScrollingWidgetList) ActivatePrev() bool {
var found bool var found bool
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true

View File

@@ -151,19 +151,22 @@ func (w *Table) Draw(screen tcell.Screen) {
func (w *Table) SetStyle(s tcell.Style) { w.style = s } func (w *Table) SetStyle(s tcell.Style) { w.style = s }
func (w *Table) Active() bool { return w.active } func (w *Table) Active() bool { return w.active }
func (w *Table) SetActive(a bool) { w.active = a } func (w *Table) SetActive(a bool) bool {
func (w *Table) Visible() bool { return w.visible } w.active = a
func (w *Table) SetVisible(a bool) { w.visible = a } return w.active
func (w *Table) SetX(x int) { w.x = x } }
func (w *Table) SetY(y int) { w.y = y } func (w *Table) Visible() bool { return w.visible }
func (w *Table) GetX() int { return w.x } func (w *Table) SetVisible(a bool) { w.visible = a }
func (w *Table) GetY() int { return w.y } func (w *Table) SetX(x int) { w.x = x }
func (w *Table) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Table) SetY(y int) { w.y = y }
func (w *Table) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Table) GetX() int { return w.x }
func (w *Table) SetW(x int) { w.w = x } func (w *Table) GetY() int { return w.y }
func (w *Table) SetH(y int) { w.h = y } func (w *Table) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Table) GetW() int { return w.w } func (w *Table) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Table) GetH() int { return w.y } func (w *Table) SetW(x int) { w.w = x }
func (w *Table) SetH(y int) { w.h = y }
func (w *Table) GetW() int { return w.w }
func (w *Table) GetH() int { return w.y }
func (w *Table) WantW() int { func (w *Table) WantW() int {
if w.minimized { if w.minimized {

View File

@@ -84,26 +84,29 @@ func (w *Text) Draw(screen tcell.Screen) {
func (w *Text) SetStyle(s tcell.Style) { w.style = s } func (w *Text) SetStyle(s tcell.Style) { w.style = s }
func (w *Text) Active() bool { return w.active } func (w *Text) Active() bool { return w.active }
func (w *Text) SetActive(a bool) { w.active = a } func (w *Text) SetActive(a bool) bool {
func (w *Text) Visible() bool { return w.visible } w.active = a
func (w *Text) SetVisible(a bool) { w.visible = a } return w.active
func (w *Text) SetX(x int) { w.x = x } }
func (w *Text) SetY(y int) { w.y = y } func (w *Text) Visible() bool { return w.visible }
func (w *Text) GetX() int { return w.x } func (w *Text) SetVisible(a bool) { w.visible = a }
func (w *Text) GetY() int { return w.y } func (w *Text) SetX(x int) { w.x = x }
func (w *Text) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *Text) SetY(y int) { w.y = y }
func (w *Text) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *Text) GetX() int { return w.x }
func (w *Text) SetW(x int) { w.w = x } func (w *Text) GetY() int { return w.y }
func (w *Text) SetH(y int) { w.h = y } func (w *Text) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Text) GetW() int { return w.w } func (w *Text) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Text) GetH() int { return w.h } func (w *Text) SetW(x int) { w.w = x }
func (w *Text) WantW() int { return wh.Longest(w.message) } func (w *Text) SetH(y int) { w.h = y }
func (w *Text) WantH() int { return len(w.message) } func (w *Text) GetW() int { return w.w }
func (w *Text) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *Text) GetH() int { return w.h }
func (w *Text) Focusable() bool { return w.focusable } func (w *Text) WantW() int { return wh.Longest(w.message) }
func (w *Text) SetFocusable(b bool) { w.focusable = b } func (w *Text) WantH() int { return len(w.message) }
func (w *Text) MinW() int { return wh.Longest(w.message) } func (w *Text) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Text) MinH() int { return len(w.message) } func (w *Text) Focusable() bool { return w.focusable }
func (w *Text) SetFocusable(b bool) { w.focusable = b }
func (w *Text) MinW() int { return wh.Longest(w.message) }
func (w *Text) MinH() int { return len(w.message) }
func (w *Text) SetText(txt string) { func (w *Text) SetText(txt string) {
w.text = txt w.text = txt

View File

@@ -183,24 +183,27 @@ func (w *TimeField) Draw(screen tcell.Screen) {
func (w *TimeField) SetStyle(s tcell.Style) { w.style = s } func (w *TimeField) SetStyle(s tcell.Style) { w.style = s }
func (w *TimeField) Active() bool { return w.active } func (w *TimeField) Active() bool { return w.active }
func (w *TimeField) SetActive(a bool) { w.active = a } func (w *TimeField) SetActive(a bool) bool {
func (w *TimeField) Visible() bool { return w.visible } w.active = a
func (w *TimeField) SetVisible(a bool) { w.visible = a } return w.active
func (w *TimeField) SetX(x int) { w.x = x } }
func (w *TimeField) SetY(y int) { w.y = y } func (w *TimeField) Visible() bool { return w.visible }
func (w *TimeField) GetX() int { return w.x } func (w *TimeField) SetVisible(a bool) { w.visible = a }
func (w *TimeField) GetY() int { return w.y } func (w *TimeField) SetX(x int) { w.x = x }
func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} } func (w *TimeField) SetY(y int) { w.y = y }
func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y } func (w *TimeField) GetX() int { return w.x }
func (w *TimeField) SetW(x int) { w.w = x } func (w *TimeField) GetY() int { return w.y }
func (w *TimeField) SetH(y int) { w.h = y } func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *TimeField) GetW() int { return w.w } func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *TimeField) GetH() int { return w.y } func (w *TimeField) SetW(x int) { w.w = x }
func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y } func (w *TimeField) SetH(y int) { w.h = y }
func (w *TimeField) Focusable() bool { return w.focusable } func (w *TimeField) GetW() int { return w.w }
func (w *TimeField) SetFocusable(b bool) { w.focusable = b } func (w *TimeField) GetH() int { return w.y }
func (w *TimeField) WantW() int { return w.MinW() } func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *TimeField) WantH() int { return w.MinH() } func (w *TimeField) Focusable() bool { return w.focusable }
func (w *TimeField) SetFocusable(b bool) { w.focusable = b }
func (w *TimeField) WantW() int { return w.MinW() }
func (w *TimeField) WantH() int { return w.MinH() }
func (w *TimeField) MinW() int { func (w *TimeField) MinW() int {
wdt := 0 wdt := 0
if w.fldYear.Visible() { if w.fldYear.Visible() {

View File

@@ -78,6 +78,28 @@ func (w *TopMenuLayout) Init(id string, s tcell.Style) {
) )
} }
func (w *TopMenuLayout) HideMenu() bool {
if w.menu == nil {
return false
}
w.menu.SetActive(false)
if w.widget != nil {
w.widget.SetActive(true)
}
return true
}
func (w *TopMenuLayout) ShowMenu() bool {
if w.menu == nil {
return false
}
w.menu.SetActive(true)
if w.widget != nil {
w.widget.SetActive(false)
}
return true
}
func (w *TopMenuLayout) ToggleMenu() bool { func (w *TopMenuLayout) ToggleMenu() bool {
if w.menu != nil { if w.menu != nil {
w.menu.SetActive(!w.menu.Active()) w.menu.SetActive(!w.menu.Active())
@@ -160,11 +182,12 @@ func (w *TopMenuLayout) Draw(screen tcell.Screen) {
func (w *TopMenuLayout) SetStyle(s tcell.Style) { w.style = s } func (w *TopMenuLayout) SetStyle(s tcell.Style) { w.style = s }
func (w *TopMenuLayout) Active() bool { return w.active } func (w *TopMenuLayout) Active() bool { return w.active }
func (w *TopMenuLayout) SetActive(a bool) { func (w *TopMenuLayout) SetActive(a bool) bool {
w.active = a w.active = a
if w.widget != nil { if w.widget != nil {
w.widget.SetActive(a) w.widget.SetActive(a)
} }
return w.active
} }
func (w *TopMenuLayout) Visible() bool { return w.visible } func (w *TopMenuLayout) Visible() bool { return w.visible }
func (w *TopMenuLayout) SetVisible(a bool) { w.visible = a } func (w *TopMenuLayout) SetVisible(a bool) { w.visible = a }

View File

@@ -40,11 +40,9 @@ type Widget interface {
Draw(tcell.Screen) Draw(tcell.Screen)
SetStyle(tcell.Style) SetStyle(tcell.Style)
Active() bool Active() bool
SetActive(bool) SetActive(bool) bool
Visible() bool Visible() bool
SetVisible(bool) SetVisible(bool)
Focusable() bool
SetFocusable(bool)
SetX(int) SetX(int)
SetY(int) SetY(int)
GetX() int GetX() int