summaryrefslogtreecommitdiff
path: root/examples/buttons/main.go
blob: 87841a7e545fa46fa6c96af33e8629c4382b56f8 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This is a simple example
package main

import 	(
	"log"
	"strconv"
	"go.wit.com/gui"
	arg "github.com/alexflint/go-arg"
)

var title string = "Demo Plugin Window"
var myGui *gui.Node

var buttonCounter int = 5
var gridW int = 5
var gridH int = 3

func init() {
	arg.MustParse()
}

func main() {
	// This will turn on all debugging
	// gui.SetDebug(true)

	myGui = gui.New().Default()
	buttonWindow()

	// This is just a optional goroutine to watch that things are alive
	gui.Watchdog()
	gui.StandardExit()
}

// This creates a window
func buttonWindow() {
	var w, t, g, more, more2 *gui.Node

	log.Println("buttonWindow() START")

	w = myGui.NewWindow(title).SetText("Nueva Ventana de Botones")
	t = w.NewTab("buttonTab is this thing").Pad()
	g = t.NewGroup("buttonGroup").Pad()
	g1 := t.NewGroup("buttonGroup 2").Pad()
	more = g1.NewGroup("more").Pad()
	g1.NewButton("hello2", func () {
		log.Println("world2")
	})
	more2 = g1.NewGrid("gridnuts", gridW, gridH).Pad()

	more2.NewLabel("more2")

	g.NewButton("hello", func () {
		log.Println("world")
	})

	g.NewButton("NewButton(more)", func () {
		name := "foobar " + strconv.Itoa(buttonCounter)
		log.Println("NewButton(more) Adding button", name)
		buttonCounter += 1
		more.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewButton(more2)", func () {
		name := "foobar " + strconv.Itoa(buttonCounter)
		log.Println("NewButton(more2) Adding button", name)
		buttonCounter += 1
		more2.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewButton(more2 d)", func () {
		name := "d" + strconv.Itoa(buttonCounter)
		log.Println("NewButton(more2 d) Adding button", name)
		buttonCounter += 1
		more2.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewGroup()", func () {
		name := "neat " + strconv.Itoa(buttonCounter)
		log.Println("NewGroup() Adding button", name)
		buttonCounter += 1
		more.NewGroup(name).Pad()
	})
}