2023-03-03 14:41:38 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Grid numbering by (X,Y)
|
|
|
|
// -----------------------------
|
|
|
|
// -- (1,1) -- (2,1) -- (3,1) --
|
|
|
|
// -- (1,2) -- (2,1) -- (3,1) --
|
|
|
|
// -----------------------------
|
|
|
|
func newGrid(parentW *toolkit.Widget, w *toolkit.Widget) {
|
|
|
|
var newt *andlabsT
|
|
|
|
log(debugToolkit, "NewGrid()", w.Name)
|
|
|
|
|
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
|
|
|
listMap(debugError)
|
|
|
|
log(debugError, "ERROR newGrid() listMap()")
|
|
|
|
log(debugError, "ERROR FFFFFFFFFFFF listMap()")
|
|
|
|
log(debugError, "ERROR FFFFFFFFFFFF listMap()")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log(debugToolkit, "NewGrid()", w.Name)
|
|
|
|
if t.broken() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
newt = new(andlabsT)
|
|
|
|
|
|
|
|
c := ui.NewGrid()
|
|
|
|
newt.uiGrid = c
|
|
|
|
newt.uiBox = t.uiBox
|
|
|
|
newt.tw = w
|
2023-03-12 08:47:16 -05:00
|
|
|
t.doAppend(toolkit.Grid, newt, nil)
|
2023-03-03 14:41:38 -06:00
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
}
|
|
|
|
|
|
|
|
func doGrid(p *toolkit.Widget, c *toolkit.Widget) {
|
|
|
|
if broken(c) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (c.Action == "New") {
|
|
|
|
newGrid(p, c)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ct := mapToolkits[c]
|
|
|
|
if (ct == nil) {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
|
2023-03-03 14:41:38 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if ct.broken() {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Grid() ct.broken", ct)
|
2023-03-03 14:41:38 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if (ct.uiGrid == nil) {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Grid() uiGrid == nil", ct)
|
2023-03-03 14:41:38 -06:00
|
|
|
return
|
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugChange, "Going to attempt:", c.Action)
|
2023-03-03 14:41:38 -06:00
|
|
|
switch c.Action {
|
|
|
|
case "Enable":
|
|
|
|
ct.uiGrid.Enable()
|
|
|
|
case "Disable":
|
|
|
|
ct.uiGrid.Disable()
|
|
|
|
case "Show":
|
|
|
|
ct.uiGrid.Show()
|
|
|
|
case "Hide":
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "trying Hide on grid")
|
2023-03-03 14:41:38 -06:00
|
|
|
ct.uiGrid.Hide()
|
2023-03-12 08:47:16 -05:00
|
|
|
case "SetMargin":
|
|
|
|
log(debugError, "trying SetMargin on grid")
|
|
|
|
ct.uiGrid.SetPadded(c.B)
|
2023-03-03 14:41:38 -06:00
|
|
|
case "Set":
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Can I use 'Set' to place a *Node in a Grid?")
|
|
|
|
/*
|
|
|
|
case "AddGrid":
|
|
|
|
log(true, "how do I add a thing to a grid?")
|
|
|
|
dump(p, c, true)
|
|
|
|
newt.uiGrid.Append(button1,
|
|
|
|
0, 2, 1, 1,
|
|
|
|
false, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
*/
|
2023-03-03 14:41:38 -06:00
|
|
|
default:
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Can't do", c.Action, "to a Grid")
|
2023-03-03 14:41:38 -06:00
|
|
|
}
|
|
|
|
}
|