summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-20 19:32:30 -0600
committerJeff Carr <[email protected]>2024-01-20 19:32:30 -0600
commitdfb7a47e8cccd82080de3d6ba97855eeb2be6593 (patch)
treee2a8f4696984ec21eacd4ceba146618a35c456c7
parent7012aff2aebdc74d950d921262e0ddfa677761e4 (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--Makefile3
-rw-r--r--action.go52
-rw-r--r--common.go16
-rw-r--r--go.mod4
-rw-r--r--go.sum6
-rw-r--r--main.go13
-rw-r--r--node.go2
7 files changed, 79 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 413f145..5a7fd91 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,9 @@ ifeq ($(GO111MODULE),)
@echo
endif
+goimports:
+ goimports -w *.go
+
redomod:
rm -f go.*
goimports -w *.go
diff --git a/action.go b/action.go
index 6db01eb..1580bf7 100644
--- a/action.go
+++ b/action.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
diff --git a/common.go b/common.go
index a46ecb5..7b9c162 100644
--- a/common.go
+++ b/common.go
@@ -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
diff --git a/go.mod b/go.mod
index b9189cb..9ba8e31 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.5.5
- go.wit.com/widget v1.1.5
+ go.wit.com/log v0.5.6
+ go.wit.com/widget v1.1.6
)
require (
diff --git a/go.sum b/go.sum
index d4d1001..08f0388 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
diff --git a/main.go b/main.go
index f86dc54..91dea02 100644
--- a/main.go
+++ b/main.go
@@ -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
diff --git a/node.go b/node.go
index a66ac93..bb26656 100644
--- a/node.go
+++ b/node.go
@@ -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