2021-10-06 08:36:28 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 11:56:52 -05:00
|
|
|
import (
|
|
|
|
"log"
|
2021-10-06 08:36:28 -05:00
|
|
|
|
2021-10-06 11:56:52 -05:00
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
)
|
|
|
|
|
|
|
|
// https://ieftimov.com/post/golang-datastructures-trees/
|
2021-10-06 08:36:28 -05:00
|
|
|
|
|
|
|
type Node struct {
|
2021-10-06 11:58:39 -05:00
|
|
|
id string
|
2021-10-06 11:56:52 -05:00
|
|
|
Name string
|
|
|
|
Width int
|
|
|
|
Height int
|
2021-10-06 08:36:28 -05:00
|
|
|
|
2021-10-06 11:56:52 -05:00
|
|
|
uiType *ui.Control
|
2021-10-06 11:58:39 -05:00
|
|
|
children []*Node
|
2021-10-06 08:36:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (n Node) SetName(name string) {
|
|
|
|
// n.uiType.SetName(name)
|
|
|
|
log.Println("n.uiType =", n.uiType)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Node) Append(child Node) {
|
2021-10-06 11:56:52 -05:00
|
|
|
// if (n.UiBox == nil) {
|
|
|
|
// return
|
|
|
|
// }
|
2021-10-06 08:36:28 -05:00
|
|
|
// n.uiType.Append(child, x)
|
|
|
|
}
|
2021-10-06 11:56:52 -05:00
|
|
|
|
|
|
|
func findByIdDFS(node *Node, id string) *Node {
|
|
|
|
if node.id == id {
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(node.children) > 0 {
|
|
|
|
for _, child := range node.children {
|
|
|
|
findByIdDFS(child, id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|