summaryrefslogtreecommitdiff
path: root/toolkit/andlabs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/andlabs')
-rw-r--r--toolkit/andlabs/debug.go12
-rw-r--r--toolkit/andlabs/log.go6
-rw-r--r--toolkit/andlabs/main.go66
-rw-r--r--toolkit/andlabs/plugin.go18
4 files changed, 77 insertions, 25 deletions
diff --git a/toolkit/andlabs/debug.go b/toolkit/andlabs/debug.go
index 2f8126d..5ecd1fc 100644
--- a/toolkit/andlabs/debug.go
+++ b/toolkit/andlabs/debug.go
@@ -11,12 +11,12 @@ var stretchy bool // expand things like buttons to the maximum size
var padded bool // add space between things like buttons
var margin bool // add space around the frames of windows
-var debugToolkit bool
-var debugChange bool
-var debugPlugin bool
-var debugAction bool
-var debugFlags bool
-var debugGrid bool
+var debugToolkit bool = true
+var debugChange bool = true
+var debugPlugin bool = true
+var debugAction bool = true
+var debugFlags bool = true
+var debugGrid bool = true
var debugNow bool = true
var debugError bool = true
diff --git a/toolkit/andlabs/log.go b/toolkit/andlabs/log.go
index 77b10e2..1a36188 100644
--- a/toolkit/andlabs/log.go
+++ b/toolkit/andlabs/log.go
@@ -7,9 +7,9 @@ import (
// various debugging flags
var logNow bool = true // useful for active development
var logError bool = true
-var logWarn bool = false
-var logInfo bool = false
-var logVerbose bool = false
+var logWarn bool = true
+var logInfo bool = true
+var logVerbose bool = true
func log(a ...any) {
witlog.Where = "wit/gui/andlabs"
diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go
index 9ca71ca..137af04 100644
--- a/toolkit/andlabs/main.go
+++ b/toolkit/andlabs/main.go
@@ -11,15 +11,43 @@ import (
//go:embed resources
var res embed.FS
+var pluginChan chan toolkit.Action
+
+func catchActionChannel() {
+ log(logNow, "makeCallback() START")
+ for {
+ log(logNow, "makeCallback() for loop")
+ select {
+ case a := <-pluginChan:
+ log(logNow, "makeCallback() SELECT widget id =", a.WidgetId, a.Name)
+ // go Action(a)
+ if (a.WidgetType == toolkit.Window) {
+ log(logNow, "makeCallback() WINDOW START")
+ go ui.Main( func() {
+ log(logNow, "ui.Main() WINDOW START")
+ rawAction(&a)
+ log(logNow, "ui.Main() WINDOW END")
+ })
+ sleep(.5)
+ log(logNow, "makeCallback() WINDOW END")
+ } else {
+ log(logNow, "makeCallback() STUFF")
+ rawAction(&a)
+ /*
+ Queue( func() {
+ rawAction(&a)
+ })
+ */
+ log(logNow, "makeCallback() STUFF END")
+ }
+ sleep(.1)
+ }
+ }
+}
func Main(f func()) {
- log(debugToolkit, "Starting gui.Main() (using gtk via andlabs/ui)")
- ui.Main( func() {
- log(debugToolkit, "Starting gui.Main() (using gtk via andlabs/ui)")
- // time.Sleep(1 * time.Second)
- // NewWindow2("helloworld2", 200, 100)
- f()
- })
+ log(debugNow, "gui.Main() START (using gtk via andlabs/ui)")
+ f() // support the old way. deprecate this
}
// this sets the channel to send user events back from the plugin
@@ -36,13 +64,14 @@ func Callback(guiCallback chan toolkit.Action) {
// For example: Queue(NewWindow())
//
func Queue(f func()) {
- log(debugToolkit, "Sending function to ui.QueueMain()")
- log(debugPlugin, "using gui.Queue() in this plugin DOES BREAK. TODO: solve this with channels")
+ log(logNow, "Sending function to ui.QueueMain()")
+ log(logNow, "using gui.Queue() in this plugin DOES BREAK. TODO: solve this with channels")
ui.QueueMain(f)
}
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func Init() {
+ log(logNow, "Init() START")
log(debugToolkit, "Init()")
// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
// log(debugToolkit, "gui/toolkit init() Setting defaultBehavior = true")
@@ -52,6 +81,25 @@ func Init() {
// mapToolkits = make(map[*toolkit.Widget]*andlabsT)
andlabs = make(map[int]*andlabsT)
+ pluginChan = make(chan toolkit.Action)
+
+ log(logNow, "Init() ui.Main() start")
+ go catchActionChannel()
+ /*
+ ui.Main( func() {
+ log(logNow, "gui.Main() IN (using gtk via andlabs/ui)")
+ var a toolkit.Action
+ a.Name = "jcarr"
+ a.Width = 640
+ a.Height = 480
+ a.WidgetId = 0
+ newWindow(&a)
+ // time.Sleep(1 * time.Second)
+ // NewWindow2("helloworld2", 200, 100)
+ log(logNow, "gui.Main() EXIT (using gtk via andlabs/ui)")
+ })
+ */
+ log(logNow, "Init() END")
}
// TODO: properly exit the plugin since Quit() doesn't do it
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go
index 2faa2ec..f7577d1 100644
--- a/toolkit/andlabs/plugin.go
+++ b/toolkit/andlabs/plugin.go
@@ -23,24 +23,28 @@ func Send(p *toolkit.Widget, c *toolkit.Widget) {
}
func Action(a *toolkit.Action) {
+ log(logNow, "Action() START")
if (a == nil) {
log(debugPlugin, "Action = nil")
return
}
+ pluginChan <- *a
+ /*
f := func() {
rawAction(a)
}
// f()
Queue(f)
+ */
+ log(logNow, "Action() END")
}
func rawAction(a *toolkit.Action) {
+ log(debugAction, "rawAction() START a.ActionType =", a.ActionType)
+ log(debugAction, "rawAction() START a.S =", a.S)
- log(debugAction, "Action() START a.ActionType =", a.ActionType)
- log(debugAction, "Action() START a.S =", a.S)
-
- log(logInfo, "Action() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
+ log(logNow, "rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
switch a.WidgetType {
case toolkit.Flag:
flag(a)
@@ -87,12 +91,12 @@ func rawAction(a *toolkit.Action) {
case toolkit.Delete:
uiDelete(a)
case toolkit.Move:
- log(debugNow, "attempt to move() =", a.ActionType, a.WidgetType)
+ log(debugNow, "rawAction() attempt to move() =", a.ActionType, a.WidgetType)
move(a)
default:
- log(debugError, "Action() Unknown =", a.ActionType, a.WidgetType)
+ log(debugError, "rawAction() Unknown =", a.ActionType, a.WidgetType)
}
- log(debugAction, "Action() END =", a.ActionType, a.WidgetType)
+ log(debugAction, "rawAction() END =", a.ActionType, a.WidgetType)
}
func flag(a *toolkit.Action) {