From fd1e048167ef152a5c04bc58f00ec22a0dffc08c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 27 Jan 2024 12:30:34 -0600 Subject: load toolkit working better Signed-off-by: Jeff Carr --- action.go | 93 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 42 deletions(-) (limited to 'action.go') 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 -- cgit v1.2.3