summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-11-13 08:53:03 -0600
committerJeff Carr <[email protected]>2022-11-13 08:53:03 -0600
commit207cf7ea16f1da8fa9f893504d77a2856298cc22 (patch)
tree54d513b83ce797be75268f7d8867e0b01ab8f23e /window.go
parented382bec55be25039e4dcf020d1512139855c9bb (diff)
Massive refactor to use go plugins. This is neat.
update README.md set xterm title. make os.Exit() default on window close add a toolkit.Widget to the node structure remove 'Greeter' symbol mapping scheme removed the testing greeter code plugins: attempt to load plugins in a sensible order andlabs/ui: working andlabs/ui plugin (andlabs2) buttons work in andlabs plugin TODO: re-implement non-plugin version for Windows mswindows doesn't support go plugins yet gocui: put the gocui console so file in the binary does a full init of gocui plugin Button() and Group() working very well with gogui cleanly exit gocui technically you can load two toolkits at the same time kinda both working at the same time. esoteric two working plugins at the same time give up working on two gui's at the same time this is fun, but _not interesting wow. this actually works. NewButton() from both toolkits examples: all the examples run again remove early helloplugin example buttonplugin example cmd code buttonplugin runs and ldd is minimum Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'window.go')
-rw-r--r--window.go57
1 files changed, 35 insertions, 22 deletions
diff --git a/window.go b/window.go
index 06db292..99e5880 100644
--- a/window.go
+++ b/window.go
@@ -4,7 +4,7 @@ import (
"log"
)
-import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
+//import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
// This routine creates a blank window with a Title and size (W x H)
//
@@ -13,33 +13,46 @@ import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
// cross platform, must pass UI changes into the OS threads (that is
// my guess).
func NewWindow() *Node {
- var n *Node
- var t *toolkit.Toolkit
+ var newNode *Node
+// var t *toolkit.Toolkit
title := Config.Title
- w := Config.Width
- h := Config.Height
- // f := Config.Exit
-
// Windows are created off of the master node of the Binary Tree
- n = Config.master.New(title)
+ newNode = Config.master.New(title)
- n.OnChanged = Config.Exit
+ newNode.Widget.Name = title
+ newNode.Widget.Width = Config.Width
+ newNode.Widget.Height = Config.Height
- t = toolkit.NewWindow(title, w, h)
- t.Custom = func () {
- if (Config.Options.Debug) {
- log.Println("Got to wit/gui Window Close START user defined close()")
+ if (Config.Exit != nil) {
+ newNode.custom = func() {
+ Config.Exit(newNode)
}
- if (n.OnChanged != nil) {
- if (Config.Options.Debug) {
- log.Println("Got to wit/gui Window Close SKIP node.custom() == nil")
- }
- n.OnChanged(n)
- return
+ }
+
+ if (newNode.custom == nil) {
+ newNode.custom = func () {StandardExit(newNode)}
+ }
+
+ newNode.Widget.Custom = newNode.custom
+
+ log.Println("gui.Node.Window()", title)
+
+ // t = toolkit.NewWindow(title, w, h)
+ // n.toolkit = t
+
+ for _, aplug := range allPlugins {
+ log.Println("gui.Node.NewWindow() toolkit plugin =", aplug.name)
+ if (aplug.NewWindow == nil) {
+ log.Println("gui.Node.NewWindow() is nil")
+ continue
}
- StandardExit(n)
+ aplug.NewWindow(&newNode.Widget)
}
- n.toolkit = t
- return n
+
+ // TODO: this is still confusing and probably wrong. This needs to communicate through a channel
+ // newNode.toolkit = n.toolkit.NewButton(name)
+ // newNode.toolkit.Custom = newNode.Widget.Custom
+
+ return newNode
}