Browse Source

Tweak window visibility changes

tablepad
Trevor Slocum 9 months ago
parent
commit
5a360ad87e
  1. 17
      window.go
  2. 11
      windowmanager.go

17
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.

11
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)
}
}

Loading…
Cancel
Save