2022-10-19 13:23:22 -05:00
|
|
|
package gui
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
import "git.wit.org/wit/gui/toolkit"
|
2022-11-13 08:53:03 -06:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
/*
|
|
|
|
generic function to create a new node on the binary tree
|
|
|
|
*/
|
2023-03-01 11:35:36 -06:00
|
|
|
func (n *Node) New(title string, t toolkit.WidgetType, custom func()) *Node {
|
2022-10-19 13:23:22 -05:00
|
|
|
var newN *Node
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
newN = addNode(title)
|
|
|
|
newN.widget.Type = t
|
|
|
|
newN.widget.Action = "New"
|
|
|
|
newN.Custom = custom
|
|
|
|
|
|
|
|
// TODO: This should not be defined for each widget. This has to be stupid
|
|
|
|
// or wait a second, is this where I send something to a channel?
|
|
|
|
newN.widget.Custom = func() {
|
|
|
|
if (newN.Custom == nil) {
|
|
|
|
log(debugChange, "newT.Custom() == nil. Not doing anything. SEND SOMETHING TO THE CHANNEL")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log(debugChange, "newT.Custom() START SEND SOMETHING TO THE CHANNEL widget.Name =", newN.widget.Name)
|
|
|
|
// send something to the channel here????
|
|
|
|
newN.Custom()
|
|
|
|
log(debugChange, "newT.Custom() END SEND SOMETHING TO THE CHANNEL widget.Name =", newN.widget.Name)
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
|
|
|
|
n.Append(newN)
|
|
|
|
newN.parent = n
|
|
|
|
return newN
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
raw create function for a new node struct
|
|
|
|
*/
|
2023-03-01 11:35:36 -06:00
|
|
|
func addNode(title string) *Node {
|
2023-02-25 14:05:25 -06:00
|
|
|
n := new(Node)
|
2022-10-19 13:23:22 -05:00
|
|
|
n.Name = title
|
2023-03-01 11:35:36 -06:00
|
|
|
n.widget.Name = title
|
2022-11-06 12:59:24 -06:00
|
|
|
|
|
|
|
n.id = Config.counter
|
2022-10-19 13:23:22 -05:00
|
|
|
Config.counter += 1
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
return n
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|