Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 04:08:11 -06:00
parent 3ea3dd10db
commit a78eadea02
11 changed files with 40 additions and 33 deletions

View File

@ -2,3 +2,10 @@ redomod:
rm -f go.*
GO111MODULE= go mod init
GO111MODULE= go mod tidy
download:
go get -v go.wit.com/toolkits/debian
go get -v go.wit.com/toolkits/tree
go get -v go.wit.com/toolkits/nogui
go get -v go.wit.com/toolkits/gogui
go get -v go.wit.com/toolkits/andlabs

View File

@ -4,7 +4,7 @@ import (
"errors"
"go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
// this is in common.go, do not move it
@ -17,14 +17,14 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node {
n.State = a.State
n.Strings = make(map[string]int)
if (a.WidgetType == widget.Root) {
if a.WidgetType == widget.Root {
log.Info("AddNode() Root")
n.Parent = n
me.treeRoot = n
return n
}
if (me.treeRoot.FindWidgetId(a.WidgetId) != nil) {
if me.treeRoot.FindWidgetId(a.WidgetId) != nil {
log.Warn("AddNode() WidgetId already exists", a.WidgetId)
log.Warn("probably this is a Show() / Hide() issue")
log.Warn("TODO: figure out what to do here")

View File

@ -1,7 +1,7 @@
package tree
import (
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
func (n *Node) GetProgName() string {

View File

@ -2,7 +2,7 @@ package tree
import (
"go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
func (n *Node) ShowButtons() {
@ -22,7 +22,7 @@ func (n *Node) DumpWidget(pad string) {
var depth int = 0
func (n *Node) ListWidgets() {
if (n == nil) {
if n == nil {
log.Warn("ERRRORRRR: n == nil in ListWidgets()")
log.Warn("ERRRORRRR: n == nil in ListWidgets()")
log.Warn("ERRRORRRR: n == nil in ListWidgets()")

View File

@ -13,11 +13,11 @@ package tree
import (
"go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
func (me *TreeInfo) DoEnableDebugger() {
if (me.callback == nil) {
if me.callback == nil {
log.Warn("DoUserEvent() toolkit panic() callback == nil")
return
}
@ -29,7 +29,7 @@ func (me *TreeInfo) DoEnableDebugger() {
}
func (me *TreeInfo) DoToolkitLoad(s string) {
if (me.callback == nil) {
if me.callback == nil {
log.Warn("DoUserEvent() toolkit load callback == nil")
return
}
@ -44,7 +44,7 @@ func (me *TreeInfo) DoToolkitLoad(s string) {
}
func (me *TreeInfo) DoToolkitPanic() {
if (me.callback == nil) {
if me.callback == nil {
log.Warn("DoUserEvent() toolkit panic() callback == nil")
return
}
@ -58,7 +58,7 @@ func (me *TreeInfo) DoToolkitPanic() {
}
func (me *TreeInfo) DoWindowCloseEvent(n *Node) {
if (me.callback == nil) {
if me.callback == nil {
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
return
}
@ -73,7 +73,7 @@ func (me *TreeInfo) DoWindowCloseEvent(n *Node) {
// Other goroutines must use this to access the GUI
func (me *TreeInfo) DoUserEvent(n *Node) {
if (me.callback == nil) {
if me.callback == nil {
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
return
}

2
go.mod
View File

@ -3,8 +3,8 @@ module go.wit.com/toolkits/tree
go 1.21.4
require (
go.wit.com/gui/widget v1.1.4
go.wit.com/log v0.5.5
go.wit.com/widget v1.1.5
)
require go.wit.com/dev/davecgh/spew v1.1.4 // indirect

4
go.sum
View File

@ -1,6 +1,6 @@
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/gui/widget v1.1.4 h1:dCztWNSuTSSP+/M8h8F3cT7vWtoKdCL3DUQql0qLKdk=
go.wit.com/gui/widget v1.1.4/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
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=

View File

@ -1,11 +1,11 @@
package tree
import (
"sync"
"errors"
"sync"
"go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
var muAction sync.Mutex
@ -29,7 +29,7 @@ func (me *TreeInfo) catchActionChannel() {
log.Info("catchActionChannel() START")
for {
log.Info("catchActionChannel() for loop")
select {
select {
case a := <-me.pluginChan:
log.Info("catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
log.Warn("catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
// makes a JSON version to pass to the toolkits ?

View File

@ -12,12 +12,12 @@ package tree
*/
import (
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
// searches the binary tree for a WidgetId
func (n *Node) FindWidgetId(id int) *Node {
if (n == nil) {
if n == nil {
return nil
}
@ -27,7 +27,7 @@ func (n *Node) FindWidgetId(id int) *Node {
for _, child := range n.children {
newN := child.FindWidgetId(id)
if (newN != nil) {
if newN != nil {
return newN
}
}

View File

@ -13,12 +13,12 @@ package tree
import (
// "go.wit.com/log"
"go.wit.com/lib/widget"
"go.wit.com/widget"
)
// var me *TreeInfo
type TreeInfo struct {
type TreeInfo struct {
// this is the channel we send user events like
// mouse clicks or keyboard events back to the program
callback chan widget.Action
@ -26,21 +26,21 @@ type TreeInfo struct {
// this is the channel we get requests to make widgets
pluginChan chan widget.Action
treeRoot *Node
NodeI interface {}
ActionFromChannel func (widget.Action) ()
PluginName string
treeRoot *Node
NodeI interface{}
ActionFromChannel func(widget.Action)
PluginName string
}
type Node struct {
Parent *Node
Parent *Node
children []*Node
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
State widget.State
State widget.State
Strings map[string]int