summaryrefslogtreecommitdiff
path: root/action.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-27 12:30:34 -0600
committerJeff Carr <[email protected]>2024-01-27 12:30:34 -0600
commitfd1e048167ef152a5c04bc58f00ec22a0dffc08c (patch)
tree6c35a8484ad56f31cc4d417dfa1c84b2e7e25d52 /action.go
parentad0b252feb1bd3e758150b326c778fe4636ffe49 (diff)
load toolkit working betterv0.13.18
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'action.go')
-rw-r--r--action.go93
1 files changed, 51 insertions, 42 deletions
diff --git a/action.go b/action.go
index 4272424..0057abe 100644
--- a/action.go
+++ b/action.go
@@ -48,6 +48,54 @@ func (n *Node) ParentVisable() bool {
return n.parent.visable
}
+// copies the state of the Node into the action
+// TODO: switch to protobuf here
+func getNewAction(n *Node, atype widget.ActionType) *widget.Action {
+ var a widget.Action
+ a.ActionType = atype
+
+ // These should be "stable" at this point (2024/01/13)
+ a.WidgetId = n.id
+
+ // set state
+ a.State.ProgName = n.progname
+ a.State.Label = n.label
+ a.State.Value = n.value
+
+ a.State.Checked = n.checked
+ a.State.Visable = n.visable
+ // TODO: if visable == false here, return
+ a.State.Enable = n.enabled
+ a.State.Pad = n.pad
+ a.State.Expand = n.expand
+ a.State.Borderless = n.borderless
+ a.State.Direction = n.direction
+
+ for s, _ := range n.strings {
+ a.State.Strings = append(a.State.Strings, s)
+ }
+ a.State.Range.Low = n.X
+ a.State.Range.High = n.Y
+
+ a.ProgName = n.progname
+ a.Value = n.value
+ a.Direction = n.direction
+
+ // These should be improved/deprecated based on the gui/widget docs
+ a.X = n.X
+ a.Y = n.Y
+
+ a.State.GridOffset.X = n.AtW
+ a.State.GridOffset.Y = n.AtH
+
+ if n.parent != nil {
+ a.ParentId = n.parent.id
+ }
+ a.WidgetType = n.WidgetType
+
+ return &a
+}
+
// 2024/01/11 finally moving to type any. simplify to just 'value'
// 2023/05/09 pretty clean
// 2023/04/06 Queue() is also being used and channels are being used.
@@ -97,48 +145,9 @@ func sendAction(n *Node, atype widget.ActionType) {
}
}
- var a widget.Action
- a.ActionType = atype
-
- // These should be "stable" at this point (2024/01/13)
- a.WidgetId = n.id
-
- // set state
- a.State.ProgName = n.progname
- a.State.Label = n.label
- a.State.Value = n.value
-
- a.State.Checked = n.checked
- a.State.Visable = n.visable
- // TODO: if visable == false here, return
- a.State.Enable = n.enabled
- a.State.Pad = n.pad
- a.State.Expand = n.expand
- a.State.Borderless = n.borderless
- a.State.Direction = n.direction
-
- for s, _ := range n.strings {
- a.State.Strings = append(a.State.Strings, s)
- }
- a.State.Range.Low = n.X
- a.State.Range.High = n.Y
-
- a.ProgName = n.progname
- a.Value = n.value
- a.Direction = n.direction
-
- // These should be improved/deprecated based on the gui/widget docs
- a.X = n.X
- a.Y = n.Y
-
- a.State.GridOffset.X = n.AtW
- a.State.GridOffset.Y = n.AtH
-
- if n.parent != nil {
- a.ParentId = n.parent.id
- }
- a.WidgetType = n.WidgetType
- sendActionToPlugin(&a)
+ // make a new action and populate the current node state
+ a := getNewAction(n, atype)
+ sendActionToPlugin(a)
}
// sends the action/event to each toolkit via a golang plugin channel