2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
import (
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
var pwLabel *toolkit.Widget
|
|
|
|
var wLabel *toolkit.Widget
|
|
|
|
var tmpNewt *andlabsT
|
2022-11-14 14:30:28 -06:00
|
|
|
|
|
|
|
func NewLabel(parentW *toolkit.Widget, w *toolkit.Widget) {
|
2023-02-25 14:05:25 -06:00
|
|
|
pwLabel = parentW
|
|
|
|
wLabel = w
|
|
|
|
tmpNewt = new(andlabsT)
|
|
|
|
tmpNewt.Width = 10
|
|
|
|
log(debugToolkit, "mapWidgets in ui.QueueMain() START newt =", tmpNewt.Width, tmpNewt)
|
|
|
|
if (tmpNewt == nil) {
|
|
|
|
log(debugToolkit, "mapWidgets WHY THE HELL IS THIS NIL?", tmpNewt.Width, tmpNewt)
|
|
|
|
}
|
|
|
|
ui.QueueMain(newLabel)
|
|
|
|
|
|
|
|
log(true, "sleep(.2) HACK. TODO: wrap spinlock around andlabs.ui goroutine")
|
|
|
|
// log(true, "sleep(.2) HACK. TODO: verify newLabel() is running inside andlabs/ui goroutine") // verified that worked
|
|
|
|
sleep(.2)
|
|
|
|
log(debugToolkit, "mapWidgets parentW/wLabel =", pwLabel)
|
|
|
|
log(debugToolkit, "mapWidgets new/newt =", tmpNewt)
|
|
|
|
mapWidgetsToolkits(w, tmpNewt)
|
|
|
|
|
|
|
|
/*
|
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
|
|
|
log(debugToolkit, "go.andlabs.NewDropdown() toolkit struct == nil. name=", parentW.Name, w.Name)
|
|
|
|
listMap()
|
|
|
|
}
|
|
|
|
newt := t.NewDropdown(w.Name)
|
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
func newLabel() {
|
2022-11-14 14:30:28 -06:00
|
|
|
var t, newt *andlabsT
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "gui.andlabs.NewButton()", wLabel.Name)
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
t = mapToolkits[pwLabel]
|
2022-11-14 14:30:28 -06:00
|
|
|
if (t == nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "go.andlabs.NewButton() toolkit struct == nil. name=", pwLabel.Name, wLabel.Name)
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
|
|
|
}
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
if t.broken() {
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
2022-10-16 10:09:16 -05:00
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
newt = tmpNewt
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
newt.uiLabel = ui.NewLabel(wLabel.Name)
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.uiBox = t.uiBox
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "gui.Toolbox.NewButton() about to append to Box parent t:", wLabel.Name)
|
|
|
|
t.Dump()
|
|
|
|
log(debugToolkit, "gui.Toolbox.NewButton() about to append to Box new t:", wLabel.Name)
|
|
|
|
newt.Dump()
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
if (t.uiBox != nil) {
|
|
|
|
t.uiBox.Append(newt.uiLabel, false)
|
|
|
|
} else {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "ERROR: wit/gui andlabs couldn't place this label in a box")
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
|
|
|
}
|
2022-10-16 10:09:16 -05:00
|
|
|
}
|