andlabs: grid and checkbox to binary tree

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-27 10:04:49 -05:00
parent fbee749187
commit 46094b5a48
3 changed files with 18 additions and 20 deletions

View File

@ -42,10 +42,10 @@ func add(a toolkit.Action) {
p.newButton(n) p.newButton(n)
return return
case toolkit.Grid: case toolkit.Grid:
newGrid(&a) p.newGrid(n)
return return
case toolkit.Checkbox: case toolkit.Checkbox:
newCheckbox(&a) p.newCheckbox(n)
return return
case toolkit.Spinner: case toolkit.Spinner:
newSpinner(&a) newSpinner(&a)

View File

@ -1,20 +1,19 @@
package main package main
import ( import (
"git.wit.org/wit/gui/toolkit"
"github.com/andlabs/ui" "github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest" _ "github.com/andlabs/ui/winmanifest"
) )
func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT { func (p *node) newCheckbox(n *node) {
var newt andlabsT newt := new(andlabsT)
log(debugToolkit, "newCheckbox()", a.Name, a.WidgetType) log(debugToolkit, "newCheckbox()", n.Name, n.WidgetType)
newt.WidgetType = a.WidgetType newt.WidgetType = n.WidgetType
newt.wId = a.WidgetId newt.wId = n.WidgetId
newt.Name = a.Name newt.Name = n.Name
newt.Text = a.Text newt.Text = n.Text
newt.uiCheckbox = ui.NewCheckbox(a.Text) newt.uiCheckbox = ui.NewCheckbox(n.Text)
newt.uiControl = newt.uiCheckbox newt.uiControl = newt.uiCheckbox
newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) { newt.uiCheckbox.OnToggled(func(spin *ui.Checkbox) {
@ -23,13 +22,15 @@ func (t *andlabsT) newCheckbox(a *toolkit.Action) *andlabsT {
newt.doUserEvent() newt.doUserEvent()
}) })
return &newt n.tk = newt
p.place(n)
} }
func (t *andlabsT) checked() bool { func (t *andlabsT) checked() bool {
return t.uiCheckbox.Checked() return t.uiCheckbox.Checked()
} }
/*
func newCheckbox(a *toolkit.Action) { func newCheckbox(a *toolkit.Action) {
log(debugToolkit, "newCheckbox()", a.Name) log(debugToolkit, "newCheckbox()", a.Name)
@ -39,5 +40,5 @@ func newCheckbox(a *toolkit.Action) {
return return
} }
newt := t.newCheckbox(a) newt := t.newCheckbox(a)
place(a, t, newt)
} }
*/

View File

@ -3,8 +3,6 @@ package main
import ( import (
"github.com/andlabs/ui" "github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest" _ "github.com/andlabs/ui/winmanifest"
"git.wit.org/wit/gui/toolkit"
) )
// Grid numbering by (X,Y) // Grid numbering by (X,Y)
@ -12,19 +10,18 @@ import (
// -- (1,1) -- (2,1) -- (3,1) -- // -- (1,1) -- (2,1) -- (3,1) --
// -- (1,2) -- (2,1) -- (3,1) -- // -- (1,2) -- (2,1) -- (3,1) --
// ----------------------------- // -----------------------------
func newGrid(a *toolkit.Action) { func (p *node) newGrid(n *node) {
var newt *andlabsT var newt *andlabsT
log(debugToolkit, "newGrid()", a.WidgetId, "to", a.ParentId) log(debugToolkit, "newGrid()", n.WidgetId, "to", n.ParentId)
newt = new(andlabsT) newt = new(andlabsT)
c := ui.NewGrid() c := ui.NewGrid()
newt.uiGrid = c newt.uiGrid = c
newt.uiControl = c newt.uiControl = c
newt.WidgetType = toolkit.Grid
newt.gridX = 0 newt.gridX = 0
newt.gridY = 0 newt.gridY = 0
t := andlabs[a.ParentId] n.tk = newt
place(a, t, newt) p.place(n)
} }