andlabs grid placement still broken
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
15f00451b7
commit
9934f932ca
|
@ -14,6 +14,7 @@ func (n *Node) NewButton(name string, custom func()) *Node {
|
|||
return newNode
|
||||
}
|
||||
|
||||
/*
|
||||
// deprecate this once andlabs is refactored
|
||||
func callback(i int) bool {
|
||||
log(debugError, "callback() for widget id =", i)
|
||||
|
@ -27,6 +28,7 @@ func callback(i int) bool {
|
|||
n.Custom()
|
||||
return true
|
||||
}
|
||||
*/
|
||||
|
||||
// find widget by number
|
||||
func (n *Node) FindId(i int) (*Node) {
|
||||
|
|
31
grid.go
31
grid.go
|
@ -27,10 +27,8 @@ func (n *Node) NewGrid(name string, w int, h int) *Node {
|
|||
log(debugChange, "click() NewGrid not defined =", name)
|
||||
})
|
||||
|
||||
var a toolkit.Action
|
||||
a.ActionType = toolkit.Add
|
||||
a.Name = name
|
||||
a.Text = name
|
||||
a := newAction(n, toolkit.Add)
|
||||
|
||||
a.X = w
|
||||
a.Y = h
|
||||
newNode.X = w
|
||||
|
@ -38,29 +36,20 @@ func (n *Node) NewGrid(name string, w int, h int) *Node {
|
|||
newNode.NextX = 1
|
||||
newNode.NextY = 1
|
||||
|
||||
/*
|
||||
// fix values here if they are invalid. Index starts at 1
|
||||
if (where.NextX < 1) {
|
||||
where.NextX = 1
|
||||
}
|
||||
if (where.NextY < 1) {
|
||||
where.NextY = 1
|
||||
}
|
||||
//
|
||||
a.X = where.NextX
|
||||
a.Y = where.NextY
|
||||
*/
|
||||
sendAction(a, newNode, n)
|
||||
|
||||
newaction(&a, newNode, n)
|
||||
return newNode
|
||||
}
|
||||
|
||||
/*
|
||||
// increments where the next element in the grid should go
|
||||
func placeGrid(a *toolkit.Action, n *Node, where *Node) {
|
||||
where.NextY += 1
|
||||
if (where.NextY > where.Y) {
|
||||
where.NextX += 1
|
||||
where.NextY = 1
|
||||
}
|
||||
log(logInfo, "Action() END size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
|
||||
*/
|
||||
|
||||
return newNode
|
||||
a.X = where.NextX
|
||||
a.Y = where.NextY
|
||||
log(logNow, "placeGrid() (X,Y)", where.X, where.Y, " next(X,Y) =", where.NextX, where.NextY)
|
||||
}
|
||||
|
|
9
label.go
9
label.go
|
@ -7,11 +7,10 @@ import (
|
|||
func (n *Node) NewLabel(text string) *Node {
|
||||
newNode := n.newNode(text, toolkit.Label, nil)
|
||||
|
||||
var a toolkit.Action
|
||||
a.ActionType = toolkit.Add
|
||||
a.Name = text
|
||||
a.Text = text
|
||||
newaction(&a, newNode, n)
|
||||
n.Name = text
|
||||
n.Text = text
|
||||
a := newAction(n, toolkit.Add)
|
||||
sendAction(a, newNode, n)
|
||||
|
||||
return newNode
|
||||
}
|
||||
|
|
23
plugin.go
23
plugin.go
|
@ -203,6 +203,24 @@ func initToolkit(name string, filename string) *aplug {
|
|||
return newPlug
|
||||
}
|
||||
|
||||
func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
|
||||
var a toolkit.Action
|
||||
a.ActionType = atype
|
||||
if (n == nil) {
|
||||
return &a
|
||||
}
|
||||
a.Name = n.Name
|
||||
a.Text = n.Text
|
||||
a.WidgetId = n.id
|
||||
a.WidgetType = n.WidgetType
|
||||
|
||||
return &a
|
||||
}
|
||||
|
||||
func sendAction(a *toolkit.Action, n *Node, where *Node) {
|
||||
newaction(a, n, where)
|
||||
}
|
||||
|
||||
// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
|
||||
func newaction(a *toolkit.Action, n *Node, where *Node) {
|
||||
// remove this
|
||||
|
@ -211,8 +229,12 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
|
|||
a.WidgetType = n.WidgetType
|
||||
a.ActionType = a.ActionType
|
||||
}
|
||||
// end remove
|
||||
if (where != nil) {
|
||||
a.ParentId = where.id
|
||||
if (where.WidgetType == toolkit.Grid) {
|
||||
placeGrid(a, n, where)
|
||||
}
|
||||
}
|
||||
|
||||
for _, aplug := range allPlugins {
|
||||
|
@ -224,6 +246,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
|
|||
}
|
||||
log(logInfo, "Action() SEND to pluginChan", aplug.name)
|
||||
aplug.pluginChan <- *a
|
||||
// added during debugging. might be a good idea in general for a tactile experience
|
||||
sleep(.02)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue