From e370d229323b7e87902f47f052714d8d9b52ea12 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 27 Apr 2023 10:24:52 -0500 Subject: [PATCH] andlabs: more things in the binary tree Signed-off-by: Jeff Carr --- toolkit/andlabs/add.go | 8 ++++---- toolkit/andlabs/image.go | 24 +++++------------------- toolkit/andlabs/label.go | 26 ++++++-------------------- toolkit/andlabs/slider.go | 26 +++++--------------------- toolkit/andlabs/spinner.go | 25 +++++-------------------- 5 files changed, 25 insertions(+), 84 deletions(-) diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index 4b2bc30..bebcfde 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -36,7 +36,7 @@ func add(a toolkit.Action) { p.newTab(n) return case toolkit.Label: - newLabel(&a) + p.newLabel(n) return case toolkit.Button: p.newButton(n) @@ -48,10 +48,10 @@ func add(a toolkit.Action) { p.newCheckbox(n) return case toolkit.Spinner: - newSpinner(&a) + p.newSpinner(n) return case toolkit.Slider: - newSlider(&a) + p.newSlider(n) return case toolkit.Dropdown: newDropdown(&a) @@ -69,7 +69,7 @@ func add(a toolkit.Action) { p.newBox(n) return case toolkit.Image: - newImage(&a) + p.newImage(n) return default: log(debugError, "add() error TODO: ", n.WidgetType, n.Name) diff --git a/toolkit/andlabs/image.go b/toolkit/andlabs/image.go index cb1565c..0b1f785 100644 --- a/toolkit/andlabs/image.go +++ b/toolkit/andlabs/image.go @@ -1,30 +1,15 @@ package main import ( - "git.wit.org/wit/gui/toolkit" - "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" ) -// make new Image here -func newImage(a *toolkit.Action) { - log(debugToolkit, "newImage()", a.Name) - - t := andlabs[a.ParentId] - if (t == nil) { - log(debugToolkit, "newImage() toolkit struct == nil. name=", a.Name) - listMap(debugToolkit) - } - newt := t.rawImage(a.Name) - place(a, t, newt) -} - // make new Image using andlabs/ui -func (t *andlabsT) rawImage(title string) *andlabsT { - var newt andlabsT +func (p *node) newImage(n *node) { + newt := new(andlabsT) var img *ui.Image - newt.Name = title + newt.Name = n.Name log(debugToolkit, "rawImage() create", newt.Name) @@ -33,7 +18,8 @@ func (t *andlabsT) rawImage(title string) *andlabsT { newt.uiImage = img // newt.uiControl = img - return &newt + n.tk = newt + p.place(n) } /* if (a.Name == "image") { diff --git a/toolkit/andlabs/label.go b/toolkit/andlabs/label.go index 7762827..0fa075e 100644 --- a/toolkit/andlabs/label.go +++ b/toolkit/andlabs/label.go @@ -3,30 +3,16 @@ package main import ( "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" - - "git.wit.org/wit/gui/toolkit" ) -func newLabel(a *toolkit.Action) { - var newt *andlabsT - log(debugToolkit, "NewLabel()", a.Name) +func (p *node) newLabel(n *node) { + log(logInfo, "NewLabel()", n.Name) - t := andlabs[a.ParentId] - if (t == nil) { - listMap(debugError) - log(debugError, "ERROR newLabel() listMap()") - log(debugError, "ERROR FFFFFFFFFFFF listMap()") - log(debugError, "ERROR FFFFFFFFFFFF listMap()") - return - } - - log(debugToolkit, "NewLabel()", a.Name) - - newt = new(andlabsT) - - c := ui.NewLabel(a.Name) + newt := new(andlabsT) + c := ui.NewLabel(n.Name) newt.uiLabel = c newt.uiControl = c - place(a, t, newt) + n.tk = newt + p.place(n) } diff --git a/toolkit/andlabs/slider.go b/toolkit/andlabs/slider.go index 821fa7b..16c8a8b 100644 --- a/toolkit/andlabs/slider.go +++ b/toolkit/andlabs/slider.go @@ -1,38 +1,22 @@ package main import ( - "git.wit.org/wit/gui/toolkit" - "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" ) -func (t *andlabsT) newSlider(a *toolkit.Action) *andlabsT { - var newt andlabsT +func (p *node) newSlider(n *node) { + newt := new(andlabsT) - s := ui.NewSlider(a.X, a.Y) + s := ui.NewSlider(n.X, n.Y) newt.uiSlider = s newt.uiControl = s - newt.WidgetType = toolkit.Slider - newt.wId = a.WidgetId s.OnChanged(func(spin *ui.Slider) { newt.i = newt.uiSlider.Value() newt.doUserEvent() }) - return &newt -} - -func newSlider(a *toolkit.Action) { - var newt *andlabsT - log(debugToolkit, "newSlider()", a.Name) - - t := andlabs[a.ParentId] - if (t == nil) { - log(debugError, "newSlider() ERROR toolkit struct == nil. name=", a.Name) - return - } - newt = t.newSlider(a) - place(a, t, newt) + n.tk = newt + p.place(n) } diff --git a/toolkit/andlabs/spinner.go b/toolkit/andlabs/spinner.go index fe2ac15..e52579c 100644 --- a/toolkit/andlabs/spinner.go +++ b/toolkit/andlabs/spinner.go @@ -1,37 +1,22 @@ package main import ( - "git.wit.org/wit/gui/toolkit" - "github.com/andlabs/ui" _ "github.com/andlabs/ui/winmanifest" ) -func (t *andlabsT) newSpinner(a *toolkit.Action) *andlabsT { - var newt andlabsT +func (p *node) newSpinner(n *node) { + newt := new(andlabsT) - s := ui.NewSpinbox(a.X, a.Y) + s := ui.NewSpinbox(n.X, n.Y) newt.uiSpinbox = s newt.uiControl = s - newt.wId = a.WidgetId - newt.WidgetType = toolkit.Spinner s.OnChanged(func(s *ui.Spinbox) { newt.i = newt.uiSpinbox.Value() newt.doUserEvent() }) - return &newt -} - -func newSpinner(a *toolkit.Action) { - var newt *andlabsT - - t := andlabs[a.ParentId] - if (t == nil) { - log(debugError, "NewSpinner() toolkit struct == nil. name=", a.Name) - return - } - newt = t.newSpinner(a) - place(a, t, newt) + n.tk = newt + p.place(n) }