2022-10-16 08:07:13 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
/*
|
|
|
|
Get the int from the gui toolkit
|
|
|
|
because eventually this gui package should become it's own seperate go routine and never interact from the
|
|
|
|
gui subroutine back into the upstream application using the gui package
|
2022-10-16 08:07:13 -05:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
TODO: instead store the int in the Node structure? (this is probably a better idea)
|
|
|
|
because technically every interaction with the toolkit has to go through the Queue() goroutine.
|
|
|
|
Is it "has to go" or "should go"? Probably it makes sense to strictly inforce it. No "callback" functions. IPC only (go channels)
|
|
|
|
*/
|
2022-10-16 08:07:13 -05:00
|
|
|
func (n *Node) Int() int {
|
2022-10-21 11:40:08 -05:00
|
|
|
if (toolkit.DebugToolkit) {
|
2022-10-16 08:07:13 -05:00
|
|
|
log.Println("gui.Node.Int() for node name =", n.Name)
|
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
|
|
|
scs.Dump(n)
|
|
|
|
}
|
|
|
|
|
2022-10-20 06:55:42 -05:00
|
|
|
if (n.toolkit == nil) {
|
2022-10-16 08:07:13 -05:00
|
|
|
log.Println("gui.Node.Int() for toolkit struct = nil")
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-10-20 06:55:42 -05:00
|
|
|
i := n.toolkit.Value()
|
2022-10-16 08:07:13 -05:00
|
|
|
return i
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
|
|
|
|
// which name to use?
|
|
|
|
func (n *Node) Value() int {
|
|
|
|
return n.Int()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) SetValue(i int) {
|
|
|
|
log.Println("gui.SetValue() START")
|
2022-10-20 06:55:42 -05:00
|
|
|
if (n.toolkit == nil) {
|
2022-10-19 13:23:22 -05:00
|
|
|
log.Println("gui.Node.SetValue() for toolkit struct = nil")
|
|
|
|
panic("SetValue failed")
|
|
|
|
}
|
|
|
|
n.Dump()
|
2022-10-20 06:55:42 -05:00
|
|
|
n.toolkit.Dump()
|
|
|
|
n.toolkit.SetValue(i)
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|