2024-01-01 16:11:54 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
2024-01-08 21:19:42 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-05 13:30:00 -06:00
|
|
|
"go.wit.com/gui/widget"
|
2024-01-01 16:11:54 -06:00
|
|
|
|
2024-01-15 16:11:40 -06:00
|
|
|
"go.wit.com/dev/andlabs/ui"
|
2024-01-01 16:11:54 -06:00
|
|
|
// the _ means we only need this for the init()
|
2024-01-15 16:11:40 -06:00
|
|
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
2024-01-01 16:11:54 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var uiMainUndef bool = true
|
|
|
|
var uiMain sync.Once
|
|
|
|
var muAction sync.Mutex
|
|
|
|
|
2024-01-15 16:11:40 -06:00
|
|
|
func queueMain(currentA widget.Action) {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
log.Warn("YAHOOOO Recovered in main application:", r)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ui.QueueMain( func() {
|
|
|
|
rawAction(¤tA)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-01-01 16:11:54 -06:00
|
|
|
func catchActionChannel() {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "catchActionChannel() START")
|
2024-01-01 16:11:54 -06:00
|
|
|
for {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "catchActionChannel() for loop")
|
2024-01-01 16:11:54 -06:00
|
|
|
select {
|
|
|
|
case a := <-pluginChan:
|
2024-01-11 17:19:47 -06:00
|
|
|
log.Log(INFO, "catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
2024-01-01 16:11:54 -06:00
|
|
|
muAction.Lock()
|
|
|
|
// TODO ui.QueueMain(f)
|
|
|
|
// TODO ui.QueueMain( func() {rawAction(a)} )
|
|
|
|
// rawAction(a)
|
2024-01-15 16:11:40 -06:00
|
|
|
queueMain(a)
|
2024-01-01 16:11:54 -06:00
|
|
|
muAction.Unlock()
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 16:11:40 -06:00
|
|
|
func guiMain() {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
log.Warn("YAHOOOO Recovered in main application:", r)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ui.Main(func() {
|
|
|
|
demoUI()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-01-01 16:11:54 -06:00
|
|
|
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
|
|
|
|
func init() {
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "Init() START")
|
|
|
|
log.Log(INFO, "Init()")
|
2024-01-01 16:11:54 -06:00
|
|
|
// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
|
2024-01-08 21:19:42 -06:00
|
|
|
// log.Log(INFO, "init() Setting defaultBehavior = true")
|
2024-01-01 16:11:54 -06:00
|
|
|
setDefaultBehavior(true)
|
|
|
|
|
|
|
|
// TODO: this is messed up. run ui.Main() from the first add? Initialize it with an empty thing first?
|
|
|
|
// fake out the OS toolkit by making a fake window. This is probably needed for macos & windows
|
|
|
|
// actually, this probably breaks the macos build
|
2024-01-15 16:11:40 -06:00
|
|
|
go guiMain()
|
2024-01-01 16:11:54 -06:00
|
|
|
|
|
|
|
// andlabs = make(map[int]*andlabsT)
|
2024-01-05 13:30:00 -06:00
|
|
|
pluginChan = make(chan widget.Action, 1)
|
2024-01-01 16:11:54 -06:00
|
|
|
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "Init() start channel reciever")
|
2024-01-01 16:11:54 -06:00
|
|
|
go catchActionChannel()
|
2024-01-08 21:19:42 -06:00
|
|
|
log.Log(INFO, "Init() END")
|
2024-01-01 16:11:54 -06:00
|
|
|
}
|