From 2141e04328dcf4e4d6857fcc0a7cb551fc84fa07 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 16 Oct 2022 08:07:13 -0500 Subject: Add slander and spinbox in toolkit/andlabs fix the helloworld demo move slider into toolkit/ move more into the toolkit directory add spinbox() fix example minor update fix examples Fix andlabs.ui.Slider() to work again correctly implement custom OnChange() callback Signed-off-by: Jeff Carr --- toolkit/andlabs/slider.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 toolkit/andlabs/slider.go (limited to 'toolkit/andlabs/slider.go') diff --git a/toolkit/andlabs/slider.go b/toolkit/andlabs/slider.go new file mode 100644 index 0000000..930c514 --- /dev/null +++ b/toolkit/andlabs/slider.go @@ -0,0 +1,38 @@ +package toolkit + +import "log" + +import "github.com/andlabs/ui" +import _ "github.com/andlabs/ui/winmanifest" + +import "github.com/davecgh/go-spew/spew" + +func NewSlider(b *ui.Box, name string, x int, y int) *Toolkit { + // make new node here + log.Println("gui.Toolbox.NewSpinbox()", x, y) + var t Toolkit + + if (b == nil) { + log.Println("gui.ToolboxNode.NewSpinbox() node.UiBox == nil. I can't add a range UI element without a place to put it") + return &t + } + s := ui.NewSlider(x, y) + t.uiSlider = s + t.uiBox = b + t.uiBox.Append(s, false) + + s.OnChanged(func(spin *ui.Slider) { + i := spin.Value() + if (DebugToolkit) { + log.Println("gui.Toolbox.ui.OnChanged() val =", i) + scs := spew.ConfigState{MaxDepth: 1} + scs.Dump(t) + } + if (t.OnChanged != nil) { + log.Println("gui.Toolbox.OnChanged() entered val =", i) + t.OnChanged(&t) + } + }) + + return &t +} -- cgit v1.2.3