diff --git a/window.go b/window.go index c92632f..3cb9f87 100644 --- a/window.go +++ b/window.go @@ -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. diff --git a/windowmanager.go b/windowmanager.go index ff76b9f..742fabf 100644 --- a/windowmanager.go +++ b/windowmanager.go @@ -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) } }