summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/spinner.go
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/andlabs/spinner.go')
-rw-r--r--toolkit/andlabs/spinner.go64
1 files changed, 8 insertions, 56 deletions
diff --git a/toolkit/andlabs/spinner.go b/toolkit/andlabs/spinner.go
index 2e87541..6a47472 100644
--- a/toolkit/andlabs/spinner.go
+++ b/toolkit/andlabs/spinner.go
@@ -12,16 +12,10 @@ func (t *andlabsT) newSpinner(w *toolkit.Widget) *andlabsT {
log(debugToolkit, "newSpinner()", w.X, w.Y)
var newt andlabsT
- if (t.uiBox == nil) {
- log(debugToolkit, "newSpinner() node.UiBox == nil. I can't add a range UI element without a place to put it")
- return nil
- }
-
s := ui.NewSpinbox(w.X, w.Y)
newt.uiSpinbox = s
- newt.uiBox = t.uiBox
+ newt.uiControl = s
newt.tw = w
- t.uiBox.Append(s, stretchy)
s.OnChanged(func(s *ui.Spinbox) {
newt.tw.I = newt.uiSpinbox.Value()
@@ -31,61 +25,19 @@ func (t *andlabsT) newSpinner(w *toolkit.Widget) *andlabsT {
return &newt
}
-func newSpinner(parentW *toolkit.Widget, w *toolkit.Widget) {
+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)
- mapWidgetsToolkits(w, newt)
-}
-
-// This routine is very specific to this toolkit
-// It's annoying and has to be copied to each widget when there are changes
-// it could be 'simplfied' maybe or made to be more generic, but this is as far as I've gotten
-// it's probably not worth working much more on this toolkit, the andlabs/ui has been great and got me here!
-// but it's time to write direct GTK, QT, macos and windows toolkit plugins
-// -- jcarr 2023/03/09
-
-func doSpinner(p *toolkit.Widget, c *toolkit.Widget) {
- if broken(c) {
- return
- }
- log(debugChange, "Going to attempt:", c.Action)
- if (c.Action == "New") {
- newSpinner(p, c)
- return
- }
- ct := mapToolkits[c]
- if (ct == nil) {
- log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
- return
- }
- if ct.broken() {
- log(debugError, "Spinner() ct.broken", ct)
- return
- }
- if (ct.uiSpinbox == nil) {
- log(debugError, "Label() uiSpinbox == nil", ct)
- return
- }
- switch c.Action {
- case "Enable":
- ct.uiSpinbox.Enable()
- case "Disable":
- ct.uiSpinbox.Disable()
- case "Show":
- ct.uiSpinbox.Show()
- case "Hide":
- ct.uiSpinbox.Hide()
- case "Set":
- ct.uiSpinbox.SetValue(c.I)
- case "Get":
- c.I = ct.uiSpinbox.Value()
- default:
- log(debugError, "Can't do", c.Action, "to a Spinbox")
- }
+ place(a, t, newt)
+ mapWidgetsToolkits(a, newt)
}