Tweak window visibility changes

This commit is contained in:
Trevor Slocum 2020-10-19 10:14:42 -07:00
parent f2230ae3f8
commit 5a360ad87e
2 changed files with 14 additions and 14 deletions

View File

@ -16,7 +16,7 @@ type Window struct {
x, y int
width, height int
fullscreen bool
visible bool
hidden bool
dragX, dragY int
dragWX, dragWY int
@ -33,23 +33,22 @@ func NewWindow(primitive Primitive) *Window {
dragWY: -1,
}
w.Box.focus = w
w.visible = true
return w
}
// IsVisible returns true if the window is visible
func (w *Window) IsVisible() bool {
return w.visible
}
// Show the window.
func (w *Window) Show() {
w.visible = true
w.hidden = false
}
// Hide the window.
func (w *Window) Hide() {
w.visible = false
w.hidden = true
}
// Visible returns whether or not the window is visible.
func (w *Window) Visible() bool {
return !w.hidden
}
// SetPosition sets the position of the window.

View File

@ -73,7 +73,7 @@ func (wm *WindowManager) Draw(screen tcell.Screen) {
var hasFullScreen bool
for _, w := range wm.windows {
if !w.fullscreen || !w.IsVisible() {
if !w.fullscreen || !w.Visible() {
continue
}
@ -88,11 +88,12 @@ func (wm *WindowManager) Draw(screen tcell.Screen) {
}
for _, w := range wm.windows {
if w.IsVisible() {
w.SetBorder(true)
w.SetRect(x+w.x, x+w.y, w.width, w.height)
w.Draw(screen)
if !w.Visible() {
continue
}
w.SetBorder(true)
w.SetRect(x+w.x, x+w.y, w.width, w.height)
w.Draw(screen)
}
}