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 ++++++++++++++++++++++++++++++++++----------------------------- go.mod | 4 +-- go.sum | 8 +++--- redraw.go | 25 +---------------- 4 files changed, 58 insertions(+), 72 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 diff --git a/go.mod b/go.mod index 0896a32..4278d18 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.21.4 require ( go.wit.com/dev/alexflint/arg v1.4.5 - go.wit.com/log v0.13.0 - go.wit.com/widget v1.1.8 + go.wit.com/log v0.13.18 + go.wit.com/widget v1.1.9 ) require ( diff --git a/go.sum b/go.sum index 739d547..d9874f9 100644 --- a/go.sum +++ b/go.sum @@ -4,7 +4,7 @@ go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26 go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= -go.wit.com/log v0.13.0 h1:0vyW3mHwDww3wCsyGnmQuX2P4V7aBMoJgxCy0GfA20g= -go.wit.com/log v0.13.0/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/widget v1.1.8 h1:5cHcmfgwCyHjf02Af/9UMrbLhBR7Z/LFAjPuCx4dx5A= -go.wit.com/widget v1.1.8/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= +go.wit.com/log v0.13.18 h1:XJNaQWX+8m12p3mH+kYih3zNjb0kScZDFpJa4c2TvKE= +go.wit.com/log v0.13.18/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= +go.wit.com/widget v1.1.9 h1:iltjAL8UZu0YPfia8/qyfDx04BDxhj8rURcx0OHVBEc= +go.wit.com/widget v1.1.9/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= diff --git a/redraw.go b/redraw.go index f4b8214..6661bb1 100644 --- a/redraw.go +++ b/redraw.go @@ -23,29 +23,6 @@ func (n *Node) redraw(p *aplug) { func (n *Node) redo(plug *aplug) { log.Log(NOW, "redo()", plug.name, n.id, n.WidgetType, n.progname) - var a *widget.Action - a = new(widget.Action) - a.ProgName = n.progname - a.Value = n.value - - a.ActionType = widget.Add - a.WidgetType = n.WidgetType - a.WidgetId = n.id - - // used for anything that needs a range - a.X = n.X - a.Y = n.Y - - // grid stuff - a.AtW = n.AtW - a.AtH = n.AtH - - if n.parent == nil { - a.ParentId = 0 - } else { - a.ParentId = n.parent.id - } - + a := getNewAction(n, widget.Add) plug.pluginChan <- *a - // sleep(.5) } -- cgit v1.2.3