summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/spinner.go
blob: 6a47472878aebe6826b5c713c23fbe9fc53f15c0 (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 main

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

	"github.com/andlabs/ui"
	_ "github.com/andlabs/ui/winmanifest"
)

func (t *andlabsT) newSpinner(w *toolkit.Widget) *andlabsT {
	// make new node here
	log(debugToolkit, "newSpinner()", w.X, w.Y)
	var newt andlabsT

	s := ui.NewSpinbox(w.X, w.Y)
	newt.uiSpinbox = s
	newt.uiControl = s
	newt.tw = w

	s.OnChanged(func(s *ui.Spinbox) {
		newt.tw.I = newt.uiSpinbox.Value()
		newt.commonChange(newt.tw)
	})

	return &newt
}

func newSpinner(a *toolkit.Action) {
	var newt *andlabsT
	w := a.Widget
	parentW := a.Where

	t := mapToolkits[parentW]
	if (t == nil) {
		log(debugError, "NewSpinner() toolkit struct == nil. name=", parentW.Name, w.Name)
		return
	}
	w.X = a.X
	w.Y = a.Y
	newt = t.newSpinner(w)
	place(a, t, newt)
	mapWidgetsToolkits(a, newt)
}