working on removing newaction()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-05-09 19:04:39 -05:00
parent 761250d24c
commit 6b55526fee
3 changed files with 18 additions and 10 deletions

View File

@ -75,24 +75,21 @@ func (n *Node) SetNext(w int, h int) {
func (n *Node) Set(val any) { func (n *Node) Set(val any) {
log(debugChange, "Set() value =", val) log(debugChange, "Set() value =", val)
var a toolkit.Action
a.ActionType = toolkit.Set
switch v := val.(type) { switch v := val.(type) {
case bool: case bool:
n.B = val.(bool) n.B = val.(bool)
a.B = val.(bool)
case string: case string:
n.Text = val.(string) n.Text = val.(string)
a.S = val.(string) n.S = val.(string)
case int: case int:
n.I = val.(int) n.I = val.(int)
a.I = val.(int)
default: default:
log(debugError, "Set() unknown type =", v, "a =", a) log(debugError, "Set() unknown type =", v)
} }
newaction(&a, n, nil) a := newAction(n, toolkit.Set)
sendAction(a)
} }
func (n *Node) AppendText(str string) { func (n *Node) AppendText(str string) {

View File

@ -212,9 +212,17 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
a.Name = n.Name a.Name = n.Name
a.Text = n.Text a.Text = n.Text
a.WidgetId = n.id a.WidgetId = n.id
a.B = n.B a.B = n.B
a.I = n.I
a.S = n.S
a.X = n.X a.X = n.X
a.Y = n.Y a.Y = n.Y
a.AtW = n.AtW
a.AtH = n.AtH
if (n.parent != nil) { if (n.parent != nil) {
a.ParentId = n.parent.id a.ParentId = n.parent.id
} }
@ -222,6 +230,7 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
return &a return &a
} }
// sends the action/event to each toolkit via a golang plugin channel
func sendAction(a *toolkit.Action) { func sendAction(a *toolkit.Action) {
for _, aplug := range allPlugins { for _, aplug := range allPlugins {
log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType) log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType)

View File

@ -32,21 +32,23 @@ type Action struct {
I int I int
S string S string
A any // switch to this or deprecate this? pros/cons?
// This is used for things like a slider(0,100) // This is used for things like a slider(0,100)
X int X int
Y int Y int
// This is used for the widget's grid position // This is for the grid size & widget position
W int W int
H int H int
AtW int
AtH int
// Put space around elements to improve look & feel // Put space around elements to improve look & feel
Margin bool Margin bool
// Make widgets fill up the space available // Make widgets fill up the space available
Expand bool Expand bool
A any // switch to this or deprecate this? pros/cons?
} }
const ( const (