diff options
Diffstat (limited to 'action.go')
| -rw-r--r-- | action.go | 52 |
1 files changed, 44 insertions, 8 deletions
@@ -10,6 +10,8 @@ package gui */ import ( + "errors" + "go.wit.com/log" "go.wit.com/gui/widget" ) @@ -19,10 +21,22 @@ import ( // 2023/04/06 Queue() is also being used and channels are being used. func sendAction(n *Node, atype widget.ActionType) { if n == nil { + log.Error(errors.New("Sending Action on n = nil")) + log.Warn("Sending Action on n = nil") return } + n.mu.Lock() + defer n.mu.Unlock() + log.Warn("SENDING ACTION STRINGS n.Strings", n.strings) + + // if the widget is hidden, don't send actions to the plugin if n.hidden { - return + if atype == widget.Hide { + // well, unless this is a Hide action, then inform the toolkit + } else { + log.Warn("NOT SENDING HIDDEN ACTION", n.GetProgName(), atype) + // return + } } var a widget.Action @@ -30,17 +44,29 @@ func sendAction(n *Node, atype widget.ActionType) { // 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.Direction = n.direction + for s, _ := range n.strings { + a.State.Strings = append(a.State.Strings, s) + } + log.Warn("SENDING ACTION STRINGS a.Strings", a.Strings) + a.State.Range.Low = n.X + a.State.Range.High = n.Y + a.ProgName = n.progname a.Value = n.value a.Direction = n.direction - a.Strings = n.strings // These should be improved/deprecated based on the gui/widget docs a.X = n.X a.Y = n.Y - a.AtW = n.AtW - a.AtH = n.AtH + a.State.GridOffset.X = n.AtW + a.State.GridOffset.Y = n.AtH if (n.parent != nil) { a.ParentId = n.parent.id @@ -54,13 +80,23 @@ func sendActionToPlugin(a *widget.Action) { for _, aplug := range allPlugins { log.Log(PLUG, "Action() aplug =", aplug.name, "Action type=", a.ActionType) if (aplug.pluginChan == nil) { - log.Info("Action() retrieving the aplug.PluginChannel()", aplug.name) + log.Warn("Action() retrieving the aplug.PluginChannel()", aplug.name) aplug.pluginChan = aplug.PluginChannel() - log.Info("Action() retrieved", aplug.pluginChan) + log.Warn("Action() retrieved", aplug.pluginChan) } - log.Info("Action() SEND to pluginChan", aplug.name, a.ActionType, a.WidgetType, a.WidgetId, a.ProgName) + log.Verbose("Action() SEND to pluginChan", aplug.name, a.ActionType, a.WidgetType, a.WidgetId, a.ProgName) aplug.pluginChan <- *a // added during debugging. might be a good idea in general for a tactile experience - log.Sleep(.02) // this delay makes it so SetText() works on initial widget creation + // start playing with this + if a.ActionType == widget.Hide { + // log.Sleep(.001) // this delay makes it so SetText() works on initial widget creation + } else { + // 2024/12/16 still leaving this as I'm not sure binary tree access is actually + // safe (thread safe, correct locking, etc). I think it is. Things seem stable + // sync.Mutex() locks don't appear to work somehow in a way I don't understand + // it's probably due to []string use. use map[] instead + // log.Sleep(.000001) // this delay makes it so SetText() works on initial widget creation + log.Sleep(.002) // this delay makes it so SetText() works on initial widget creation + } } } |
