diff options
| author | Jeff Carr <[email protected]> | 2024-01-20 19:32:30 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-20 19:32:30 -0600 |
| commit | dfb7a47e8cccd82080de3d6ba97855eeb2be6593 (patch) | |
| tree | e2a8f4696984ec21eacd4ceba146618a35c456c7 | |
| parent | 7012aff2aebdc74d950d921262e0ddfa677761e4 (diff) | |
log settings works againv0.12.19
still dreaming of protobuf here
go mod update
show panic for now
finally drop sending stuff for non-visable windows
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | action.go | 52 | ||||
| -rw-r--r-- | common.go | 16 | ||||
| -rw-r--r-- | go.mod | 4 | ||||
| -rw-r--r-- | go.sum | 6 | ||||
| -rw-r--r-- | main.go | 13 | ||||
| -rw-r--r-- | node.go | 2 |
7 files changed, 79 insertions, 17 deletions
@@ -18,6 +18,9 @@ ifeq ($(GO111MODULE),) @echo endif +goimports: + goimports -w *.go + redomod: rm -f go.* goimports -w *.go @@ -16,6 +16,27 @@ import ( "go.wit.com/widget" ) +func (n *Node) SetVisable(b bool) { + n.visable = b +} + +// returns true if the window is not visable to the user +// in which case events are not sent to the toolkit +func (n *Node) WindowVisable() bool { + if n == nil { + return true + } + if n.WidgetType == widget.Window { + return n.visable + } + if n.parent == nil { + return true + } else { + return n.parent.WindowVisable() + } + return true +} + // 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. @@ -27,16 +48,27 @@ func sendAction(n *Node, atype widget.ActionType) { } n.mu.Lock() defer n.mu.Unlock() - log.Warn("SENDING ACTION STRINGS n.Strings", n.strings, n.id, n.WidgetType, n.GetProgName()) + // log.Warn("SENDING ACTION STRINGS n.Strings", n.strings, n.id, n.WidgetType, n.GetProgName()) // if the widget is hidden, don't send actions to the plugin - if n.hidden { - if atype == widget.Hide { - // well, unless this is a Hide action, then inform the toolkit - log.Warn("SENDING HIDDEN ACTION. IS THIS A WINDOW?", n.GetProgName(), atype) - } else { - log.Warn("NOT SENDING HIDDEN ACTION", n.GetProgName(), atype) - // return + /* + if n.hidden { + if atype == widget.Hide { + // well, unless this is a Hide action, then inform the toolkit + log.Warn("SENDING HIDDEN ACTION. IS THIS A WINDOW?", n.GetProgName(), atype) + } else { + log.Warn("NOT SENDING HIDDEN ACTION", n.GetProgName(), atype) + // return + } + } + */ + + // this checks to see if the window is show in the toolkit. If it is not, + // then don't send any events. Unless it is a window widget, then send events + if n.WidgetType != widget.Window { + if !n.WindowVisable() { + log.Warn("NOT SENDING ACTION. Window is not visable", n.id, n.WidgetType, n.GetProgName()) + return } } @@ -61,8 +93,8 @@ func sendAction(n *Node, atype widget.ActionType) { for s, _ := range n.strings { a.State.Strings = append(a.State.Strings, s) } - log.Warn("SENDING ACTION STRINGS a.Strings", a.Strings) - log.Warn("SENDING ACTION a.State.Value", a.State.Value) + // log.Warn("SENDING ACTION STRINGS a.Strings", a.Strings) + // log.Warn("SENDING ACTION a.State.Value", a.State.Value) a.State.Range.Low = n.X a.State.Range.High = n.Y @@ -115,6 +115,16 @@ func (n *Node) Int() int { return widget.GetInt(n.value) } +func (n *Node) SetBool(b bool) { + switch n.WidgetType { + case widget.Checkbox: + n.checked = b + n.value = b + default: + log.Warn("WidgetType not bool", n.WidgetType, n.id) + } +} + func (n *Node) String() string { if !n.Ready() { return "" @@ -321,6 +331,12 @@ func (n *Node) Ready() bool { return true } +// returns the root of the binary tree +// change the names to 'Tree' as I think the name is better +func TreeRoot() *Node { + return me.rootNode +} + // // // DEPRECATE / REDO / SORT OUT THIS STUFF @@ -4,8 +4,8 @@ go 1.21.4 require ( go.wit.com/dev/alexflint/arg v1.4.5 - go.wit.com/log v0.5.5 - go.wit.com/widget v1.1.5 + go.wit.com/log v0.5.6 + go.wit.com/widget v1.1.6 ) require ( @@ -6,5 +6,7 @@ go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNe go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4= go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30= -go.wit.com/widget v1.1.5/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= +go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= +go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= +go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY= +go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= @@ -107,7 +107,7 @@ func watchCallback() { log.Warn("guiChan() Enable Debugging Window") log.Warn("guiChan() TODO: not implemented") log.Warn("guiChan() Listing Toolkits:") - PLUG.Set(true) + PLUG.SetBool(true) me.rootNode.ListToolkits() me.rootNode.ListChildren(true) /* @@ -134,7 +134,16 @@ func watchCallback() { // TODO: implement throttling someday func (n *Node) gotUserEvent(a widget.Action) { log.Info("gotUserEvent() received event node =", n.id, n.progname, a.Value) - n.value = a.Value + + switch n.WidgetType { + case widget.Checkbox: + // n.checked = a.State.Checked // TODO: do this and/or time to switch to protobuf + n.checked = widget.GetBool(a.Value) + default: + } + + n.SetValue(a.Value) + log.Info("gotUserEvent() n.Bool() =", n.Bool(), "n.String() =", n.String()) if n.Custom == nil { log.Info("a Custom() function was not set for this widget") return @@ -16,7 +16,7 @@ there isn't much to see here. func (n *Node) newNode(title string, t widget.WidgetType) *Node { if n == nil { log.Warn("newNode got parent == nil") - log.Exit(0) + panic("gui newNode") } var newN *Node |
