diff options
| author | Jeff Carr <[email protected]> | 2023-05-09 18:50:16 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-05-09 18:50:16 -0500 |
| commit | c36725fa90acc47fe5c0650f93540b5d65a126b6 (patch) | |
| tree | 287e41eecaa606aa0714e6e2126327c8aa83aa14 | |
| parent | b392c40969e105b00efa262042d647303d6fbc2c (diff) | |
simplify sendAction()
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | box.go | 13 | ||||
| -rw-r--r-- | group.go | 13 | ||||
| -rw-r--r-- | image.go | 10 | ||||
| -rw-r--r-- | plugin.go | 19 | ||||
| -rw-r--r-- | tab.go | 10 | ||||
| -rw-r--r-- | textbox.go | 12 | ||||
| -rw-r--r-- | window.go | 14 |
7 files changed, 43 insertions, 48 deletions
@@ -4,16 +4,11 @@ import ( "git.wit.org/wit/gui/toolkit" ) -func (n *Node) NewBox(name string, b bool) *Node { - newNode := n.newNode(name, toolkit.Box, nil) +func (parent *Node) NewBox(name string, b bool) *Node { + newNode := parent.newNode(name, toolkit.Box, nil) newNode.B = b - var a toolkit.Action - a.ActionType = toolkit.Add - a.Name = name - a.Text = name - a.B = b - newaction(&a, newNode, n) - + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, parent) return newNode } @@ -7,16 +7,13 @@ import ( // TODO: make a "Group" a "Grid" ? // probably since right now group is just a // pre-canned andlabs/ui gtk,macos,windows thing -func (n *Node) NewGroup(name string) *Node { +func (parent *Node) NewGroup(name string) *Node { var newNode *Node - newNode = n.newNode(name, toolkit.Group, nil) + newNode = parent.newNode(name, toolkit.Group, nil) - var a toolkit.Action - a.ActionType = toolkit.Add - a.Name = name - a.Text = name - newaction(&a, newNode, n) + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, parent) - newBox := newNode.NewBox("group vBox", false) + newBox := newNode.NewBox("defaultGroupBox", false) return newBox } @@ -4,13 +4,11 @@ import ( "git.wit.org/wit/gui/toolkit" ) -func (n *Node) NewImage(name string) *Node { +func (parent *Node) NewImage(name string) *Node { var newNode *Node - newNode = n.newNode(name, toolkit.Image, nil) - - var a toolkit.Action - a.ActionType = toolkit.Add - newaction(&a, newNode, n) + newNode = parent.newNode(name, toolkit.Image, nil) + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, parent) return newNode } @@ -212,16 +212,31 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action { a.Name = n.Name a.Text = n.Text a.WidgetId = n.id + a.B = n.B + a.X = n.X + a.Y = n.Y if (n.parent != nil) { a.ParentId = n.parent.id } a.WidgetType = n.WidgetType - return &a } +// func sendAction(a *toolkit.Action) { func sendAction(a *toolkit.Action, n *Node, where *Node) { - newaction(a, n, where) + // newaction(a, n, where) + for _, aplug := range allPlugins { + log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType) + if (aplug.pluginChan == nil) { + log(logInfo, "Action() retrieving the aplug.PluginChannel()", aplug.name) + aplug.pluginChan = aplug.PluginChannel() + log(logInfo, "Action() retrieved", aplug.pluginChan) + } + log(logInfo, "Action() SEND to pluginChan", aplug.name) + aplug.pluginChan <- *a + // added during debugging. might be a good idea in general for a tactile experience + sleep(.02) + } } // 2023/04/06 Queue() is also being used and channels are being used. memcopy() only @@ -30,12 +30,12 @@ func (n *Node) NewTab(text string) *Node { } newNode := n.newNode(text, toolkit.Tab, nil) - var a toolkit.Action - a.ActionType = toolkit.Add - a.Name = text - a.Text = text - newaction(&a, newNode, n) + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, n) + // by default, create a box inside the tab + // TODO: allow this to be configurable newBox := newNode.NewBox(text, true) + return newBox } @@ -4,16 +4,12 @@ import ( "git.wit.org/wit/gui/toolkit" ) -func (n *Node) NewTextbox(name string) *Node { - newNode := n.newNode(name, toolkit.Textbox, func() { +func (parent *Node) NewTextbox(name string) *Node { + newNode := parent.newNode(name, toolkit.Textbox, func() { log(debugGui, "NewTextbox changed =", name) }) - var a toolkit.Action - a.ActionType = toolkit.Add - a.Name = name - a.Text = name - newaction(&a, newNode, n) - + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, parent) return newNode } @@ -6,21 +6,15 @@ import ( // This routine creates a blank window with a Title and size (W x H) -func (n *Node) NewWindow(title string) *Node { +func (parent *Node) NewWindow(title string) *Node { var newNode *Node // Windows are created off of the master node of the Binary Tree - newNode = n.newNode(title, toolkit.Window, StandardExit) + newNode = parent.newNode(title, toolkit.Window, StandardExit) log(logInfo, "NewWindow()", title) - var a toolkit.Action - a.ActionType = toolkit.Add - a.X = n.X - a.Y = n.Y - a.Name = title - a.Text = title - newaction(&a, newNode, n) - + a := newAction(newNode, toolkit.Add) + sendAction(a, newNode, parent) return newNode } |
