diff options
Diffstat (limited to 'toolkit')
| -rw-r--r-- | toolkit/andlabs/main.go | 15 | ||||
| -rw-r--r-- | toolkit/andlabs/plugin.go | 16 | ||||
| -rw-r--r-- | toolkit/widget.go | 46 |
3 files changed, 31 insertions, 46 deletions
diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go index 5a99421..e9ac6b1 100644 --- a/toolkit/andlabs/main.go +++ b/toolkit/andlabs/main.go @@ -24,9 +24,6 @@ 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) @@ -95,7 +92,7 @@ func queue(f func()) { } // This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc -func Init() { +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 @@ -106,7 +103,17 @@ func Init() { pluginChan = make(chan toolkit.Action, 1) log(logNow, "Init() start channel reciever") + go ui.Main(func() { + demoUI() + }) go catchActionChannel() + /* + // go catchActionChannel() + go uiMain.Do(func() { + ui.Main(demoUI) + // go catchActionChannel() + }) + */ log(logNow, "Init() END") } diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go index f9befd5..a7205fb 100644 --- a/toolkit/andlabs/plugin.go +++ b/toolkit/andlabs/plugin.go @@ -24,6 +24,7 @@ func Send(p *toolkit.Widget, c *toolkit.Widget) { } */ +/* func oldAction2(a *toolkit.Action) { log(logNow, "Action() START") if (a == nil) { @@ -31,22 +32,31 @@ func oldAction2(a *toolkit.Action) { 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) + if (a.ActionType == toolkit.InitToolkit) { + // TODO: make sure to only do this once + // go uiMain.Do(func() { + // ui.Main(demoUI) + // go catchActionChannel() + // }) + // try doing this on toolkit load in init() + return + } + log(logNow, "rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId) switch a.WidgetType { case toolkit.Flag: diff --git a/toolkit/widget.go b/toolkit/widget.go index 658475e..1a5a45f 100644 --- a/toolkit/widget.go +++ b/toolkit/widget.go @@ -1,15 +1,7 @@ package toolkit -type WidgetType int -type ActionType int - // passes information between the toolkit library (plugin) // -// All Toolkit interactions should be done via a channel or Queue() -// TODO: FIGURE OUT HOW TO IMPLEMENT THIS -// https://ieftimov.com/post/golang-datastructures-trees/ -// TODO: protobuf ? -// // This is the only thing that is passed between the toolkit plugin // // what names should be used? This is not part of [[Graphical Widget]] @@ -17,29 +9,12 @@ type ActionType int // Event is used too much: web dev, cloud, etc // I'm using "Action". Maybe it should really be // "Interaction" as per wikipedia [[User interface]] -// Could a protobuf be used here? (Can functions be passed?) -type Widget2 struct { - // Name string - Type WidgetType - - // This function is how you interact with the toolkit - // latest attempt. seems to work so far (2023/02/28) - // Hopefully this will be the barrier between the goroutines - // TODO: move this interaction to channels - Custom func() - - // re-adding an id to test channels - Id int +// +// TODO: convert this to a protobuf (?) +// - // This is how the values are passed back and forth - // values from things like checkboxes & dropdown's - // The string is also used to set the button name - B bool - I int - // maybe safe if there is correctly working Custom() between goroutines? - // (still probably not, almost certainly not. not possible. layer violation?) - S string // not safe to have 'S' -} +type WidgetType int // Button, Menu, Checkbox, etc. +type ActionType int // Add, SetText, Click, Hide, Append, Delete, etc type Action struct { ActionType ActionType @@ -51,20 +26,13 @@ type Action struct { Text string // what is visable to the user Name string // a name useful for programming - // this should be the widget - // if the action is New, Hide, Enable, etc - // Widget *Widget - // This is how the values are passed back and forth // values from things like checkboxes & dropdown's - // The string is also used to set the button name B bool I int - // maybe safe if there is correctly working Custom() between goroutines? - // (still probably not, almost certainly not. not possible. layer violation?) - S string // not safe to have 'S' + S string - A any + A any // switch to this or deprecate this? pros/cons? // This GUI is intended for simple things // We are not laying out PDF's here |
