summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/common.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
committerJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
commit8dbf5a09097b7868e9218bf98716c57eac998a10 (patch)
treeab3bdfeaf5a59a55de9d2a6661d2d824090491e5 /toolkit/andlabs/common.go
parentf3bb68396afa7452ecf1c8d4744c825a9d81057c (diff)
lots cleaner code between the pluginv0.6.1
Queue() around SetText is helping userspace crashing merge forceDump(bool) into Dump() debugging output configuration is pretty clean keep cutting down duplicate things --gui-verbose flag works make label "standard" code add debug.FreeOSMemory() move the GO language internals to display in the GUI update push to do tags and go to github.com/wit-go/ remove the other license file it might be confusing golang.org and github proper WidgetType added a Quit() button Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/common.go')
-rw-r--r--toolkit/andlabs/common.go79
1 files changed, 28 insertions, 51 deletions
diff --git a/toolkit/andlabs/common.go b/toolkit/andlabs/common.go
index 94e19e1..31b73e6 100644
--- a/toolkit/andlabs/common.go
+++ b/toolkit/andlabs/common.go
@@ -1,5 +1,9 @@
package main
+import (
+ "git.wit.org/wit/gui/toolkit"
+)
+
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func init() {
// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
@@ -7,79 +11,52 @@ func init() {
setDefaultBehavior(true)
}
-func (t andlabsT) commonChange(widget string) {
- s := t.String()
- log(debugChange, "commonChange() START widget =", widget)
- log(debugChange, "commonChange() t.String =", s)
- if (t.OnChanged != nil) {
- // log(debugChange, "commonChange() toolkit.OnChanged() START")
- // t.OnChanged(&t)
- exit("OnChanged is not implemented. TODO: FIX THIS")
- return
- }
- if (t.Custom != nil) {
- log(debugChange, "commonChange() START toolkit.Custom()")
- t.Custom()
- log(debugChange, "commonChange() END toolkit.Custom()")
- return
- }
- if (widget == "Checkbox") {
- log(debugChange, "commonChange() END Need to read the Checkbox value")
+func (t andlabsT) commonChange(tw *toolkit.Widget) {
+ log(debugChange, "commonChange() START widget =", t.Name, t.Type)
+ if (tw == nil) {
+ log(true, "commonChange() What the fuck. there is no widget t.tw == nil")
return
}
- if (widget == "Dropdown") {
- t.getDropdown()
- if (t.tw == nil) {
- log(debugChange, "commonChange() END tw.Custom == nil")
- }
- if (t.tw.Custom == nil) {
- log(debugChange, "commonChange() END Dropdown (no custom())")
- }
- t.tw.Custom()
- log(debugChange, "commonChange() END Dropdown")
+ if (tw.Custom == nil) {
+ log(debugChange, "commonChange() END Widget.Custom() = nil", t.tw.Name, t.tw.Type)
return
}
- log(debugChange, "commonChange() t.String =", s)
- log(debugChange, "commonChange() ENDED without finding any callback")
-}
-
-func (t *andlabsT) getDropdown() {
- log(debugChange, "commonChange() Need to read the dropdown menu")
- if (t.uiCombobox == nil) {
- log(debugChange, "commonChange() END BAD NEWS. t.uiCombobox == nil")
- return
- }
- i := t.uiCombobox.Selected()
- log(debugChange, "commonChange() t.uiCombobox = ", i)
- if (t.tw == nil) {
- log(debugChange, "commonChange() END tw = nil")
- return
- }
- t.tw.S = t.String()
- log(debugChange, "commonChange() END tw = ", t.tw)
- return
+ tw.Custom()
+ log(debugChange, "commonChange() END Widget.Custom()", t.tw.Name, t.tw.Type)
}
// does some sanity checks on the internal structs of the binary tree
// TODO: probably this should not panic unless it's running in devel mode (?)
+// TODO: redo this now that WidgetType is used and send() is used to package plugins
func (t *andlabsT) broken() bool {
+ if (t.parent != nil) {
+ return false
+ }
if (t.uiBox == nil) {
if (t.uiWindow != nil) {
- log(debugToolkit, "gui.Toolkit.UiBox == nil. This is an empty window. Try to add a box")
+ log(debugToolkit, "UiBox == nil. This is an empty window. Try to add a box")
t.NewBox()
return false
}
- log(debugToolkit, "gui.Toolkit.UiBox == nil. I can't add a widget without a place to put it")
+ log(true, "UiBox == nil. I can't add a widget without a place to put it")
// log(debugToolkit, "probably could just make a box here?")
// corruption or something horrible?
+ t.Dump(true)
panic("wit/gui toolkit/andlabs func broken() invalid goroutine access into this toolkit?")
panic("wit/gui toolkit/andlabs func broken() this probably should not cause the app to panic here (?)")
return true
}
if (t.uiWindow == nil) {
- log(debugToolkit, "gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)")
- forceDump(t)
+ log(debugToolkit, "UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)")
+ t.Dump(debugToolkit)
return false
}
return false
}
+func broken(w *toolkit.Widget) bool {
+ if (w == nil) {
+ log(true, "widget == nil. I can't do anything widget")
+ return true
+ }
+ return false
+}