diff --git a/action.go b/action.go index 08dd212..83f0afc 100644 --- a/action.go +++ b/action.go @@ -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) } diff --git a/add.go b/add.go index 42b9f98..8a404fb 100644 --- a/add.go +++ b/add.go @@ -13,7 +13,6 @@ func add(a *widget.Action) { } return } - // n := addNode(a) n := me.myTree.AddNode(a) p := n.Parent diff --git a/main.go b/main.go index 671d4ac..8fc343d 100644 --- a/main.go +++ b/main.go @@ -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(¤tA) + processAction(¤tA) }) } @@ -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() }) } diff --git a/updateui.go b/updateui.go index 8c94163..3e75f7c 100644 --- a/updateui.go +++ b/updateui.go @@ -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 { diff --git a/window.go b/window.go index 50eb4bd..2053ad0 100644 --- a/window.go +++ b/window.go @@ -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