better function names

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 21:00:37 -06:00
parent 0fd60847fc
commit 0adbbecdac
5 changed files with 39 additions and 22 deletions

View File

@ -205,8 +205,8 @@ func (n *node) Delete() {
}
}
func rawAction(a *widget.Action) {
log.Log(INFO, "rawAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
func processAction(a *widget.Action) {
log.Log(INFO, "processAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
if a.ActionType == widget.ToolkitInit {
Init()
@ -219,10 +219,10 @@ func rawAction(a *widget.Action) {
return
}
log.Warn("andlabs rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId, a.ActionType)
log.Warn("andlabs processAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId, a.ActionType)
switch a.WidgetType {
case widget.Flag:
log.Log(ERROR, "rawAction() RE-IMPLEMENT LOG FLAGS")
log.Log(ERROR, "processAction() RE-IMPLEMENT LOG FLAGS")
return
}
@ -233,26 +233,20 @@ func rawAction(a *widget.Action) {
n := me.treeRoot.FindWidgetId(a.WidgetId)
if a.ActionType == widget.Add {
me.treeRoot.ListWidgets()
// ui.QueueMain(func() {
add(a)
// })
// TODO: remove this artificial delay
// sleep(.001)
return
}
if a.ActionType == widget.Dump {
log.Log(NOW, "rawAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
// me.rootNode.listChildren(true)
log.Log(NOW, "processAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
return
}
if n == nil {
log.Error(errors.New("andlabs rawAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
log.Log(NOW, "rawAction() ERROR findWidgetId found nil for id =", a.WidgetId)
log.Log(NOW, "rawAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
log.Log(NOW, "rawAction() ERROR findWidgetId found nil for id =", a.WidgetId)
log.Error(errors.New("andlabs processAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
log.Log(NOW, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
log.Log(NOW, "processAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
log.Log(NOW, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
me.treeRoot.ListWidgets()
return
panic("findWidgetId found nil for id = " + string(a.WidgetId))
@ -301,10 +295,10 @@ func rawAction(a *widget.Action) {
case widget.Delete:
n.Delete()
case widget.Move:
log.Log(NOW, "rawAction() attempt to move() =", a.ActionType, a.WidgetType)
log.Log(NOW, "processAction() attempt to move() =", a.ActionType, a.WidgetType)
*/
default:
log.Log(ERROR, "rawAction() Unknown =", a.ActionType, a.WidgetType)
log.Log(ERROR, "processAction() Unknown =", a.ActionType, a.WidgetType)
}
log.Log(INFO, "rawAction() END =", a.ActionType, a.WidgetType)
log.Log(INFO, "processAction() END =", a.ActionType, a.WidgetType)
}

1
add.go
View File

@ -13,7 +13,6 @@ func add(a *widget.Action) {
}
return
}
// n := addNode(a)
n := me.myTree.AddNode(a)
p := n.Parent

16
main.go
View File

@ -18,6 +18,8 @@ var uiMain sync.Once
var muAction sync.Mutex
func queueMain(currentA widget.Action) {
/*
// this never happends
defer func() {
if r := recover(); r != nil {
log.Warn("YAHOOOO Recovered in queueMain() application:", r)
@ -27,8 +29,15 @@ func queueMain(currentA widget.Action) {
me.myTree.DoToolkitPanic()
}
}()
*/
// andlabs puts this inside the gofunction over there
// probably this should be changed around here
// and only andlabs stuff should be sent there?
// it's easier to code it this way however
// also, if it dies here, it get's caught
// usually, this is where it dies
ui.QueueMain(func() {
rawAction(&currentA)
processAction(&currentA)
})
}
@ -43,7 +52,10 @@ func guiMain() {
}
}()
ui.Main(func() {
demoUI()
// this is a bad hack for now.
// a better way would be to spawn ui.Main on the first actual window
// that is supposed to be displayed
placeholderUI()
})
}

View File

@ -11,6 +11,18 @@ import (
var count int
func placeholderUI() {
mainWindow := ui.NewWindow("libui placeholder", 640, 480, true)
mainWindow.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
mainWindow.Destroy()
return true
})
}
func demoUI() {
mainWindow := ui.NewWindow("libui Updating UI", 640, 480, true)
mainWindow.OnClosing(func(*ui.Window) bool {

View File

@ -28,7 +28,7 @@ func newWindow(p, n *tree.Node) {
win.OnClosing(func(*ui.Window) bool {
// show(n, false)
me.myTree.DoWindowCloseEvent(n)
return false
return true
})
newt.uiWindow = win
newt.uiControl = win