diff options
| author | Jeff Carr <[email protected]> | 2024-01-04 22:02:12 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-04 22:02:12 -0600 |
| commit | d69a41a295aca9cd40449d4d4840265defb4e3de (patch) | |
| tree | 2d271f659e94a6bbbd20db93943d0cf292fdfe52 /basicWindow.go | |
| parent | 54b576b69d9ff0afcb50124fe72bcee8f6e6a2f8 (diff) | |
switch log to BasicWindow()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'basicWindow.go')
| -rw-r--r-- | basicWindow.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/basicWindow.go b/basicWindow.go new file mode 100644 index 0000000..ba4f0bf --- /dev/null +++ b/basicWindow.go @@ -0,0 +1,64 @@ +/* + A Standard Window +*/ +package gadgets + +import ( + "go.wit.com/log" + "go.wit.com/gui/gui" +) + +type BasicWindow struct { + hidden bool + name string + + p *gui.Node // parent widget + win *gui.Node // window widget + box *gui.Node // box + + Custom func() +} + +func (w *BasicWindow) Hide() { + w.win.Hide() + w.hidden = true + return +} + +func (w *BasicWindow) Show() { + w.win.Show() + w.hidden = false + return +} + +func (w *BasicWindow) Toggle() { + if w.hidden { + w.Show() + w.hidden = false + } else { + w.Hide() + w.hidden = true + } + return +} + +func (w *BasicWindow) Box() *gui.Node { + return w.box +} + +func NewBasicWindow(parent *gui.Node, name string) *BasicWindow { + var w *BasicWindow + w = &BasicWindow { + p: parent, + name: name, + } + + // various timeout settings + w.win = w.p.NewWindow(name) + w.win.Custom = func() { + log.Println("BasicWindow.Custom() closed. TODO: handle this", w.name) + } + w.box = w.win.NewBox("hBox", true) + + return w +} |
