summaryrefslogtreecommitdiff
path: root/slider.go
blob: 4ee144cf55c20f5e79f01d007f987a21935798bb (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
41
42
43
package gui

import "log"

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

func (n *Node) NewSlider(name string, x int, y int) *Node {
	var newT *toolkit.Toolkit
	var sNode *Node

	log.Println("toolkit.NewSlider() START", name)

	if (n.toolkit == nil) {
		log.Println("toolkit.NewSlider() toolkit == nil")
		panic("Toolkit should never be nil")
	}

	// make a *Node with a *toolkit.Group
	sNode = n.New(name + " part1")
	newT = n.toolkit.NewSlider(name, x, y)
	newT.Name = name
	sNode.custom = n.custom
	newT.Custom = func () {
		// TODO: make all of this common code to all the widgets
		if (n.custom == nil) {
			log.Println("Not Running n.custom(n) == nil")
		} else {
			log.Println("Running n.custom(n)")
			sNode.custom(sNode)
		}
		if (sNode.OnChanged == nil) {
			log.Println("Not Running n.OnChanged(n) == nil")
		} else {
			log.Println("Running n.OnChanged(n)")
			sNode.OnChanged(sNode)
		}
	}
	sNode.toolkit = newT
	sNode.Dump()
	// panic("checking Custom()")

	return sNode
}