2022-10-16 08:07:13 -05:00
|
|
|
package toolkit
|
|
|
|
|
|
|
|
import "log"
|
2022-10-19 13:23:22 -05:00
|
|
|
import "os"
|
2022-10-16 08:07:13 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
// func NewSlider(b *ui.Box, name string *Toolkit {
|
|
|
|
func (t Toolkit) NewSlider(title string, x int, y int) *Toolkit {
|
2022-10-16 08:07:13 -05:00
|
|
|
// make new node here
|
2022-10-20 06:55:42 -05:00
|
|
|
log.Println("gui.Toolkit.NewSpinbox()", x, y)
|
2022-10-19 13:23:22 -05:00
|
|
|
var newt Toolkit
|
2022-10-16 08:07:13 -05:00
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
if (t.uiBox == nil) {
|
2022-10-20 06:55:42 -05:00
|
|
|
log.Println("gui.ToolkitNode.NewGroup() node.UiBox == nil. I can't add a range UI element without a place to put it")
|
2022-10-19 13:23:22 -05:00
|
|
|
log.Println("probably could just make a box here?")
|
|
|
|
os.Exit(0)
|
|
|
|
return nil
|
2022-10-16 08:07:13 -05:00
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
|
2022-10-16 08:07:13 -05:00
|
|
|
s := ui.NewSlider(x, y)
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.uiSlider = s
|
|
|
|
newt.uiBox = t.uiBox
|
2022-10-21 11:40:08 -05:00
|
|
|
t.uiBox.Append(s, stretchy)
|
2022-10-16 08:07:13 -05:00
|
|
|
|
|
|
|
s.OnChanged(func(spin *ui.Slider) {
|
|
|
|
i := spin.Value()
|
2022-10-20 06:55:42 -05:00
|
|
|
log.Println("gui.Toolkit.ui.Slider.OnChanged() val =", i)
|
2022-10-16 08:07:13 -05:00
|
|
|
if (DebugToolkit) {
|
2022-10-20 06:55:42 -05:00
|
|
|
log.Println("gui.Toolkit.ui.OnChanged() val =", i)
|
2022-10-16 08:07:13 -05:00
|
|
|
scs := spew.ConfigState{MaxDepth: 1}
|
2022-10-19 13:23:22 -05:00
|
|
|
scs.Dump(newt)
|
2022-10-16 08:07:13 -05:00
|
|
|
}
|
2022-10-20 06:55:42 -05:00
|
|
|
if (newt.OnChanged != nil) {
|
|
|
|
log.Println("gui.Toolkit.OnChanged() trying to run toolkit.OnChanged() entered val =", i)
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.OnChanged(&newt)
|
2022-10-20 06:55:42 -05:00
|
|
|
return
|
2022-10-16 08:07:13 -05:00
|
|
|
}
|
2022-10-20 06:55:42 -05:00
|
|
|
if (newt.Custom != nil) {
|
|
|
|
log.Println("gui.Toolkit.OnChanged() Running toolkit.Custom()")
|
|
|
|
newt.Custom()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Println("gui.Toolkit.OnChanged() ENDED without finding any callback")
|
2022-10-16 08:07:13 -05:00
|
|
|
})
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
return &newt
|
2022-10-16 08:07:13 -05:00
|
|
|
}
|