2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
|
2022-10-21 11:40:08 -05:00
|
|
|
func init() {
|
2023-02-25 14:05:25 -06:00
|
|
|
// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
|
|
|
|
// log(debugToolkit, "gui/toolkit init() Setting defaultBehavior = true")
|
2022-10-21 11:40:08 -05:00
|
|
|
setDefaultBehavior(true)
|
|
|
|
}
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t andlabsT) commonChange(widget string) {
|
2022-10-21 11:40:08 -05:00
|
|
|
s := t.String()
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugChange, "commonChange() START widget =", widget)
|
|
|
|
log(debugChange, "commonChange() t.String =", s)
|
2022-10-21 11:40:08 -05:00
|
|
|
if (t.OnChanged != nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
// log(debugChange, "commonChange() toolkit.OnChanged() START")
|
|
|
|
// t.OnChanged(&t)
|
|
|
|
exit("OnChanged is not implemented. TODO: FIX THIS")
|
2022-10-21 11:40:08 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if (t.Custom != nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugChange, "commonChange() START toolkit.Custom()")
|
2022-10-21 11:40:08 -05:00
|
|
|
t.Custom()
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugChange, "commonChange() END toolkit.Custom()")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (widget == "Checkbox") {
|
|
|
|
log(debugChange, "commonChange() END Need to read the Checkbox value")
|
|
|
|
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")
|
|
|
|
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")
|
2022-10-21 11:40:08 -05:00
|
|
|
return
|
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
i := t.uiCombobox.Selected()
|
|
|
|
log(debugChange, "commonChange() t.uiCombobox = ", i)
|
|
|
|
if (t.tw == nil) {
|
|
|
|
log(debugChange, "commonChange() END tw = nil")
|
|
|
|
return
|
2022-11-05 10:19:04 -05:00
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
t.tw.S = t.String()
|
|
|
|
log(debugChange, "commonChange() END tw = ", t.tw)
|
|
|
|
return
|
2022-10-21 11:40:08 -05:00
|
|
|
}
|
|
|
|
|
2022-11-05 10:19:04 -05:00
|
|
|
// 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 (?)
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t *andlabsT) broken() bool {
|
2022-10-21 11:40:08 -05:00
|
|
|
if (t.uiBox == nil) {
|
2022-11-06 12:59:24 -06:00
|
|
|
if (t.uiWindow != nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "gui.Toolkit.UiBox == nil. This is an empty window. Try to add a box")
|
2022-11-06 12:59:24 -06:00
|
|
|
t.NewBox()
|
|
|
|
return false
|
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "gui.Toolkit.UiBox == nil. I can't add a widget without a place to put it")
|
|
|
|
// log(debugToolkit, "probably could just make a box here?")
|
2022-10-21 11:40:08 -05:00
|
|
|
// corruption or something horrible?
|
|
|
|
panic("wit/gui toolkit/andlabs func broken() invalid goroutine access into this toolkit?")
|
2022-11-05 10:19:04 -05:00
|
|
|
panic("wit/gui toolkit/andlabs func broken() this probably should not cause the app to panic here (?)")
|
2022-10-21 11:40:08 -05:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (t.uiWindow == nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)")
|
2022-11-06 12:59:24 -06:00
|
|
|
forceDump(t)
|
2022-10-21 11:40:08 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|