summaryrefslogtreecommitdiff
path: root/smartwindow/postReady.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-07 05:46:59 -0600
committerJeff Carr <[email protected]>2024-01-07 05:46:59 -0600
commit930bdc941b1181460f4c38dc708dc53d583ab5d3 (patch)
tree725fc54433bcc5a5947922bae0fee2a6b830b346 /smartwindow/postReady.go
parent82b5717f48f258f6ea792cd4e895c0ba99cf1e11 (diff)
remove debugging options
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'smartwindow/postReady.go')
-rw-r--r--smartwindow/postReady.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/smartwindow/postReady.go b/smartwindow/postReady.go
new file mode 100644
index 0000000..bb3eab8
--- /dev/null
+++ b/smartwindow/postReady.go
@@ -0,0 +1,59 @@
+// This creates a 'smart window'
+// it should work even when it is hidden
+// from the gui toolkit plugins
+package smartwindow
+
+import (
+ "go.wit.com/log"
+ "go.wit.com/gui/gui"
+)
+
+/*
+ all these functions run after the window is Ready()
+ so they should all start with that check
+*/
+
+// reports externally if something has changed
+// since the last time it was asked about it
+func (sw *SmartWindow) Changed() bool {
+ if ! sw.Ready() {return false}
+
+ if sw.changed {
+ sw.changed = false
+ return true
+ }
+ return false
+}
+
+func (sw *SmartWindow) Show() {
+ if ! sw.Ready() {return}
+
+ log.Log(WARN, "Show() window ready =", sw.ready)
+ sw.window.Show()
+ sw.hidden = false
+}
+
+func (sw *SmartWindow) Hide() {
+ if ! sw.Ready() {return}
+
+ log.Log(WARN, "Hide() window ready =", sw.ready)
+ sw.window.Hide()
+ sw.hidden = true
+}
+
+func (sw *SmartWindow) Toggle() {
+ if ! sw.Ready() {return}
+
+ log.Log(WARN, "Toggle() window ready =", sw.ready)
+ if sw.hidden {
+ sw.Show()
+ } else {
+ sw.Hide()
+ }
+}
+
+func (sw *SmartWindow) Box() *gui.Node {
+ if ! sw.Ready() {return nil}
+
+ return sw.window.Box()
+}