summaryrefslogtreecommitdiff
path: root/node.go
blob: c4641f5600f8db81586eddf615d0c1d8ae089f6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package gui

// import "git.wit.org/wit/gui/toolkit"

/*
	generic function to create a new node on the binary tree
*/
func (n *Node) New(title string) *Node {
	var newN *Node

	newN = addNode(title, n.Width, n.Height)

	n.Append(newN)
	newN.parent = n
	return newN
}

/*
	raw create function for a new node struct
*/
func addNode(title string, width int, height int) *Node {
	var n Node

	n.Name = title
	n.Width = width
	n.Height = height

	n.Widget.Name = title
	n.Widget.Width = width
	n.Widget.Height = height

	// no longer a string
	// id := Config.prefix + strconv.Itoa(Config.counter)
	// n.id = id

	n.id = Config.counter
	Config.counter += 1

	return &n
}