2023-03-03 14:41:38 -06:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
2023-04-04 06:31:30 -05:00
|
|
|
// Grid numbering examples (H) or (W,H)
|
2023-04-27 20:41:53 -05:00
|
|
|
// -----------------------
|
|
|
|
// -- (1) -- (2) -- (3) -- (X)
|
|
|
|
// -----------------------
|
|
|
|
//
|
|
|
|
// (Y)
|
2023-03-23 12:35:12 -05:00
|
|
|
// ---------
|
|
|
|
// -- (1) --
|
|
|
|
// -- (2) --
|
|
|
|
// ---------
|
|
|
|
//
|
2023-04-27 20:41:53 -05:00
|
|
|
// (X,Y)
|
2023-03-23 12:35:12 -05:00
|
|
|
// -----------------------------
|
2023-04-04 06:31:30 -05:00
|
|
|
// -- (1,1) -- (2,1) -- (3,1) --
|
|
|
|
// -- (1,2) -- (2,2) -- (3,2) --
|
|
|
|
// -- (1,3) -- -- (3,3) --
|
2023-03-23 12:35:12 -05:00
|
|
|
// -----------------------------
|
|
|
|
|
2023-04-04 06:31:30 -05:00
|
|
|
func (n *Node) NewGrid(name string, w int, h int) *Node {
|
2023-04-08 11:06:50 -05:00
|
|
|
newNode := n.newNode(name, toolkit.Grid, func() {
|
2023-03-03 14:41:38 -06:00
|
|
|
log(debugChange, "click() NewGrid not defined =", name)
|
|
|
|
})
|
|
|
|
|
2023-05-09 08:25:10 -05:00
|
|
|
a := newAction(n, toolkit.Add)
|
|
|
|
|
2023-04-04 06:31:30 -05:00
|
|
|
a.X = w
|
|
|
|
a.Y = h
|
|
|
|
newNode.X = w
|
|
|
|
newNode.Y = h
|
2023-03-23 12:35:12 -05:00
|
|
|
newNode.NextX = 1
|
|
|
|
newNode.NextY = 1
|
2023-04-28 15:34:55 -05:00
|
|
|
|
2023-05-09 08:25:10 -05:00
|
|
|
sendAction(a, newNode, n)
|
2023-04-28 15:34:55 -05:00
|
|
|
|
2023-05-09 08:25:10 -05:00
|
|
|
return newNode
|
|
|
|
}
|
2023-03-23 12:35:12 -05:00
|
|
|
|
2023-05-09 08:25:10 -05:00
|
|
|
// increments where the next element in the grid should go
|
|
|
|
func placeGrid(a *toolkit.Action, n *Node, where *Node) {
|
2023-04-28 15:34:55 -05:00
|
|
|
where.NextY += 1
|
|
|
|
if (where.NextY > where.Y) {
|
|
|
|
where.NextX += 1
|
|
|
|
where.NextY = 1
|
|
|
|
}
|
|
|
|
|
2023-05-09 08:25:10 -05:00
|
|
|
a.X = where.NextX
|
|
|
|
a.Y = where.NextY
|
|
|
|
log(logNow, "placeGrid() (X,Y)", where.X, where.Y, " next(X,Y) =", where.NextX, where.NextY)
|
2023-03-03 14:41:38 -06:00
|
|
|
}
|