2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
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")
|
2023-02-25 14:05:25 -06:00
|
|
|
return
|
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
if (tw.Custom == nil) {
|
|
|
|
log(debugChange, "commonChange() END Widget.Custom() = nil", t.tw.Name, t.tw.Type)
|
2023-02-25 14:05:25 -06:00
|
|
|
return
|
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
tw.Custom()
|
|
|
|
log(debugChange, "commonChange() END Widget.Custom()", t.tw.Name, t.tw.Type)
|
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 (?)
|
2023-03-01 11:35:36 -06:00
|
|
|
// TODO: redo this now that WidgetType is used and send() is used to package plugins
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t *andlabsT) broken() bool {
|
2023-03-01 11:35:36 -06:00
|
|
|
if (t.parent != nil) {
|
|
|
|
return false
|
|
|
|
}
|
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-03-01 11:35:36 -06:00
|
|
|
log(debugToolkit, "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-03-01 11:35:36 -06:00
|
|
|
log(true, "UiBox == nil. I can't add a widget without a place to put it")
|
2023-02-25 14:05:25 -06:00
|
|
|
// log(debugToolkit, "probably could just make a box here?")
|
2022-10-21 11:40:08 -05:00
|
|
|
// corruption or something horrible?
|
2023-03-01 11:35:36 -06:00
|
|
|
t.Dump(true)
|
2022-10-21 11:40:08 -05:00
|
|
|
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-03-01 11:35:36 -06:00
|
|
|
log(debugToolkit, "UiWindow == nil. I can't add a widget without a place to put it (IGNORING FOR NOW)")
|
|
|
|
t.Dump(debugToolkit)
|
2022-10-21 11:40:08 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
func broken(w *toolkit.Widget) bool {
|
|
|
|
if (w == nil) {
|
|
|
|
log(true, "widget == nil. I can't do anything widget")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|