summaryrefslogtreecommitdiff
path: root/basicWindow.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-18 05:04:18 -0600
committerJeff Carr <[email protected]>2024-01-18 05:04:18 -0600
commita8d95fef8d0879a3e3ecdac76ab4df4fee658fcf (patch)
treed870cdb3147828e2a93bb99a84925b07b719216d /basicWindow.go
parent76d6da5505900c50b72e3c84e86a521d9bcbc6bd (diff)
lots of syntax changesv0.12.8
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'basicWindow.go')
-rw-r--r--basicWindow.go86
1 files changed, 58 insertions, 28 deletions
diff --git a/basicWindow.go b/basicWindow.go
index 8e511cf..cc382b8 100644
--- a/basicWindow.go
+++ b/basicWindow.go
@@ -1,31 +1,31 @@
/*
- A Standard Window
+A Standard Window
*/
package gadgets
-import (
+import (
+ "go.wit.com/gui"
"go.wit.com/log"
- "go.wit.com/gui/gui"
)
type BasicWindow struct {
- ready bool
- hidden bool
+ ready bool
+ hidden bool
vertical bool
- title string
+ title string
- parent *gui.Node
- win *gui.Node // window widget
- box *gui.Node // box
+ parent *gui.Node
+ win *gui.Node // window widget
+ box *gui.Node // box
Custom func()
}
func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
var w *BasicWindow
- w = &BasicWindow {
- parent: parent,
- title: title,
+ w = &BasicWindow{
+ parent: parent,
+ title: title,
vertical: false,
}
log.Warn("NewBasicWindow() END")
@@ -34,21 +34,27 @@ func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
}
func (w *BasicWindow) Show() {
- if ! w.Ready() {return}
+ if !w.Ready() {
+ return
+ }
w.win.Show()
w.hidden = false
return
}
func (w *BasicWindow) Hide() {
- if ! w.Ready() {return}
+ if !w.Ready() {
+ return
+ }
w.win.Hide()
w.hidden = true
return
}
func (w *BasicWindow) Toggle() {
- if ! w.Ready() {return}
+ if !w.Ready() {
+ return
+ }
if w.hidden {
w.Show()
w.hidden = false
@@ -60,14 +66,18 @@ func (w *BasicWindow) Toggle() {
}
func (w *BasicWindow) Title(title string) {
- if ! w.Ready() {return}
+ if !w.Ready() {
+ return
+ }
w.win.SetText(title)
return
}
// sets this window to run os.Exit()
func (w *BasicWindow) StandardExit() {
- if ! w.Ready() {return}
+ if !w.Ready() {
+ return
+ }
w.win.Custom = func() {
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
@@ -81,21 +91,31 @@ func (w *BasicWindow) StandardExit() {
// Returns true if initialized
func (w *BasicWindow) Initialized() bool {
- if w == nil {return false}
- if w.parent == nil {return false}
+ if w == nil {
+ return false
+ }
+ if w.parent == nil {
+ return false
+ }
return true
}
// Returns true if the status is valid
func (w *BasicWindow) Ready() bool {
- if ! w.Initialized() {return false}
- if ! w.parent.Ready() {return false}
+ if !w.Initialized() {
+ return false
+ }
+ if !w.parent.Ready() {
+ return false
+ }
return w.ready
}
func (w *BasicWindow) Box() *gui.Node {
- if ! w.Initialized() {return nil}
- if (w.win == nil) {
+ if !w.Initialized() {
+ return nil
+ }
+ if w.win == nil {
w.Draw()
}
return w.box
@@ -103,20 +123,26 @@ func (w *BasicWindow) Box() *gui.Node {
func (w *BasicWindow) Vertical() {
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
- if w == nil {return}
+ if w == nil {
+ return
+ }
w.vertical = true
log.Warn("BasicWindow() Vertical() END w.vertical =", w.vertical, w.title)
}
func (w *BasicWindow) Horizontal() {
log.Warn("BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title)
- if w == nil {return}
+ if w == nil {
+ return
+ }
w.vertical = false
log.Warn("BasicWindow() Horizontal() END w.vertical =", w.vertical, w.title)
}
func (w *BasicWindow) Make() {
- if ! w.Initialized() {return}
+ if !w.Initialized() {
+ return
+ }
if w.win != nil {
log.Warn("BasicWindow.Make() window was already created")
return
@@ -148,7 +174,9 @@ func (w *BasicWindow) Make() {
}
func (w *BasicWindow) TestDraw() {
- if ! w.Initialized() {return}
+ if !w.Initialized() {
+ return
+ }
if w.win == nil {
log.Warn("BasicWindow.TestDraw() can't draw on window == nil")
w.Make()
@@ -158,7 +186,9 @@ func (w *BasicWindow) TestDraw() {
}
func (w *BasicWindow) Draw() {
- if ! w.Initialized() {return}
+ if !w.Initialized() {
+ return
+ }
if w.win != nil {
log.Warn("BasicWindow.Draw() window was already created")
w.Make()