Bold button when active
This commit is contained in:
@@ -79,16 +79,20 @@ func (w *Button) Draw(screen tcell.Screen) {
|
|||||||
if !w.visible {
|
if !w.visible {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dStyle := w.style.Dim(!w.active)
|
dStyle := w.style.Dim(!w.active).Bold(w.active)
|
||||||
|
lbl := w.label
|
||||||
switch w.h {
|
switch w.h {
|
||||||
case 1:
|
case 1:
|
||||||
lbl := w.label
|
lb, rb := "[", "]"
|
||||||
|
if w.active {
|
||||||
|
lb, rb = ">", "<"
|
||||||
|
}
|
||||||
if w.w < len(lbl) {
|
if w.w < len(lbl) {
|
||||||
lbl = lbl[:w.w]
|
lbl = lbl[:w.w]
|
||||||
} else if w.w == len(w.label)+2 {
|
} 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 {
|
} 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)
|
wh.DrawText(w.x, w.y, lbl, dStyle, screen)
|
||||||
return
|
return
|
||||||
@@ -111,7 +115,7 @@ func (w *Button) Draw(screen tcell.Screen) {
|
|||||||
wh.DrawText(w.x, w.y, "[]", dStyle, screen)
|
wh.DrawText(w.x, w.y, "[]", dStyle, screen)
|
||||||
return
|
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, 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+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)
|
wh.DrawText(w.x, w.y+2, fmt.Sprintf("╰%s╯", strings.Repeat("─", w.w-2)), dStyle, screen)
|
||||||
|
|||||||
Reference in New Issue
Block a user