From c1296b1dc1ae680054a280de151c3f065a348b2e Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Fri, 23 Jan 2026 09:36:43 -0600 Subject: [PATCH] Add SetStyle Function --- wdgt_absolute_layout.go | 39 +++++++++-------- wdgt_alert.go | 35 +++++++-------- wdgt_asciiarttext.go | 35 +++++++-------- wdgt_blank.go | 43 ++++++++++--------- wdgt_bordered.go | 43 ++++++++++--------- wdgt_buffer.go | 36 ++++++++-------- wdgt_button.go | 43 ++++++++++--------- wdgt_chat.go | 43 ++++++++++--------- wdgt_checkbox.go | 29 +++++++------ wdgt_cli.go | 37 ++++++++-------- wdgt_datepicker.go | 3 +- wdgt_debug.go | 3 +- wdgt_field.go | 29 +++++++------ wdgt_filepicker.go | 35 +++++++-------- wdgt_form.go | 3 +- wdgt_linear_layout.go | 3 +- wdgt_menu.go | 36 ++++++++-------- wdgt_menu_item.go | 3 +- wdgt_prompt.go | 35 +++++++-------- wdgt_relative_layout.go | 39 +++++++++-------- wdgt_searcher.go | 3 +- wdgt_shrinkwrap.go | 43 ++++++++++--------- wdgt_simple_list.go | 35 +++++++-------- ...twithhelp.go => wdgt_simplelistwithhelp.go | 3 +- wdgt_spinner.go | 43 ++++++++++--------- wdgt_stacked_layout.go | 3 +- wdgt_table.go | 29 +++++++------ wdgt_text.go | 43 ++++++++++--------- wdgt_timefield.go | 39 +++++++++-------- wdgt_top_menu_layout.go | 3 +- widget.go | 1 + 31 files changed, 425 insertions(+), 392 deletions(-) rename wdget_simplelistwithhelp.go => wdgt_simplelistwithhelp.go (97%) diff --git a/wdgt_absolute_layout.go b/wdgt_absolute_layout.go index 1b37eb3..5562584 100644 --- a/wdgt_absolute_layout.go +++ b/wdgt_absolute_layout.go @@ -139,25 +139,26 @@ func (w *AbsoluteLayout) Draw(screen tcell.Screen) { } } -func (w *AbsoluteLayout) Active() bool { return w.active } -func (w *AbsoluteLayout) SetActive(a bool) { w.active = a } -func (w *AbsoluteLayout) Visible() bool { return w.visible } -func (w *AbsoluteLayout) SetVisible(a bool) { w.visible = a } -func (w *AbsoluteLayout) Focusable() bool { return w.focusable } -func (w *AbsoluteLayout) SetFocusable(b bool) { w.focusable = b } -func (w *AbsoluteLayout) SetX(x int) { w.x = x } -func (w *AbsoluteLayout) SetY(y int) { w.y = y } -func (w *AbsoluteLayout) GetX() int { return w.x } -func (w *AbsoluteLayout) GetY() int { return w.y } -func (w *AbsoluteLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *AbsoluteLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *AbsoluteLayout) GetW() int { return w.w } -func (w *AbsoluteLayout) GetH() int { return w.h } -func (w *AbsoluteLayout) SetW(wd int) { w.w = wd } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *AbsoluteLayout) Active() bool { return w.active } +func (w *AbsoluteLayout) SetActive(a bool) { w.active = a } +func (w *AbsoluteLayout) Visible() bool { return w.visible } +func (w *AbsoluteLayout) SetVisible(a bool) { w.visible = a } +func (w *AbsoluteLayout) Focusable() bool { return w.focusable } +func (w *AbsoluteLayout) SetFocusable(b bool) { w.focusable = b } +func (w *AbsoluteLayout) SetX(x int) { w.x = x } +func (w *AbsoluteLayout) SetY(y int) { w.y = y } +func (w *AbsoluteLayout) GetX() int { return w.x } +func (w *AbsoluteLayout) GetY() int { return w.y } +func (w *AbsoluteLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *AbsoluteLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *AbsoluteLayout) GetW() int { return w.w } +func (w *AbsoluteLayout) GetH() int { return w.h } +func (w *AbsoluteLayout) SetW(wd int) { w.w = wd } +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 { // Find the highest value for x in all widgets GetX() + MinW() var minW int diff --git a/wdgt_alert.go b/wdgt_alert.go index ce0e42a..7d50230 100644 --- a/wdgt_alert.go +++ b/wdgt_alert.go @@ -125,23 +125,24 @@ func (w *Alert) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.layout, screen) } -func (w *Alert) Active() bool { return w.active } -func (w *Alert) SetActive(a bool) { w.active = a } -func (w *Alert) Visible() bool { return w.visible } -func (w *Alert) SetVisible(a bool) { w.visible = a } -func (w *Alert) SetX(x int) { w.x = x } -func (w *Alert) SetY(y int) { w.y = y } -func (w *Alert) GetX() int { return w.x } -func (w *Alert) GetY() int { return w.y } -func (w *Alert) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Alert) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Alert) SetW(x int) { w.w = x } -func (w *Alert) SetH(y int) { w.h = y } -func (w *Alert) GetW() int { return w.w } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Alert) Active() bool { return w.active } +func (w *Alert) SetActive(a bool) { w.active = a } +func (w *Alert) Visible() bool { return w.visible } +func (w *Alert) SetVisible(a bool) { w.visible = a } +func (w *Alert) SetX(x int) { w.x = x } +func (w *Alert) SetY(y int) { w.y = y } +func (w *Alert) GetX() int { return w.x } +func (w *Alert) GetY() int { return w.y } +func (w *Alert) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Alert) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Alert) SetW(x int) { w.w = x } +func (w *Alert) SetH(y int) { w.h = y } +func (w *Alert) GetW() int { return w.w } +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 { return 4 + wh.Max(w.message.WantW(), (w.btnOk.WantW()+w.btnCancel.WantW())) } diff --git a/wdgt_asciiarttext.go b/wdgt_asciiarttext.go index cc0b8cd..594703f 100644 --- a/wdgt_asciiarttext.go +++ b/wdgt_asciiarttext.go @@ -80,23 +80,24 @@ func (w *ArtWidget) Draw(screen tcell.Screen) { w.buffer.Draw(w.x, w.y, screen) } -func (w *ArtWidget) Active() bool { return w.active } -func (w *ArtWidget) SetActive(a bool) { w.active = a } -func (w *ArtWidget) Visible() bool { return w.visible } -func (w *ArtWidget) SetVisible(v bool) { w.visible = v } -func (w *ArtWidget) Focusable() bool { return w.focusable } -func (w *ArtWidget) SetFocusable(t bool) { w.focusable = t } -func (w *ArtWidget) SetX(x int) { w.x = x } -func (w *ArtWidget) SetY(y int) { w.y = y } -func (w *ArtWidget) GetX() int { return w.x } -func (w *ArtWidget) GetY() int { return w.y } -func (w *ArtWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *ArtWidget) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y } -func (w *ArtWidget) SetSize(size Coord) { w.w, w.h = size.X, size.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *ArtWidget) Active() bool { return w.active } +func (w *ArtWidget) SetActive(a bool) { w.active = a } +func (w *ArtWidget) Visible() bool { return w.visible } +func (w *ArtWidget) SetVisible(v bool) { w.visible = v } +func (w *ArtWidget) Focusable() bool { return w.focusable } +func (w *ArtWidget) SetFocusable(t bool) { w.focusable = t } +func (w *ArtWidget) SetX(x int) { w.x = x } +func (w *ArtWidget) SetY(y int) { w.y = y } +func (w *ArtWidget) GetX() int { return w.x } +func (w *ArtWidget) GetY() int { return w.y } +func (w *ArtWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *ArtWidget) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y } +func (w *ArtWidget) SetSize(size Coord) { w.w, w.h = size.X, size.Y } +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) WantH() int { return w.buffer.Height() } diff --git a/wdgt_blank.go b/wdgt_blank.go index 43c7d86..54ffae3 100644 --- a/wdgt_blank.go +++ b/wdgt_blank.go @@ -51,27 +51,28 @@ func (w *BlankWidget) HandleKey(ev *tcell.EventKey) bool { return false } func (w *BlankWidget) HandleTime(ev *tcell.EventTime) {} func (w *BlankWidget) Draw(screen tcell.Screen) {} -func (w *BlankWidget) Active() bool { return false } -func (w *BlankWidget) SetActive(a bool) {} -func (w *BlankWidget) Visible() bool { return true } -func (w *BlankWidget) SetVisible(v bool) {} -func (w *BlankWidget) Focusable() bool { return false } -func (w *BlankWidget) SetFocusable(t bool) {} -func (w *BlankWidget) SetX(x int) {} -func (w *BlankWidget) SetY(y int) {} -func (w *BlankWidget) GetX() int { return w.x } -func (w *BlankWidget) GetY() int { return w.y } -func (w *BlankWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *BlankWidget) SetPos(pos Coord) {} -func (w *BlankWidget) SetSize(size Coord) {} -func (w *BlankWidget) SetW(wd int) {} -func (w *BlankWidget) SetH(h int) {} -func (w *BlankWidget) GetW() int { return 0 } -func (w *BlankWidget) GetH() int { return 0 } -func (w *BlankWidget) WantW() int { return w.wantW } -func (w *BlankWidget) WantH() int { return w.wantH } -func (w *BlankWidget) MinW() int { return 0 } -func (w *BlankWidget) MinH() int { return 0 } +func (w *BlankWidget) SetStyle(s tcell.Style) { w.style = s } +func (w *BlankWidget) Active() bool { return false } +func (w *BlankWidget) SetActive(a bool) {} +func (w *BlankWidget) Visible() bool { return true } +func (w *BlankWidget) SetVisible(v bool) {} +func (w *BlankWidget) Focusable() bool { return false } +func (w *BlankWidget) SetFocusable(t bool) {} +func (w *BlankWidget) SetX(x int) {} +func (w *BlankWidget) SetY(y int) {} +func (w *BlankWidget) GetX() int { return w.x } +func (w *BlankWidget) GetY() int { return w.y } +func (w *BlankWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *BlankWidget) SetPos(pos Coord) {} +func (w *BlankWidget) SetSize(size Coord) {} +func (w *BlankWidget) SetW(wd int) {} +func (w *BlankWidget) SetH(h int) {} +func (w *BlankWidget) GetW() int { return 0 } +func (w *BlankWidget) GetH() int { return 0 } +func (w *BlankWidget) WantW() int { return w.wantW } +func (w *BlankWidget) WantH() int { return w.wantH } +func (w *BlankWidget) MinW() int { return 0 } +func (w *BlankWidget) MinH() int { return 0 } func (w *BlankWidget) SetWantH(v int) { w.wantH = v } func (w *BlankWidget) SetWantW(v int) { w.wantW = v } diff --git a/wdgt_bordered.go b/wdgt_bordered.go index 5bd2cf2..925f6b2 100644 --- a/wdgt_bordered.go +++ b/wdgt_bordered.go @@ -91,27 +91,28 @@ func (w *BorderedWidget) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.widget, screen) } -func (w *BorderedWidget) Active() bool { return w.widget.Active() } -func (w *BorderedWidget) SetActive(a bool) { w.widget.SetActive(a) } -func (w *BorderedWidget) Visible() bool { return w.widget.Visible() } -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) SetY(y int) { w.y = y } -func (w *BorderedWidget) GetX() int { return w.x } -func (w *BorderedWidget) GetY() int { return w.y } -func (w *BorderedWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *BorderedWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *BorderedWidget) GetW() int { return w.w } -func (w *BorderedWidget) GetH() int { return w.h } -func (w *BorderedWidget) SetW(wd int) { w.w = wd } -func (w *BorderedWidget) SetH(h int) { w.h = h } -func (w *BorderedWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -func (w *BorderedWidget) WantW() int { return w.w } -func (w *BorderedWidget) WantH() int { return w.h } -func (w *BorderedWidget) MinW() int { return 2 + w.widget.MinW() } -func (w *BorderedWidget) MinH() int { return 2 + w.widget.MinH() } +func (w *BorderedWidget) SetStyle(s tcell.Style) { w.style = s } +func (w *BorderedWidget) Active() bool { return w.widget.Active() } +func (w *BorderedWidget) SetActive(a bool) { w.widget.SetActive(a) } +func (w *BorderedWidget) Visible() bool { return w.widget.Visible() } +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) SetY(y int) { w.y = y } +func (w *BorderedWidget) GetX() int { return w.x } +func (w *BorderedWidget) GetY() int { return w.y } +func (w *BorderedWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *BorderedWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *BorderedWidget) GetW() int { return w.w } +func (w *BorderedWidget) GetH() int { return w.h } +func (w *BorderedWidget) SetW(wd int) { w.w = wd } +func (w *BorderedWidget) SetH(h int) { w.h = h } +func (w *BorderedWidget) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +func (w *BorderedWidget) WantW() int { return w.w } +func (w *BorderedWidget) WantH() int { return w.h } +func (w *BorderedWidget) MinW() int { return 2 + w.widget.MinW() } +func (w *BorderedWidget) MinH() int { return 2 + w.widget.MinH() } func (w *BorderedWidget) SetBorder(r []rune) { w.border = r } func (w *BorderedWidget) SetTitle(ttl string) { w.title = ttl } diff --git a/wdgt_buffer.go b/wdgt_buffer.go index 08b7b09..e7fdb5a 100644 --- a/wdgt_buffer.go +++ b/wdgt_buffer.go @@ -75,23 +75,25 @@ func (w *BufferWidget) HandleKey(ev *tcell.EventKey) bool { } func (w *BufferWidget) HandleTime(ev *tcell.EventTime) { w.timeMap.Handle(ev) } func (w *BufferWidget) Draw(screen tcell.Screen) { w.buffer.Draw(w.x, w.y, screen) } -func (w *BufferWidget) Active() bool { return w.active } -func (w *BufferWidget) SetActive(a bool) { w.active = a } -func (w *BufferWidget) Visible() bool { return w.visible } -func (w *BufferWidget) SetVisible(a bool) { w.visible = a } -func (w *BufferWidget) Focusable() bool { return w.focusable } -func (w *BufferWidget) SetFocusable(b bool) { w.focusable = b } -func (w *BufferWidget) SetX(x int) { w.x = x } -func (w *BufferWidget) SetY(y int) { w.y = y } -func (w *BufferWidget) GetX() int { return w.x } -func (w *BufferWidget) GetY() int { return w.y } -func (w *BufferWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *BufferWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *BufferWidget) GetW() int { return w.buffer.Width() } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *BufferWidget) Active() bool { return w.active } +func (w *BufferWidget) SetActive(a bool) { w.active = a } +func (w *BufferWidget) Visible() bool { return w.visible } +func (w *BufferWidget) SetVisible(a bool) { w.visible = a } +func (w *BufferWidget) Focusable() bool { return w.focusable } +func (w *BufferWidget) SetFocusable(b bool) { w.focusable = b } +func (w *BufferWidget) SetX(x int) { w.x = x } +func (w *BufferWidget) SetY(y int) { w.y = y } +func (w *BufferWidget) GetX() int { return w.x } +func (w *BufferWidget) GetY() int { return w.y } +func (w *BufferWidget) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *BufferWidget) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *BufferWidget) GetW() int { return w.buffer.Width() } +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) WantH() int { return w.buffer.Height() } diff --git a/wdgt_button.go b/wdgt_button.go index d41f4aa..f1180af 100644 --- a/wdgt_button.go +++ b/wdgt_button.go @@ -119,27 +119,28 @@ func (w *Button) Draw(screen tcell.Screen) { wh.DrawText(w.x, w.y+2, fmt.Sprintf("╰%s╯", strings.Repeat("─", w.w-2)), dStyle, screen) } -func (w *Button) Active() bool { return w.active } -func (w *Button) SetActive(a bool) { w.active = a } -func (w *Button) Visible() bool { return w.visible } -func (w *Button) SetVisible(a bool) { w.visible = a } -func (w *Button) SetX(x int) { w.x = x } -func (w *Button) SetY(y int) { w.y = y } -func (w *Button) GetX() int { return w.x } -func (w *Button) GetY() int { return w.y } -func (w *Button) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Button) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Button) SetW(x int) { w.w = x } -func (w *Button) SetH(y int) { w.h = y } -func (w *Button) GetW() int { return w.w } -func (w *Button) GetH() int { return w.h } -func (w *Button) WantW() int { return 4 + len(w.label) } -func (w *Button) WantH() int { return 3 } -func (w *Button) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Button) Active() bool { return w.active } +func (w *Button) SetActive(a bool) { w.active = a } +func (w *Button) Visible() bool { return w.visible } +func (w *Button) SetVisible(a bool) { w.visible = a } +func (w *Button) SetX(x int) { w.x = x } +func (w *Button) SetY(y int) { w.y = y } +func (w *Button) GetX() int { return w.x } +func (w *Button) GetY() int { return w.y } +func (w *Button) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Button) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Button) SetW(x int) { w.w = x } +func (w *Button) SetH(y int) { w.h = y } +func (w *Button) GetW() int { return w.w } +func (w *Button) GetH() int { return w.h } +func (w *Button) WantW() int { return 4 + len(w.label) } +func (w *Button) WantH() int { return 3 } +func (w *Button) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +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) SetOnPressed(p func() bool) { w.onPressed = p } diff --git a/wdgt_chat.go b/wdgt_chat.go index 8c473d9..bb64a78 100644 --- a/wdgt_chat.go +++ b/wdgt_chat.go @@ -158,27 +158,28 @@ func (w *Chat) Draw(screen tcell.Screen) { // x += len(post) - 1 } -func (w *Chat) Active() bool { return w.active } -func (w *Chat) SetActive(a bool) { w.active = a } -func (w *Chat) Visible() bool { return w.visible } -func (w *Chat) SetVisible(a bool) { w.visible = a } -func (w *Chat) Focusable() bool { return w.focusable } -func (w *Chat) SetFocusable(b bool) { w.focusable = b } -func (w *Chat) SetX(x int) { w.x = x } -func (w *Chat) SetY(y int) { w.y = y } -func (w *Chat) GetX() int { return w.x } -func (w *Chat) GetY() int { return w.y } -func (w *Chat) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Chat) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Chat) GetW() int { return w.w } -func (w *Chat) GetH() int { return w.h } -func (w *Chat) SetW(wd int) { w.w = wd } -func (w *Chat) SetH(h int) { w.h = h } -func (w *Chat) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Chat) Active() bool { return w.active } +func (w *Chat) SetActive(a bool) { w.active = a } +func (w *Chat) Visible() bool { return w.visible } +func (w *Chat) SetVisible(a bool) { w.visible = a } +func (w *Chat) Focusable() bool { return w.focusable } +func (w *Chat) SetFocusable(b bool) { w.focusable = b } +func (w *Chat) SetX(x int) { w.x = x } +func (w *Chat) SetY(y int) { w.y = y } +func (w *Chat) GetX() int { return w.x } +func (w *Chat) GetY() int { return w.y } +func (w *Chat) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Chat) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Chat) GetW() int { return w.w } +func (w *Chat) GetH() int { return w.h } +func (w *Chat) SetW(wd int) { w.w = wd } +func (w *Chat) SetH(h int) { w.h = h } +func (w *Chat) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +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() { w.keyMap = NewKeyMap( diff --git a/wdgt_checkbox.go b/wdgt_checkbox.go index 8aedf2b..3a3abec 100644 --- a/wdgt_checkbox.go +++ b/wdgt_checkbox.go @@ -92,20 +92,21 @@ func (w *Checkbox) Draw(screen tcell.Screen) { wh.DrawText(w.x, w.y, fmt.Sprintf("[%s] %s", string(w.stateRunes[w.state]), w.label), dStyle, screen) } -func (w *Checkbox) Active() bool { return w.active } -func (w *Checkbox) SetActive(a bool) { w.active = a } -func (w *Checkbox) Visible() bool { return w.visible } -func (w *Checkbox) SetVisible(a bool) { w.visible = a } -func (w *Checkbox) SetX(x int) { w.x = x } -func (w *Checkbox) SetY(y int) { w.y = y } -func (w *Checkbox) GetX() int { return w.x } -func (w *Checkbox) GetY() int { return w.y } -func (w *Checkbox) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Checkbox) SetPos(c Coord) { w.x, w.y = c.X, c.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) SetStyle(s tcell.Style) { w.style = s } +func (w *Checkbox) Active() bool { return w.active } +func (w *Checkbox) SetActive(a bool) { w.active = a } +func (w *Checkbox) Visible() bool { return w.visible } +func (w *Checkbox) SetVisible(a bool) { w.visible = a } +func (w *Checkbox) SetX(x int) { w.x = x } +func (w *Checkbox) SetY(y int) { w.y = y } +func (w *Checkbox) GetX() int { return w.x } +func (w *Checkbox) GetY() int { return w.y } +func (w *Checkbox) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Checkbox) SetPos(c Coord) { w.x, w.y = c.X, c.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 { return len(fmt.Sprintf("[%s] %s", string(w.state), w.label)) } diff --git a/wdgt_cli.go b/wdgt_cli.go index bd2e13c..475c8c7 100644 --- a/wdgt_cli.go +++ b/wdgt_cli.go @@ -172,24 +172,25 @@ func (w *Cli) Draw(screen tcell.Screen) { wh.DrawText(x, y, wh.PadR(post, w.w-x-2), dStyle, screen) } -func (w *Cli) Active() bool { return w.active } -func (w *Cli) SetActive(a bool) { w.active = a } -func (w *Cli) Visible() bool { return w.visible } -func (w *Cli) SetVisible(a bool) { w.visible = a } -func (w *Cli) Focusable() bool { return true } -func (w *Cli) SetFocusable(b bool) { w.focusable = b } -func (w *Cli) SetX(x int) { w.x = x } -func (w *Cli) SetY(y int) { w.y = y } -func (w *Cli) GetX() int { return w.x } -func (w *Cli) GetY() int { return w.y } -func (w *Cli) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Cli) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Cli) GetW() int { return w.w } -func (w *Cli) GetH() int { return w.h } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Cli) Active() bool { return w.active } +func (w *Cli) SetActive(a bool) { w.active = a } +func (w *Cli) Visible() bool { return w.visible } +func (w *Cli) SetVisible(a bool) { w.visible = a } +func (w *Cli) Focusable() bool { return true } +func (w *Cli) SetFocusable(b bool) { w.focusable = b } +func (w *Cli) SetX(x int) { w.x = x } +func (w *Cli) SetY(y int) { w.y = y } +func (w *Cli) GetX() int { return w.x } +func (w *Cli) GetY() int { return w.y } +func (w *Cli) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Cli) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Cli) GetW() int { return w.w } +func (w *Cli) GetH() int { return w.h } +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 { if w.minimized { return 3 diff --git a/wdgt_datepicker.go b/wdgt_datepicker.go index 950594a..5bbd6d9 100644 --- a/wdgt_datepicker.go +++ b/wdgt_datepicker.go @@ -129,7 +129,8 @@ func (w *DatePicker) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.dateNow, screen) } -func (w *DatePicker) Active() bool { return w.active } +func (w *DatePicker) SetStyle(s tcell.Style) { w.style = s } +func (w *DatePicker) Active() bool { return w.active } func (w *DatePicker) SetActive(a bool) { if !w.active && a { // Wasn't active, but turning on diff --git a/wdgt_debug.go b/wdgt_debug.go index a85f197..a4bebe5 100644 --- a/wdgt_debug.go +++ b/wdgt_debug.go @@ -165,7 +165,8 @@ func (w *DebugWidget) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.widget, screen) } -func (w *DebugWidget) Active() bool { return w.active } +func (w *DebugWidget) SetStyle(s tcell.Style) { w.style = s } +func (w *DebugWidget) Active() bool { return w.active } func (w *DebugWidget) SetActive(a bool) { w.active = a w.widget.SetActive(a) diff --git a/wdgt_field.go b/wdgt_field.go index 7274cfc..ff946cc 100644 --- a/wdgt_field.go +++ b/wdgt_field.go @@ -155,20 +155,21 @@ func (w *Field) Draw(screen tcell.Screen) { wh.DrawText(x, w.y, post, valueStyle, screen) } -func (w *Field) Active() bool { return w.active } -func (w *Field) SetActive(a bool) { w.active = a } -func (w *Field) Visible() bool { return w.visible } -func (w *Field) SetVisible(a bool) { w.visible = a } -func (w *Field) SetX(x int) { w.x = x } -func (w *Field) SetY(y int) { w.y = y } -func (w *Field) GetX() int { return w.x } -func (w *Field) GetY() int { return w.y } -func (w *Field) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Field) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Field) Active() bool { return w.active } +func (w *Field) SetActive(a bool) { w.active = a } +func (w *Field) Visible() bool { return w.visible } +func (w *Field) SetVisible(a bool) { w.visible = a } +func (w *Field) SetX(x int) { w.x = x } +func (w *Field) SetY(y int) { w.y = y } +func (w *Field) GetX() int { return w.x } +func (w *Field) GetY() int { return w.y } +func (w *Field) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Field) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +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 { vM := wh.Max(40, len(w.value)) if len(w.label) > 0 { diff --git a/wdgt_filepicker.go b/wdgt_filepicker.go index 16d09b3..1f20423 100644 --- a/wdgt_filepicker.go +++ b/wdgt_filepicker.go @@ -121,23 +121,24 @@ func (w *FilePicker) Draw(screen tcell.Screen) { p.DrawOffset(w.btnSelect, screen) } -func (w *FilePicker) Active() bool { return w.active } -func (w *FilePicker) SetActive(a bool) { w.active = a } -func (w *FilePicker) Visible() bool { return w.visible } -func (w *FilePicker) SetVisible(a bool) { w.visible = a } -func (w *FilePicker) SetX(x int) { w.x = x } -func (w *FilePicker) SetY(y int) { w.y = y } -func (w *FilePicker) GetX() int { return w.x } -func (w *FilePicker) GetY() int { return w.y } -func (w *FilePicker) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *FilePicker) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *FilePicker) SetW(x int) { w.w = x } -func (w *FilePicker) SetH(y int) { w.h = y } -func (w *FilePicker) GetW() int { return w.w } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *FilePicker) Active() bool { return w.active } +func (w *FilePicker) SetActive(a bool) { w.active = a } +func (w *FilePicker) Visible() bool { return w.visible } +func (w *FilePicker) SetVisible(a bool) { w.visible = a } +func (w *FilePicker) SetX(x int) { w.x = x } +func (w *FilePicker) SetY(y int) { w.y = y } +func (w *FilePicker) GetX() int { return w.x } +func (w *FilePicker) GetY() int { return w.y } +func (w *FilePicker) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *FilePicker) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *FilePicker) SetW(x int) { w.w = x } +func (w *FilePicker) SetH(y int) { w.h = y } +func (w *FilePicker) GetW() int { return w.w } +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 { // 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 diff --git a/wdgt_form.go b/wdgt_form.go index c774ec0..1dd9893 100644 --- a/wdgt_form.go +++ b/wdgt_form.go @@ -146,7 +146,8 @@ func (w *Form) Draw(screen tcell.Screen) { } } -func (w *Form) Active() bool { return w.active } +func (w *Form) SetStyle(s tcell.Style) { w.style = s } +func (w *Form) Active() bool { return w.active } func (w *Form) SetActive(a bool) { w.active = a w.updateWidgets() diff --git a/wdgt_linear_layout.go b/wdgt_linear_layout.go index 142ebc3..24c0550 100644 --- a/wdgt_linear_layout.go +++ b/wdgt_linear_layout.go @@ -160,7 +160,8 @@ func (w *LinearLayout) Draw(screen tcell.Screen) { } } -func (w *LinearLayout) Active() bool { return w.active } +func (w *LinearLayout) SetStyle(s tcell.Style) { w.style = s } +func (w *LinearLayout) Active() bool { return w.active } func (w *LinearLayout) SetActive(a bool) { w.active = a if w.active { diff --git a/wdgt_menu.go b/wdgt_menu.go index 9b30de0..aa7d2e6 100644 --- a/wdgt_menu.go +++ b/wdgt_menu.go @@ -224,23 +224,25 @@ func (w *Menu) drawVMenu(screen tcell.Screen) { y++ } } -func (w *Menu) Active() bool { return w.active } -func (w *Menu) SetActive(a bool) { w.active = a } -func (w *Menu) Visible() bool { return w.visible } -func (w *Menu) SetVisible(a bool) { w.visible = a } -func (w *Menu) SetX(x int) { w.x = x } -func (w *Menu) SetY(y int) { w.y = y } -func (w *Menu) GetX() int { return w.x } -func (w *Menu) GetY() int { return w.y } -func (w *Menu) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Menu) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Menu) SetW(x int) { w.w = x } -func (w *Menu) SetH(y int) { w.h = y } -func (w *Menu) GetW() int { return w.w } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Menu) Active() bool { return w.active } +func (w *Menu) SetActive(a bool) { w.active = a } +func (w *Menu) Visible() bool { return w.visible } +func (w *Menu) SetVisible(a bool) { w.visible = a } +func (w *Menu) SetX(x int) { w.x = x } +func (w *Menu) SetY(y int) { w.y = y } +func (w *Menu) GetX() int { return w.x } +func (w *Menu) GetY() int { return w.y } +func (w *Menu) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Menu) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Menu) SetW(x int) { w.w = x } +func (w *Menu) SetH(y int) { w.h = y } +func (w *Menu) GetW() int { return w.w } +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 { var maxW int diff --git a/wdgt_menu_item.go b/wdgt_menu_item.go index 47f0846..6062afb 100644 --- a/wdgt_menu_item.go +++ b/wdgt_menu_item.go @@ -197,7 +197,8 @@ func (w *MenuItem) Draw(screen tcell.Screen) { } } -func (w *MenuItem) Active() bool { return w.active } +func (w *MenuItem) SetStyle(s tcell.Style) { w.style = s } +func (w *MenuItem) Active() bool { return w.active } func (w *MenuItem) SetActive(a bool) { w.active = a if !w.manualExpand { diff --git a/wdgt_prompt.go b/wdgt_prompt.go index 22813be..1715874 100644 --- a/wdgt_prompt.go +++ b/wdgt_prompt.go @@ -114,23 +114,24 @@ func (w *Prompt) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.btnCancel, screen) } -func (w *Prompt) Active() bool { return w.active } -func (w *Prompt) SetActive(a bool) { w.active = a } -func (w *Prompt) Visible() bool { return w.visible } -func (w *Prompt) SetVisible(a bool) { w.visible = a } -func (w *Prompt) SetX(x int) { w.x = x } -func (w *Prompt) SetY(y int) { w.y = y } -func (w *Prompt) GetX() int { return w.x } -func (w *Prompt) GetY() int { return w.y } -func (w *Prompt) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Prompt) SetW(x int) { w.w = x } -func (w *Prompt) SetH(y int) { w.h = y } -func (w *Prompt) GetW() int { return w.w } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Prompt) Active() bool { return w.active } +func (w *Prompt) SetActive(a bool) { w.active = a } +func (w *Prompt) Visible() bool { return w.visible } +func (w *Prompt) SetVisible(a bool) { w.visible = a } +func (w *Prompt) SetX(x int) { w.x = x } +func (w *Prompt) SetY(y int) { w.y = y } +func (w *Prompt) GetX() int { return w.x } +func (w *Prompt) GetY() int { return w.y } +func (w *Prompt) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Prompt) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Prompt) SetW(x int) { w.w = x } +func (w *Prompt) SetH(y int) { w.h = y } +func (w *Prompt) GetW() int { return w.w } +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 { return w.btnOk.WantW() + w.btnCancel.WantW() + 4 } diff --git a/wdgt_relative_layout.go b/wdgt_relative_layout.go index 03062f0..89ad281 100644 --- a/wdgt_relative_layout.go +++ b/wdgt_relative_layout.go @@ -112,25 +112,26 @@ func (w *RelativeLayout) Draw(screen tcell.Screen) { */ } -func (w *RelativeLayout) Active() bool { return w.active } -func (w *RelativeLayout) SetActive(a bool) { w.active = a } -func (w *RelativeLayout) Visible() bool { return w.visible } -func (w *RelativeLayout) SetVisible(a bool) { w.visible = a } -func (w *RelativeLayout) Focusable() bool { return w.focusable } -func (w *RelativeLayout) SetFocusable(b bool) { w.focusable = b } -func (w *RelativeLayout) SetX(x int) { w.x = x } -func (w *RelativeLayout) SetY(y int) { w.y = y } -func (w *RelativeLayout) GetX() int { return w.x } -func (w *RelativeLayout) GetY() int { return w.y } -func (w *RelativeLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -func (w *RelativeLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *RelativeLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *RelativeLayout) SetW(wd int) { w.w = wd } -func (w *RelativeLayout) SetH(h int) { w.h = h } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *RelativeLayout) Active() bool { return w.active } +func (w *RelativeLayout) SetActive(a bool) { w.active = a } +func (w *RelativeLayout) Visible() bool { return w.visible } +func (w *RelativeLayout) SetVisible(a bool) { w.visible = a } +func (w *RelativeLayout) Focusable() bool { return w.focusable } +func (w *RelativeLayout) SetFocusable(b bool) { w.focusable = b } +func (w *RelativeLayout) SetX(x int) { w.x = x } +func (w *RelativeLayout) SetY(y int) { w.y = y } +func (w *RelativeLayout) GetX() int { return w.x } +func (w *RelativeLayout) GetY() int { return w.y } +func (w *RelativeLayout) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +func (w *RelativeLayout) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *RelativeLayout) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *RelativeLayout) SetW(wd int) { w.w = wd } +func (w *RelativeLayout) SetH(h int) { w.h = h } +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 { // Find the highest value for x in all widgets GetX() + MinW() var minW int diff --git a/wdgt_searcher.go b/wdgt_searcher.go index 667bef7..b921eeb 100644 --- a/wdgt_searcher.go +++ b/wdgt_searcher.go @@ -257,7 +257,8 @@ func (w *Searcher) buildBuffer() { w.buffer = b } -func (w *Searcher) Active() bool { return w.active } +func (w *Searcher) SetStyle(s tcell.Style) { w.style = s } +func (w *Searcher) Active() bool { return w.active } func (w *Searcher) SetActive(a bool) { w.active = a w.search.SetActive(a) diff --git a/wdgt_shrinkwrap.go b/wdgt_shrinkwrap.go index f9de35c..9c903d6 100644 --- a/wdgt_shrinkwrap.go +++ b/wdgt_shrinkwrap.go @@ -46,24 +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) Draw(screen tcell.Screen) { w.widget.Draw(screen) } -func (w *ShrinkWrap) Active() bool { return w.widget.Active() } -func (w *ShrinkWrap) SetActive(a bool) { w.widget.SetActive(a) } -func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() } -func (w *ShrinkWrap) SetVisible(v bool) { w.widget.SetVisible(v) } -func (w *ShrinkWrap) Focusable() bool { return w.widget.Focusable() } -func (w *ShrinkWrap) SetFocusable(t bool) { w.widget.SetFocusable(t) } -func (w *ShrinkWrap) SetX(x int) { w.widget.SetX(x) } -func (w *ShrinkWrap) SetY(y int) { w.widget.SetY(y) } -func (w *ShrinkWrap) GetX() int { return w.widget.GetX() } -func (w *ShrinkWrap) GetY() int { return w.widget.GetY() } -func (w *ShrinkWrap) GetPos() Coord { return w.widget.GetPos() } -func (w *ShrinkWrap) SetPos(pos Coord) { w.widget.SetPos(pos) } -func (w *ShrinkWrap) SetSize(size Coord) { w.widget.SetSize(size) } -func (w *ShrinkWrap) SetW(wd int) { w.widget.SetW(wd) } -func (w *ShrinkWrap) SetH(h int) { w.widget.SetH(h) } -func (w *ShrinkWrap) GetW() int { return w.widget.GetW() } -func (w *ShrinkWrap) GetH() int { return w.widget.GetH() } -func (w *ShrinkWrap) WantW() int { return w.widget.MinW() } -func (w *ShrinkWrap) WantH() int { return w.widget.MinH() } -func (w *ShrinkWrap) MinW() int { return w.widget.MinW() } -func (w *ShrinkWrap) MinH() int { return w.widget.MinH() } +func (w *ShrinkWrap) SetStyle(s tcell.Style) { w.style = s } +func (w *ShrinkWrap) Active() bool { return w.widget.Active() } +func (w *ShrinkWrap) SetActive(a bool) { w.widget.SetActive(a) } +func (w *ShrinkWrap) Visible() bool { return w.widget.Visible() } +func (w *ShrinkWrap) SetVisible(v bool) { w.widget.SetVisible(v) } +func (w *ShrinkWrap) Focusable() bool { return w.widget.Focusable() } +func (w *ShrinkWrap) SetFocusable(t bool) { w.widget.SetFocusable(t) } +func (w *ShrinkWrap) SetX(x int) { w.widget.SetX(x) } +func (w *ShrinkWrap) SetY(y int) { w.widget.SetY(y) } +func (w *ShrinkWrap) GetX() int { return w.widget.GetX() } +func (w *ShrinkWrap) GetY() int { return w.widget.GetY() } +func (w *ShrinkWrap) GetPos() Coord { return w.widget.GetPos() } +func (w *ShrinkWrap) SetPos(pos Coord) { w.widget.SetPos(pos) } +func (w *ShrinkWrap) SetSize(size Coord) { w.widget.SetSize(size) } +func (w *ShrinkWrap) SetW(wd int) { w.widget.SetW(wd) } +func (w *ShrinkWrap) SetH(h int) { w.widget.SetH(h) } +func (w *ShrinkWrap) GetW() int { return w.widget.GetW() } +func (w *ShrinkWrap) GetH() int { return w.widget.GetH() } +func (w *ShrinkWrap) WantW() int { return w.widget.MinW() } +func (w *ShrinkWrap) WantH() int { return w.widget.MinH() } +func (w *ShrinkWrap) MinW() int { return w.widget.MinW() } +func (w *ShrinkWrap) MinH() int { return w.widget.MinH() } diff --git a/wdgt_simple_list.go b/wdgt_simple_list.go index 85bb408..eaa5fc1 100644 --- a/wdgt_simple_list.go +++ b/wdgt_simple_list.go @@ -185,23 +185,24 @@ func (w *SimpleList) Draw(screen tcell.Screen) { } } -func (w *SimpleList) Active() bool { return w.active } -func (w *SimpleList) SetActive(a bool) { w.active = a } -func (w *SimpleList) Visible() bool { return w.visible } -func (w *SimpleList) SetVisible(a bool) { w.visible = a } -func (w *SimpleList) SetX(x int) { w.x = x } -func (w *SimpleList) SetY(y int) { w.y = y } -func (w *SimpleList) GetX() int { return w.x } -func (w *SimpleList) GetY() int { return w.y } -func (w *SimpleList) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *SimpleList) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *SimpleList) SetW(x int) { w.w = x } -func (w *SimpleList) SetH(y int) { w.h = y } -func (w *SimpleList) GetW() int { return w.w } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *SimpleList) Active() bool { return w.active } +func (w *SimpleList) SetActive(a bool) { w.active = a } +func (w *SimpleList) Visible() bool { return w.visible } +func (w *SimpleList) SetVisible(a bool) { w.visible = a } +func (w *SimpleList) SetX(x int) { w.x = x } +func (w *SimpleList) SetY(y int) { w.y = y } +func (w *SimpleList) GetX() int { return w.x } +func (w *SimpleList) GetY() int { return w.y } +func (w *SimpleList) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *SimpleList) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *SimpleList) SetW(x int) { w.w = x } +func (w *SimpleList) SetH(y int) { w.h = y } +func (w *SimpleList) GetW() int { return w.w } +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 { lng := wh.Longest(w.list) if len(w.border) > 0 { diff --git a/wdget_simplelistwithhelp.go b/wdgt_simplelistwithhelp.go similarity index 97% rename from wdget_simplelistwithhelp.go rename to wdgt_simplelistwithhelp.go index ed1f4ee..ee63ec3 100644 --- a/wdget_simplelistwithhelp.go +++ b/wdgt_simplelistwithhelp.go @@ -84,7 +84,8 @@ func (w *SimpleListWithHelp) Draw(screen tcell.Screen) { w.GetPos().DrawOffset(w.help, screen) } -func (w *SimpleListWithHelp) Active() bool { return w.list.Active() } +func (w *SimpleListWithHelp) SetStyle(s tcell.Style) { w.style = s } +func (w *SimpleListWithHelp) Active() bool { return w.list.Active() } func (w *SimpleListWithHelp) SetActive(a bool) { w.list.SetActive(a) w.help.SetVisible(a) diff --git a/wdgt_spinner.go b/wdgt_spinner.go index 81d79f8..aa435f4 100644 --- a/wdgt_spinner.go +++ b/wdgt_spinner.go @@ -78,27 +78,28 @@ func (w *Spinner) Draw(screen tcell.Screen) { screen.SetContent(w.x, w.y, w.frames[w.currentFrame], nil, w.style) } -func (w *Spinner) Active() bool { return false } -func (w *Spinner) SetActive(a bool) {} -func (w *Spinner) Visible() bool { return w.visible } -func (w *Spinner) SetVisible(v bool) { w.visible = v } -func (w *Spinner) Focusable() bool { return false } -func (w *Spinner) SetFocusable(t bool) {} -func (w *Spinner) SetX(x int) { w.x = x } -func (w *Spinner) SetY(y int) { w.y = y } -func (w *Spinner) GetX() int { return w.x } -func (w *Spinner) GetY() int { return w.y } -func (w *Spinner) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Spinner) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y } -func (w *Spinner) SetSize(size Coord) {} -func (w *Spinner) SetW(wd int) {} -func (w *Spinner) SetH(h int) {} -func (w *Spinner) GetW() int { return 1 } -func (w *Spinner) GetH() int { return 1 } -func (w *Spinner) WantW() int { return 1 } -func (w *Spinner) WantH() int { return 1 } -func (w *Spinner) MinW() int { return 1 } -func (w *Spinner) MinH() int { return 1 } +func (w *Spinner) SetStyle(s tcell.Style) { w.style = s } +func (w *Spinner) Active() bool { return false } +func (w *Spinner) SetActive(a bool) {} +func (w *Spinner) Visible() bool { return w.visible } +func (w *Spinner) SetVisible(v bool) { w.visible = v } +func (w *Spinner) Focusable() bool { return false } +func (w *Spinner) SetFocusable(t bool) {} +func (w *Spinner) SetX(x int) { w.x = x } +func (w *Spinner) SetY(y int) { w.y = y } +func (w *Spinner) GetX() int { return w.x } +func (w *Spinner) GetY() int { return w.y } +func (w *Spinner) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Spinner) SetPos(pos Coord) { w.x, w.y = pos.X, pos.Y } +func (w *Spinner) SetSize(size Coord) {} +func (w *Spinner) SetW(wd int) {} +func (w *Spinner) SetH(h int) {} +func (w *Spinner) GetW() int { return 1 } +func (w *Spinner) GetH() int { return 1 } +func (w *Spinner) WantW() int { return 1 } +func (w *Spinner) WantH() int { return 1 } +func (w *Spinner) MinW() int { return 1 } +func (w *Spinner) MinH() int { return 1 } func (w *Spinner) SetFrames(frames []rune) { w.frames = frames diff --git a/wdgt_stacked_layout.go b/wdgt_stacked_layout.go index 80a6bf8..033837a 100644 --- a/wdgt_stacked_layout.go +++ b/wdgt_stacked_layout.go @@ -153,7 +153,8 @@ func (w *ScrollingWidgetList) Draw(screen tcell.Screen) { } } -func (w *ScrollingWidgetList) Active() bool { return w.active } +func (w *ScrollingWidgetList) SetStyle(s tcell.Style) { w.style = s } +func (w *ScrollingWidgetList) Active() bool { return w.active } func (w *ScrollingWidgetList) SetActive(a bool) { w.active = a if w.active { diff --git a/wdgt_table.go b/wdgt_table.go index 79bec88..3ed3612 100644 --- a/wdgt_table.go +++ b/wdgt_table.go @@ -149,20 +149,21 @@ func (w *Table) Draw(screen tcell.Screen) { } } -func (w *Table) Active() bool { return w.active } -func (w *Table) SetActive(a bool) { w.active = a } -func (w *Table) Visible() bool { return w.visible } -func (w *Table) SetVisible(a bool) { w.visible = a } -func (w *Table) SetX(x int) { w.x = x } -func (w *Table) SetY(y int) { w.y = y } -func (w *Table) GetX() int { return w.x } -func (w *Table) GetY() int { return w.y } -func (w *Table) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Table) SetPos(c Coord) { w.x, w.y = c.X, c.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) SetStyle(s tcell.Style) { w.style = s } +func (w *Table) Active() bool { return w.active } +func (w *Table) SetActive(a bool) { w.active = a } +func (w *Table) Visible() bool { return w.visible } +func (w *Table) SetVisible(a bool) { w.visible = a } +func (w *Table) SetX(x int) { w.x = x } +func (w *Table) SetY(y int) { w.y = y } +func (w *Table) GetX() int { return w.x } +func (w *Table) GetY() int { return w.y } +func (w *Table) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Table) SetPos(c Coord) { w.x, w.y = c.X, c.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 { if w.minimized { diff --git a/wdgt_text.go b/wdgt_text.go index 6710565..9dc3b58 100644 --- a/wdgt_text.go +++ b/wdgt_text.go @@ -82,27 +82,28 @@ func (w *Text) Draw(screen tcell.Screen) { } } -func (w *Text) Active() bool { return w.active } -func (w *Text) SetActive(a bool) { w.active = a } -func (w *Text) Visible() bool { return w.visible } -func (w *Text) SetVisible(a bool) { w.visible = a } -func (w *Text) SetX(x int) { w.x = x } -func (w *Text) SetY(y int) { w.y = y } -func (w *Text) GetX() int { return w.x } -func (w *Text) GetY() int { return w.y } -func (w *Text) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *Text) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *Text) SetW(x int) { w.w = x } -func (w *Text) SetH(y int) { w.h = y } -func (w *Text) GetW() int { return w.w } -func (w *Text) GetH() int { return w.h } -func (w *Text) WantW() int { return wh.Longest(w.message) } -func (w *Text) WantH() int { return len(w.message) } -func (w *Text) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *Text) Active() bool { return w.active } +func (w *Text) SetActive(a bool) { w.active = a } +func (w *Text) Visible() bool { return w.visible } +func (w *Text) SetVisible(a bool) { w.visible = a } +func (w *Text) SetX(x int) { w.x = x } +func (w *Text) SetY(y int) { w.y = y } +func (w *Text) GetX() int { return w.x } +func (w *Text) GetY() int { return w.y } +func (w *Text) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *Text) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *Text) SetW(x int) { w.w = x } +func (w *Text) SetH(y int) { w.h = y } +func (w *Text) GetW() int { return w.w } +func (w *Text) GetH() int { return w.h } +func (w *Text) WantW() int { return wh.Longest(w.message) } +func (w *Text) WantH() int { return len(w.message) } +func (w *Text) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +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) { w.text = txt diff --git a/wdgt_timefield.go b/wdgt_timefield.go index 41b4afc..e2b66a2 100644 --- a/wdgt_timefield.go +++ b/wdgt_timefield.go @@ -181,25 +181,26 @@ func (w *TimeField) Draw(screen tcell.Screen) { } } -func (w *TimeField) Active() bool { return w.active } -func (w *TimeField) SetActive(a bool) { w.active = a } -func (w *TimeField) Visible() bool { return w.visible } -func (w *TimeField) SetVisible(a bool) { w.visible = a } -func (w *TimeField) SetX(x int) { w.x = x } -func (w *TimeField) SetY(y int) { w.y = y } -func (w *TimeField) GetX() int { return w.x } -func (w *TimeField) GetY() int { return w.y } -func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} } -func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y } -func (w *TimeField) SetW(x int) { w.w = x } -func (w *TimeField) SetH(y int) { w.h = y } -func (w *TimeField) GetW() int { return w.w } -func (w *TimeField) GetH() int { return w.y } -func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y } -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) SetStyle(s tcell.Style) { w.style = s } +func (w *TimeField) Active() bool { return w.active } +func (w *TimeField) SetActive(a bool) { w.active = a } +func (w *TimeField) Visible() bool { return w.visible } +func (w *TimeField) SetVisible(a bool) { w.visible = a } +func (w *TimeField) SetX(x int) { w.x = x } +func (w *TimeField) SetY(y int) { w.y = y } +func (w *TimeField) GetX() int { return w.x } +func (w *TimeField) GetY() int { return w.y } +func (w *TimeField) GetPos() Coord { return Coord{X: w.x, Y: w.y} } +func (w *TimeField) SetPos(c Coord) { w.x, w.y = c.X, c.Y } +func (w *TimeField) SetW(x int) { w.w = x } +func (w *TimeField) SetH(y int) { w.h = y } +func (w *TimeField) GetW() int { return w.w } +func (w *TimeField) GetH() int { return w.y } +func (w *TimeField) SetSize(c Coord) { w.w, w.h = c.X, c.Y } +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 { wdt := 0 if w.fldYear.Visible() { diff --git a/wdgt_top_menu_layout.go b/wdgt_top_menu_layout.go index d4025a2..2c89667 100644 --- a/wdgt_top_menu_layout.go +++ b/wdgt_top_menu_layout.go @@ -158,7 +158,8 @@ func (w *TopMenuLayout) Draw(screen tcell.Screen) { } } -func (w *TopMenuLayout) Active() bool { return w.active } +func (w *TopMenuLayout) SetStyle(s tcell.Style) { w.style = s } +func (w *TopMenuLayout) Active() bool { return w.active } func (w *TopMenuLayout) SetActive(a bool) { w.active = a if w.widget != nil { diff --git a/widget.go b/widget.go index db9af8b..1669143 100644 --- a/widget.go +++ b/widget.go @@ -38,6 +38,7 @@ type Widget interface { SetKeyMap(km *KeyMap) Draw(tcell.Screen) + SetStyle(tcell.Style) Active() bool SetActive(bool) Visible() bool