make boxes cover anything behind them
This commit is contained in:
parent
4ec1a85139
commit
bb01987b3b
15
ui/ui.go
15
ui/ui.go
@ -193,6 +193,7 @@ type Box struct {
|
||||
style tcell.Style
|
||||
cascade bool
|
||||
visible bool
|
||||
transparent bool
|
||||
}
|
||||
|
||||
func NewBox(title string, menuItems []string, contents Contents, initialStyle tcell.Style, cascade bool) *Box {
|
||||
@ -203,6 +204,7 @@ func NewBox(title string, menuItems []string, contents Contents, initialStyle tc
|
||||
style: initialStyle,
|
||||
cascade: cascade,
|
||||
visible: true,
|
||||
transparent: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,6 +225,15 @@ func (b *Box) Draw(s tcell.Screen) {
|
||||
if !b.visible {
|
||||
return
|
||||
}
|
||||
// blank out inner area
|
||||
if !b.transparent {
|
||||
for m := b.x + 1; m < b.x+b.w-1; m++ {
|
||||
for n := b.y + 1; n < b.y+b.h-1; n++ {
|
||||
s.SetContent(m, n, ' ', nil, b.style)
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw outside bars
|
||||
for m := b.x + 1; m < b.x+b.w-1; m++ {
|
||||
s.SetContent(m, b.y, tcell.RuneHLine, nil, b.style)
|
||||
s.SetContent(m, b.y+b.h-1, tcell.RuneHLine, nil, b.style)
|
||||
@ -262,6 +273,10 @@ func (b *Box) SetVisible(v bool) {
|
||||
b.visible = v
|
||||
}
|
||||
|
||||
func (b *Box) SetTransparent(v bool) {
|
||||
b.transparent = v
|
||||
}
|
||||
|
||||
func (b *Box) Contents() Contents {
|
||||
return b.contents
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user