2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-20 06:55:42 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
2022-10-20 06:55:42 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
)
|
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
func (t *andlabsT) newSpinner(w *toolkit.Widget) *andlabsT {
|
2022-10-20 06:55:42 -05:00
|
|
|
// make new node here
|
2023-03-01 11:35:36 -06:00
|
|
|
log(debugToolkit, "newSpinner()", w.X, w.Y)
|
2022-11-14 14:30:28 -06:00
|
|
|
var newt andlabsT
|
2022-10-20 06:55:42 -05:00
|
|
|
|
|
|
|
if (t.uiBox == nil) {
|
2023-03-01 11:35:36 -06:00
|
|
|
log(debugToolkit, "newSpinner() node.UiBox == nil. I can't add a range UI element without a place to put it")
|
2022-10-20 06:55:42 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
s := ui.NewSpinbox(w.X, w.Y)
|
2022-10-20 06:55:42 -05:00
|
|
|
newt.uiSpinbox = s
|
|
|
|
newt.uiBox = t.uiBox
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.tw = w
|
2022-10-21 11:40:08 -05:00
|
|
|
t.uiBox.Append(s, stretchy)
|
2022-10-20 06:55:42 -05:00
|
|
|
|
|
|
|
s.OnChanged(func(s *ui.Spinbox) {
|
2023-03-03 14:41:38 -06:00
|
|
|
newt.tw.I = newt.uiSpinbox.Value()
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.commonChange(newt.tw)
|
2022-10-20 06:55:42 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
return &newt
|
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
|
|
|
|
func newSpinner(parentW *toolkit.Widget, w *toolkit.Widget) {
|
|
|
|
var newt *andlabsT
|
|
|
|
|
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
|
|
|
log(debugToolkit, "go.andlabs.NewTab() toolkit struct == nil. name=", parentW.Name, w.Name)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
newt = t.newSpinner(w)
|
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
}
|