summaryrefslogtreecommitdiff
path: root/toolkit/andlabs
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-12 13:00:29 -0500
committerJeff Carr <[email protected]>2023-04-12 13:00:29 -0500
commit047cde4c9d68ea4ff87006448137e836ec9eb140 (patch)
treece3332991cf5ebd7761e9021f66db787abd25536 /toolkit/andlabs
parent982097557b2625cf04378cd7e7771122382d6de9 (diff)
better toolkit init options
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs')
-rw-r--r--toolkit/andlabs/add.go54
-rw-r--r--toolkit/andlabs/button.go1
-rw-r--r--toolkit/andlabs/main.go17
-rw-r--r--toolkit/andlabs/plugin.go2
-rw-r--r--toolkit/andlabs/structs.go1
5 files changed, 46 insertions, 29 deletions
diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go
index 2f35e99..6d4c7cd 100644
--- a/toolkit/andlabs/add.go
+++ b/toolkit/andlabs/add.go
@@ -15,21 +15,21 @@ func actionDump(b bool, a *toolkit.Action) {
log(b, "actionDump() ParentId =", a.ParentId)
}
-func add(a *toolkit.Action) {
+func add(a toolkit.Action) {
if (andlabs[a.WidgetId] != nil) {
log(debugError, "add() error. can't make a widget that already exists. id =", a.WidgetId)
- actionDump(debugError, a)
+ actionDump(debugError, &a)
return
}
if (a.WidgetId == 0) {
log(debugError, "add() error. w.WidgetId == 0")
- actionDump(debugError, a)
+ actionDump(debugError, &a)
return
}
// for now, window gets handled without checking where == nil)
if (a.WidgetType == toolkit.Window) {
- newWindow(*a)
+ newWindow(a)
return
}
@@ -44,49 +44,49 @@ func add(a *toolkit.Action) {
switch a.WidgetType {
case toolkit.Window:
- newWindow(*a)
+ newWindow(a)
return
case toolkit.Tab:
log(debugError, "add() CAME AT THIS FROM add() =", a.Name)
log(debugError, "add() CAME AT THIS FROM add() =", a.Name)
log(debugError, "add() CAME AT THIS FROM add() =", a.Name)
- newTab(*a)
+ newTab(a)
return
case toolkit.Label:
- newLabel(a)
+ newLabel(&a)
return
case toolkit.Button:
- newButton(a)
+ newButton(&a)
return
case toolkit.Grid:
- newGrid(a)
+ newGrid(&a)
return
case toolkit.Checkbox:
- newCheckbox(a)
+ newCheckbox(&a)
return
case toolkit.Spinner:
- newSpinner(a)
+ newSpinner(&a)
return
case toolkit.Slider:
- newSlider(a)
+ newSlider(&a)
return
case toolkit.Dropdown:
- newDropdown(a)
+ newDropdown(&a)
return
case toolkit.Combobox:
- newCombobox(a)
+ newCombobox(&a)
return
case toolkit.Textbox:
- newTextbox(a)
+ newTextbox(&a)
return
case toolkit.Group:
- newGroup(a)
+ newGroup(&a)
return
case toolkit.Box:
- newBox(a)
+ newBox(&a)
return
case toolkit.Image:
- newImage(a)
+ newImage(&a)
return
default:
log(debugError, "add() error TODO: ", a.WidgetType, a.Name)
@@ -122,13 +122,14 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
// add the structure to the array
if (andlabs[a.WidgetId] == nil) {
- log(logInfo, "newTab() MAPPED", a.WidgetId, a.ParentId)
+ log(logInfo, "place() MAPPED", a.WidgetId, a.ParentId)
andlabs[a.WidgetId] = newt
newt.WidgetType = a.WidgetType
} else {
- log(debugError, "newTab() DO WHAT?", a.WidgetId, a.ParentId)
- log(debugError, "THIS IS BAD")
+ log(debugError, "place() DO WHAT?", a.WidgetId, a.ParentId)
+ log(debugError, "place() THIS IS BAD")
}
+ log(logInfo, "place() DONE MAPPED", a.WidgetId, a.ParentId)
if (newt.uiControl == nil) {
log(debugError, "place() ERROR uiControl == nil", a.ParentId)
@@ -141,12 +142,13 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
return false
}
+ log(logInfo, "place() switch", where.WidgetType)
switch where.WidgetType {
case toolkit.Grid:
- log(debugGrid, "add() Grid try at Parent X,Y =", a.X, a.Y)
+ log(debugGrid, "place() Grid try at Parent X,Y =", a.X, a.Y)
newt.gridX = a.X
newt.gridY = a.Y
- log(debugGrid, "add() Grid try at gridX,gridY", newt.gridX, newt.gridY)
+ log(debugGrid, "place() Grid try at gridX,gridY", newt.gridX, newt.gridY)
// at the very end, subtract 1 from X & Y since andlabs/ui starts counting at zero
t.uiGrid.Append(newt.uiControl,
newt.gridY - 1, newt.gridX - 1, 1, 1,
@@ -155,7 +157,7 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
case toolkit.Group:
if (t.uiBox == nil) {
t.uiGroup.SetChild(newt.uiControl)
- log(debugGrid, "add() hack Group to use this as the box?", a.Name, a.WidgetType)
+ log(debugGrid, "place() hack Group to use this as the box?", a.Name, a.WidgetType)
t.uiBox = newt.uiBox
} else {
t.uiBox.Append(newt.uiControl, stretchy)
@@ -166,6 +168,8 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
t.boxC += 1
return true
case toolkit.Box:
+ log(logInfo, "place() uiBox =", t.uiBox)
+ log(logInfo, "place() uiControl =", newt.uiControl)
t.uiBox.Append(newt.uiControl, stretchy)
t.boxC += 1
return true
@@ -173,7 +177,7 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
t.uiWindow.SetChild(newt.uiControl)
return true
default:
- log(debugError, "add() how?", a.ParentId)
+ log(debugError, "place() how?", a.ParentId)
}
return false
}
diff --git a/toolkit/andlabs/button.go b/toolkit/andlabs/button.go
index bc58da2..f4032d0 100644
--- a/toolkit/andlabs/button.go
+++ b/toolkit/andlabs/button.go
@@ -24,7 +24,6 @@ func newButton(a *toolkit.Action) {
newt.uiButton = b
newt.uiControl = b
newt.wId = a.WidgetId
- // newt.tw = a.Widget
newt.WidgetType = a.WidgetType
newt.parent = t
diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go
index e6befd2..5a99421 100644
--- a/toolkit/andlabs/main.go
+++ b/toolkit/andlabs/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "sync"
"embed"
"git.wit.org/wit/gui/toolkit"
@@ -16,14 +17,20 @@ var res embed.FS
var pluginChan chan toolkit.Action
var uiMainUndef bool = true
+var uiMain sync.Once
+var muAction sync.Mutex
func catchActionChannel() {
log(logNow, "catchActionChannel() START")
for {
log(logNow, "catchActionChannel() for loop")
+ uiMain.Do(func() {
+ go ui.Main(demoUI)
+ })
select {
case a := <-pluginChan:
log(logNow, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name)
+ /*
// go Action(a)
if (uiMainUndef) {
log(logError,"catchActionChannel() main() was not run yet")
@@ -34,7 +41,7 @@ func catchActionChannel() {
log(logError,"catchActionChannel() ui.Main() START")
log(logError,"catchActionChannel() ui.Main() START")
sleep(1)
- go ui.Main(demoUI)
+ // go ui.Main(demoUI)
// go ui.Main( func() {
// rawAction(a)
// })
@@ -46,6 +53,12 @@ func catchActionChannel() {
rawAction(a)
log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
}
+ */
+ log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
+ muAction.Lock()
+ rawAction(a)
+ muAction.Unlock()
+ log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
}
}
}
@@ -90,7 +103,7 @@ func Init() {
setDefaultBehavior(true)
andlabs = make(map[int]*andlabsT)
- pluginChan = make(chan toolkit.Action)
+ pluginChan = make(chan toolkit.Action, 1)
log(logNow, "Init() start channel reciever")
go catchActionChannel()
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go
index f319add..15e9396 100644
--- a/toolkit/andlabs/plugin.go
+++ b/toolkit/andlabs/plugin.go
@@ -55,7 +55,7 @@ func rawAction(a toolkit.Action) {
switch a.ActionType {
case toolkit.Add:
- add(&a)
+ add(a)
case toolkit.Show:
a.B = true
show(&a)
diff --git a/toolkit/andlabs/structs.go b/toolkit/andlabs/structs.go
index 0216407..60047ef 100644
--- a/toolkit/andlabs/structs.go
+++ b/toolkit/andlabs/structs.go
@@ -22,6 +22,7 @@ type andlabsT struct {
// tw *toolkit.Widget
parent *andlabsT
+ a toolkit.Action
uiControl ui.Control