From e1cd1a27a3064c61fa3a42e59de937ac2c8def43 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 27 Jan 2024 10:03:01 -0600 Subject: [PATCH] nocui works release automation testing try to track disable state Signed-off-by: Jeff Carr --- .gitignore | 1 + action.go | 27 +++++++++++++++++++-------- go.mod | 6 +++--- go.sum | 12 ++++++------ 4 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/action.go b/action.go index 4e7c636..f61c218 100644 --- a/action.go +++ b/action.go @@ -80,6 +80,11 @@ func ready(n *tree.Node) bool { return true } +func hide(n *tree.Node) { + show(n, false) + n.State.Hidden = true +} + func show(n *tree.Node, b bool) { if tkbad(n) { return @@ -102,14 +107,11 @@ func show(n *tree.Node, b bool) { } func enable(n *tree.Node, b bool) { - var tk *guiWidget - tk = n.TK.(*guiWidget) - if n == nil { - panic("WHAT? enable was passed nil. How does this even happen?") - } - if tk == nil { + if !ready(n) { return } + var tk *guiWidget + tk = n.TK.(*guiWidget) if tk.uiControl == nil { return } @@ -199,7 +201,16 @@ func processAction(a *widget.Action) { if a.ActionType == widget.Add { n := add(a) - show(n, !a.State.Hidden) + // show(n, !a.State.Hidden) + if a.State.Hidden { + hide(n) + } else { + if a.State.Enable { + // nothing to do + } else { + enable(n, false) + } + } // pad(n, n.State.Pad) // expand(n, a.State.Expand) return @@ -238,7 +249,7 @@ func processAction(a *widget.Action) { case widget.Show: show(n, true) case widget.Hide: - show(n, false) + hide(n) case widget.Enable: enable(n, true) case widget.Disable: diff --git a/go.mod b/go.mod index 8159e2e..27b0a53 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.21.4 require ( go.wit.com/dev/andlabs/ui v0.0.1 - go.wit.com/log v0.5.6 - go.wit.com/toolkits/tree v0.13.13 - go.wit.com/widget v1.1.7 + go.wit.com/log v0.13.0 + go.wit.com/toolkits/tree v0.13.14 + go.wit.com/widget v1.1.8 ) require go.wit.com/dev/davecgh/spew v1.1.4 // indirect diff --git a/go.sum b/go.sum index 662253b..92b8ecf 100644 --- a/go.sum +++ b/go.sum @@ -2,9 +2,9 @@ go.wit.com/dev/andlabs/ui v0.0.1 h1:SowOybLBu/qUOqp905EZikz5/iPa3GpmnCAPzNOYajM= go.wit.com/dev/andlabs/ui v0.0.1/go.mod h1:mlKEEe05ZJURzjh1LtjzdGMHVbJm9a7BUaVpA9cHxsM= 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.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= -go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/toolkits/tree v0.13.13 h1:2/3hTZ7mMxbxsFnIgknySEbTdX/cHxpdHqK5xUoP7fI= -go.wit.com/toolkits/tree v0.13.13/go.mod h1:BUJYvkdwGjuyK987nELtZXyqOf4cbMWx+TV+Kon6MtU= -go.wit.com/widget v1.1.7 h1:Gy84I2bD8CMna7NcKBX4sRLR8do6x6mVYX0Ui43f3is= -go.wit.com/widget v1.1.7/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= +go.wit.com/log v0.13.0 h1:0vyW3mHwDww3wCsyGnmQuX2P4V7aBMoJgxCy0GfA20g= +go.wit.com/log v0.13.0/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= +go.wit.com/toolkits/tree v0.13.14 h1:Hy1tbgSL67rvlXkPCz65CDq03i2VeilL95gtOpkzOpo= +go.wit.com/toolkits/tree v0.13.14/go.mod h1:f9ihlbRaORRqgWiqOslfUbLkFRgIjBWY0nG0MidHC7g= +go.wit.com/widget v1.1.8 h1:5cHcmfgwCyHjf02Af/9UMrbLhBR7Z/LFAjPuCx4dx5A= +go.wit.com/widget v1.1.8/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=