Bold button when active

This commit is contained in:
2026-02-26 08:36:19 -06:00
parent 18ead7b486
commit d4ec3f210c

View File

@@ -79,16 +79,20 @@ func (w *Button) Draw(screen tcell.Screen) {
if !w.visible {
return
}
dStyle := w.style.Dim(!w.active)
dStyle := w.style.Dim(!w.active).Bold(w.active)
lbl := w.label
switch w.h {
case 1:
lbl := w.label
lb, rb := "[", "]"
if w.active {
lb, rb = ">", "<"
}
if w.w < len(lbl) {
lbl = lbl[:w.w]
} else if w.w == len(w.label)+2 {
lbl = fmt.Sprintf("[%s]", lbl)
lbl = fmt.Sprintf("%s%s%s", lb, lbl, rb)
} else if w.w > len(w.label)+2 {
lbl = fmt.Sprintf("[%s]", wh.Center(lbl, w.w-2))
lbl = fmt.Sprintf("%s%s%s", lb, wh.Center(lbl, w.w-2), rb)
}
wh.DrawText(w.x, w.y, lbl, dStyle, screen)
return
@@ -111,7 +115,7 @@ func (w *Button) Draw(screen tcell.Screen) {
wh.DrawText(w.x, w.y, "[]", dStyle, screen)
return
}
lbl := wh.Center(w.label, w.w-2)
lbl = wh.Center(w.label, w.w-2)
wh.DrawText(w.x, w.y, fmt.Sprintf("╭%s╮", strings.Repeat("─", w.w-2)), dStyle, screen)
wh.DrawText(w.x, w.y+1, fmt.Sprintf("│%s│", wh.Center(lbl, w.w-2)), dStyle, screen)
wh.DrawText(w.x, w.y+2, fmt.Sprintf("╰%s╯", strings.Repeat("─", w.w-2)), dStyle, screen)