fixed for new 'tree' package
This commit is contained in:
parent
2b8673e04c
commit
9e177d2636
Notes:
Jeff Carr
2025-02-14 19:32:54 -06:00
// `autogen:go.mod` module go.wit.com/toolkits/pixelgl go 1.22 toolchain go1.23.6 require ( github.com/faiface/pixel v0.10.0 github.com/go-gl/mathgl v1.2.0 github.com/gookit/config v1.1.0 go.wit.com/dev/alexflint/arg v1.5.5 go.wit.com/lib/protobuf/guipb v0.0.2 go.wit.com/log v0.22.16 go.wit.com/toolkits/tree v0.22.10 go.wit.com/widget v1.1.29 golang.org/x/image v0.24.0 ) require ( github.com/faiface/glhf v0.0.0-20181018222622-82a6317ac380 // indirect github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 // indirect github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72 // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/pkg/errors v0.8.1 // indirect go.wit.com/dev/alexflint/scalar v1.2.4 // indirect google.golang.org/protobuf v1.36.5 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) // `autogen:go.sum` github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/faiface/glhf v0.0.0-20181018222622-82a6317ac380 h1:FvZ0mIGh6b3kOITxUnxS3tLZMh7yEoHo75v3/AgUqg0= github.com/faiface/glhf v0.0.0-20181018222622-82a6317ac380/go.mod h1:zqnPFFIuYFFxl7uH2gYByJwIVKG7fRqlqQCbzAnHs9g= github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 h1:baVdMKlASEHrj19iqjARrPbaRisD7EuZEVJj6ZMLl1Q= github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3/go.mod h1:VEPNJUlxl5KdWjDvz6Q1l+rJlxF2i6xqDeGuGAxa87M= github.com/faiface/pixel v0.10.0 h1:EHm3ZdQw2Ck4y51cZqFfqQpwLqNHOoXwbNEc9Dijql0= github.com/faiface/pixel v0.10.0/go.mod h1:lU0YYcW77vL0F1CG8oX51GXurymL45MXd57otHNLK7A= github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw= github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72 h1:b+9H1GAsx5RsjvDFLoS5zkNBzIQMuVKUYQDmxU3N5XE= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/mathgl v1.2.0 h1:v2eOj/y1B2afDxF6URV1qCYmo1KW08lAMtTbOn3KXCY= github.com/go-gl/mathgl v1.2.0/go.mod h1:pf9+b5J3LFP7iZ4XXaVzZrCle0Q/vNpB/vDe5+3ulRE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gookit/config v1.1.0 h1:mO4aPz0jMUIKS8FdEQo6oQJ1Cd+DLCx4NCvJZOjBPnA= github.com/gookit/config v1.1.0/go.mod h1:+0W5UvRpZaChP3aXx0cZ+zv7U9tvX+0oSGjisJA6fWA= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= go.wit.com/dev/alexflint/arg v1.5.5 h1:c4jgIb4OvHjnCMRNSjOa1sNLl6WDxV6tIkMVezR9hCk= go.wit.com/dev/alexflint/arg v1.5.5/go.mod h1:nH3F6TJDaAUgnLkC0WgRN/H047YfN1TYKaWPYr6B8lo= go.wit.com/dev/alexflint/scalar v1.2.4 h1:zmBeEkObwz1lcelwfGNYP2GS6SQ9e0tdv7JdHwMZEEk= go.wit.com/dev/alexflint/scalar v1.2.4/go.mod h1:kCNO1Fo5LnnK6+qa+zYhP5fdgfC1C+vx1ti99Md+FAM= go.wit.com/lib/protobuf/guipb v0.0.2 h1:ZR4cLy+XheRQEFLlissBmASJDqiLfHaAluF6wYbVuOo= go.wit.com/lib/protobuf/guipb v0.0.2/go.mod h1:mZsirb7zRgsE2IGHuvHkG7j85hkrGZl3NAALOEkjowA= go.wit.com/log v0.22.16 h1:E0Vd0Z2ILtfjhs7J/CQ4g13DK1jtQiYl6l5KOBGsZoA= go.wit.com/log v0.22.16/go.mod h1:/c5Uj30sWRQ4B5ei2ElB6Q8Si/cK6v+KbxnH208KD84= go.wit.com/toolkits/tree v0.22.10 h1:h1sHPBenR0Ohj0LG4nL3nW6/deCsbb+qeBmw8Idl6w8= go.wit.com/toolkits/tree v0.22.10/go.mod h1:BhgxAFb8LxpM/L9e8nM+fQdM9MYi6lInMagRIX5+VTA= go.wit.com/widget v1.1.29 h1:rURM/N1hbrl0btGlBIUx0SCre9jj+hshvkBLMMa008I= go.wit.com/widget v1.1.29/go.mod h1:wj7TpAr2gk7Poa+v8XQkH1aidnTdgAa/a8GxrMtcztw= golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ= golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= // `autogen:`
5
Makefile
5
Makefile
|
@ -4,8 +4,11 @@ BUILDTIME = $(shell date +%Y.%m.%d)
|
|||
all: goimports plugin
|
||||
#ldd pixelgl.so
|
||||
|
||||
deps:
|
||||
sudo apt install libxxf86vm-dev libxxf86vm1
|
||||
|
||||
plugin:
|
||||
GO111MODULE=off go build -v -x -buildmode=plugin -o pixelgl.so
|
||||
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ GO111MODULE=off go build -v -x -buildmode=plugin -o pixelgl.so
|
||||
|
||||
install:
|
||||
rm -f pixelgo.so
|
||||
|
|
35
action.go
35
action.go
|
@ -7,12 +7,13 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"go.wit.com/lib/protobuf/guipb"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func Add(n *tree.Node) {
|
||||
func newAdd(n *tree.Node) {
|
||||
log.Log(INFO, "Add() END =", n.WidgetType, n.String())
|
||||
if n == nil {
|
||||
log.Warn("Tree Error: Add() sent n == nil")
|
||||
|
@ -68,15 +69,15 @@ func newaction(n *tree.Node, atype widget.ActionType) {
|
|||
log.Log(INFO, "newaction() END", atype, n.String())
|
||||
}
|
||||
|
||||
func SetTitle(n *tree.Node, s string) {
|
||||
SetText(n, s)
|
||||
func setTitle(n *tree.Node, s string) {
|
||||
setText(n, s)
|
||||
}
|
||||
|
||||
func SetLabel(n *tree.Node, s string) {
|
||||
SetText(n, s)
|
||||
func setLabel(n *tree.Node, s string) {
|
||||
setText(n, s)
|
||||
}
|
||||
|
||||
func SetText(n *tree.Node, s string) {
|
||||
func setText(n *tree.Node, s string) {
|
||||
if n == nil {
|
||||
log.Warn("Tree Error: Add() sent n == nil")
|
||||
return
|
||||
|
@ -90,7 +91,7 @@ func SetText(n *tree.Node, s string) {
|
|||
log.Info("SetText()", n.WidgetType, n.String())
|
||||
}
|
||||
|
||||
func AddText(n *tree.Node, s string) {
|
||||
func addText(n *tree.Node, s string) {
|
||||
if n == nil {
|
||||
log.Warn("Tree Error: Add() sent n == nil")
|
||||
return
|
||||
|
@ -103,3 +104,23 @@ func AddText(n *tree.Node, s string) {
|
|||
// w := n.TK.(*guiWidget)
|
||||
// w.AddText(s)
|
||||
}
|
||||
|
||||
func enableWidget(n *tree.Node) {
|
||||
log.Info("do enable() here")
|
||||
}
|
||||
|
||||
func disableWidget(n *tree.Node) {
|
||||
log.Info("do enable() here")
|
||||
}
|
||||
|
||||
func setChecked(n *tree.Node, b bool) {
|
||||
log.Info("do enable() here")
|
||||
}
|
||||
|
||||
func showTable(n *guipb.Table) {
|
||||
log.Info("do enable() here")
|
||||
}
|
||||
|
||||
func toolkitClose() {
|
||||
log.Info("do enable() here")
|
||||
}
|
||||
|
|
25
main.go
25
main.go
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
|
||||
"github.com/faiface/pixel/pixelgl"
|
||||
// "github.com/gookit/config"
|
||||
|
@ -24,6 +23,8 @@ import (
|
|||
var VERSION string
|
||||
var BUILDTIME string
|
||||
|
||||
var PLUGIN string = "pixelgl"
|
||||
|
||||
//go:embed resources/*
|
||||
var resources embed.FS
|
||||
|
||||
|
@ -32,21 +33,23 @@ var pp *arg.Parser
|
|||
// the glsl file
|
||||
var glslFile string
|
||||
|
||||
func init() {
|
||||
func initPlugin() {
|
||||
pp = arg.MustParse(&argv)
|
||||
|
||||
log.Log(INFO, "Init()")
|
||||
|
||||
me.myTree = tree.New()
|
||||
me.myTree.PluginName = "nocui"
|
||||
// me.myTree.ActionFromChannel = doAction
|
||||
me.myTree = initTree()
|
||||
/*
|
||||
me.myTree.PluginName = "nocui"
|
||||
// me.myTree.ActionFromChannel = doAction
|
||||
|
||||
me.myTree.NodeAction = newaction
|
||||
me.myTree.Add = Add
|
||||
me.myTree.SetTitle = SetTitle
|
||||
me.myTree.SetLabel = SetLabel
|
||||
me.myTree.SetText = SetText
|
||||
me.myTree.AddText = AddText
|
||||
me.myTree.NodeAction = newaction
|
||||
me.myTree.Add = Add
|
||||
me.myTree.SetTitle = SetTitle
|
||||
me.myTree.SetLabel = SetLabel
|
||||
me.myTree.SetText = SetText
|
||||
me.myTree.AddText = AddText
|
||||
*/
|
||||
|
||||
me.exit = false
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"go.wit.com/toolkits/tree"
|
||||
)
|
||||
|
||||
|
@ -13,8 +15,8 @@ type guiWidget struct {
|
|||
val map[string]int
|
||||
}
|
||||
|
||||
// It's probably a terrible idea to call this 'me'
|
||||
var me toolkitConfig
|
||||
var initOnce sync.Once // run initPlugin() only once
|
||||
var me toolkitConfig // It's probably a terrible idea to call this 'me'
|
||||
|
||||
type toolkitConfig struct {
|
||||
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
||||
|
|
24
tree.go
24
tree.go
|
@ -1,24 +0,0 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
This is reference code for toolkit developers
|
||||
*/
|
||||
|
||||
import (
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// Other goroutines must use this to access the GUI
|
||||
//
|
||||
// You can not acess / process the GUI thread directly from
|
||||
// other goroutines. This is due to the nature of how
|
||||
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
|
||||
//
|
||||
// this sets the channel to send user events back from the plugin
|
||||
func Callback(guiCallback chan widget.Action) {
|
||||
me.myTree.Callback(guiCallback)
|
||||
}
|
||||
|
||||
func PluginChannel() chan widget.Action {
|
||||
return me.myTree.PluginChannel()
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
/*
|
||||
DO NOT EDIT THIS FILE
|
||||
|
||||
this file is the same for every GUI toolkit plugin
|
||||
when you are making a new GUI toolkit plugin for
|
||||
a specific toolkit, you just need to define these
|
||||
functions.
|
||||
|
||||
for example, in the "gocui" toolkit, the functions
|
||||
below are what triggers the "gocui" GO package
|
||||
to draw labels, buttons, windows, etc
|
||||
|
||||
If you are starting out trying to make a new GUI toolkit,
|
||||
all you have to do is copy this file over. Then
|
||||
work on making these functions. addWidget(), setText(), etc.
|
||||
|
||||
That's it!
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
This is reference code for toolkit developers
|
||||
|
||||
This is how information is passed in GO back to the application
|
||||
via the GO 'plugin' concept
|
||||
|
||||
TODO: switch this to protocol buffers
|
||||
*/
|
||||
|
||||
import (
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// Other goroutines must use this to access the GUI
|
||||
//
|
||||
// You can not acess / process the GUI thread directly from
|
||||
// other goroutines. This is due to the nature of how
|
||||
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
|
||||
//
|
||||
// this sets the channel to send user events back from the plugin
|
||||
func Callback(guiCallback chan widget.Action) {
|
||||
me.myTree.Callback(guiCallback)
|
||||
}
|
||||
|
||||
func PluginChannel() chan widget.Action {
|
||||
initOnce.Do(initPlugin)
|
||||
return me.myTree.PluginChannel()
|
||||
}
|
||||
|
||||
func initTree() *tree.TreeInfo {
|
||||
t := tree.New()
|
||||
t.PluginName = PLUGIN
|
||||
t.Add = newAdd
|
||||
t.SetTitle = setTitle
|
||||
t.SetLabel = setLabel
|
||||
t.SetText = setText
|
||||
t.AddText = addText
|
||||
|
||||
t.Enable = enableWidget
|
||||
t.Disable = disableWidget
|
||||
|
||||
t.SetChecked = setChecked
|
||||
t.ToolkitClose = toolkitClose
|
||||
t.ShowTable = showTable
|
||||
|
||||
return t
|
||||
}
|
Loading…
Reference in New Issue