2022-10-21 11:40:08 -05:00
|
|
|
package toolkit
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
|
|
|
func init() {
|
2022-11-06 19:57:20 -06:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui/toolkit init() Setting defaultBehavior = true")
|
|
|
|
}
|
2022-10-21 11:40:08 -05:00
|
|
|
setDefaultBehavior(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t Toolkit) commonChange(widget string) {
|
|
|
|
s := t.String()
|
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui.Toolkit.ui.OnChanged() =", s)
|
|
|
|
}
|
|
|
|
if (t.OnChanged != nil) {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", s)
|
|
|
|
}
|
2022-10-21 11:40:08 -05:00
|
|
|
t.OnChanged(&t)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (t.Custom != nil) {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()")
|
|
|
|
t.Dump()
|
|
|
|
}
|
2022-10-21 11:40:08 -05:00
|
|
|
t.Custom()
|
|
|
|
return
|
|
|
|
}
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback")
|
|
|
|
}
|
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-06 12:59:24 -06:00
|
|
|
func (t *Toolkit) 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) {
|
2022-11-06 19:57:20 -06:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("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
|
|
|
|
}
|
2022-10-21 11:40:08 -05:00
|
|
|
log.Println("gui.Toolkit.UiBox == nil. I can't add a widget without a place to put it")
|
|
|
|
// log.Println("probably could just make a box here?")
|
|
|
|
// 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) {
|
|
|
|
log.Println("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
|
|
|
|
}
|