diff options
Diffstat (limited to 'action.go')
| -rw-r--r-- | action.go | 93 |
1 files changed, 51 insertions, 42 deletions
@@ -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 |
