Compare commits
No commits in common. "master" and "v0.20.8" have entirely different histories.
|
@ -1,5 +1,3 @@
|
||||||
*.swp
|
*.swp
|
||||||
go.mod
|
go.mod
|
||||||
go.sum
|
go.sum
|
||||||
pixelgl
|
|
||||||
*.so
|
|
||||||
|
|
30
Makefile
30
Makefile
|
@ -1,32 +1,12 @@
|
||||||
VERSION = $(shell git describe --tags)
|
all: plugin
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
ldd ../pixelgl.so
|
||||||
|
|
||||||
all: clean goimports plugin
|
|
||||||
#ldd pixelgl.so
|
|
||||||
|
|
||||||
deps:
|
|
||||||
sudo apt install libxxf86vm-dev libxxf86vm1
|
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ GO111MODULE=off go build -v -x -buildmode=plugin -o pixelgl.so
|
GO111MODULE=off go build -v -x -buildmode=plugin -o ../pixelgl.so
|
||||||
|
|
||||||
install:
|
|
||||||
rm -f pixelgo.so
|
|
||||||
go build -v -x -buildmode=plugin -o ~/go/lib/pixelgl-${VERSION}.so
|
|
||||||
cd ~/go/lib && ln -f -s pixelgl-${VERSION}.so pixelgl.so
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f pixelgl pixelgl.so
|
|
||||||
|
|
||||||
full-plugin:
|
|
||||||
GO111MODULE=off go build -v -x -buildmode=plugin -o pixelgl.so
|
|
||||||
|
|
||||||
full-install:
|
|
||||||
GO111MODULE=off go build -v -x -buildmode=plugin -o pixelgl.so
|
|
||||||
|
|
||||||
standalone:
|
standalone:
|
||||||
GO111MODULE=off go build -v -x
|
GO111MODULE=off go install -v -x
|
||||||
./pixelgl
|
pixelgl
|
||||||
|
|
||||||
check-git-clean:
|
check-git-clean:
|
||||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||||
|
|
|
@ -3,5 +3,3 @@
|
||||||
Package gui implements a abstraction layer for Go visual elements.
|
Package gui implements a abstraction layer for Go visual elements.
|
||||||
|
|
||||||
This is a sample plugin. It's a skeleton intended to be used when making a new toolkit plugin.
|
This is a sample plugin. It's a skeleton intended to be used when making a new toolkit plugin.
|
||||||
|
|
||||||
# github.com/faiface/pixel-examples/community/seascape-shader/
|
|
||||||
|
|
37
action.go
37
action.go
|
@ -7,13 +7,12 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/lib/protobuf/guipb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newAdd(n *tree.Node) {
|
func Add(n *tree.Node) {
|
||||||
log.Log(INFO, "Add() END =", n.WidgetType, n.String())
|
log.Log(INFO, "Add() END =", n.WidgetType, n.String())
|
||||||
if n == nil {
|
if n == nil {
|
||||||
log.Warn("Tree Error: Add() sent n == nil")
|
log.Warn("Tree Error: Add() sent n == nil")
|
||||||
|
@ -59,7 +58,7 @@ func newaction(n *tree.Node, atype widget.ActionType) {
|
||||||
// w.disableColor()
|
// w.disableColor()
|
||||||
case widget.Delete:
|
case widget.Delete:
|
||||||
log.Info("newaction() DeleteNode()")
|
log.Info("newaction() DeleteNode()")
|
||||||
// n.DeleteNode()
|
n.DeleteNode()
|
||||||
case widget.ToolkitClose:
|
case widget.ToolkitClose:
|
||||||
log.Info("newaction() toolkit closed. are the channels cleand up?")
|
log.Info("newaction() toolkit closed. are the channels cleand up?")
|
||||||
return
|
return
|
||||||
|
@ -69,15 +68,15 @@ func newaction(n *tree.Node, atype widget.ActionType) {
|
||||||
log.Log(INFO, "newaction() END", atype, n.String())
|
log.Log(INFO, "newaction() END", atype, n.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTitle(n *tree.Node, s string) {
|
func SetTitle(n *tree.Node, s string) {
|
||||||
setText(n, s)
|
SetText(n, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setLabel(n *tree.Node, s string) {
|
func SetLabel(n *tree.Node, s string) {
|
||||||
setText(n, s)
|
SetText(n, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setText(n *tree.Node, s string) {
|
func SetText(n *tree.Node, s string) {
|
||||||
if n == nil {
|
if n == nil {
|
||||||
log.Warn("Tree Error: Add() sent n == nil")
|
log.Warn("Tree Error: Add() sent n == nil")
|
||||||
return
|
return
|
||||||
|
@ -91,7 +90,7 @@ func setText(n *tree.Node, s string) {
|
||||||
log.Info("SetText()", n.WidgetType, n.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 {
|
if n == nil {
|
||||||
log.Warn("Tree Error: Add() sent n == nil")
|
log.Warn("Tree Error: Add() sent n == nil")
|
||||||
return
|
return
|
||||||
|
@ -104,23 +103,3 @@ func addText(n *tree.Node, s string) {
|
||||||
// w := n.TK.(*guiWidget)
|
// w := n.TK.(*guiWidget)
|
||||||
// w.AddText(s)
|
// 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")
|
|
||||||
}
|
|
||||||
|
|
30
args.go
30
args.go
|
@ -28,33 +28,3 @@ func init() {
|
||||||
|
|
||||||
ERROR = log.NewFlag("ERROR", true, full, short, "toolkit errors")
|
ERROR = log.NewFlag("ERROR", true, full, short, "toolkit errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
var argv args
|
|
||||||
|
|
||||||
type args struct {
|
|
||||||
Width float64 `arg:"--width" default:"640" help:"window width"`
|
|
||||||
Height float64 `arg:"--height" default:"480" help:"window height"`
|
|
||||||
Filename string `arg:"--filename" help:"what .glsl file to render"`
|
|
||||||
DryRun bool `arg:"--dry-run" help:"show what would be run"`
|
|
||||||
GLdrift float32 `arg:"--drift" default:"0.01" help:"how fast things move around"`
|
|
||||||
// Fetch bool `arg:"--git-fetch" default:"false" help:"run 'git fetch' on all your repos"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (args) Version() string {
|
|
||||||
return "go-clone " + VERSION + " Built on " + BUILDTIME
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a args) Description() string {
|
|
||||||
return `
|
|
||||||
git clone go repositories
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
go-clone go.wit.com/apps/go-clone # simply try to git clone this
|
|
||||||
go-clone --recursive go.wit.com/apps/go-clone # recursively clone all the dependancies
|
|
||||||
go-clone --auto-work go.wit.com/apps/go-clone # if you are using a go.work file, recreate the go.work file
|
|
||||||
go-clone --go-reset # recreate every go.mod and go.sum file
|
|
||||||
go-clone --git-pull # run 'git pull' in every repo
|
|
||||||
go-clone --build # build every binary package
|
|
||||||
go-clone --install # install every binary package
|
|
||||||
`
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
This simply parses the command line arguments using the default golang
|
||||||
|
package called 'flag'. This can be used as a simple template to parse
|
||||||
|
command line arguments in other programs.
|
||||||
|
|
||||||
|
It puts everything in the 'config' package which I think is a good
|
||||||
|
wrapper around the 'flags' package and doesn't need a whole mess of
|
||||||
|
global variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/gookit/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
var customUsage = func() {
|
||||||
|
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
|
||||||
|
flag.PrintDefaults()
|
||||||
|
|
||||||
|
fmt.Println("")
|
||||||
|
fmt.Println("EXAMPLES:")
|
||||||
|
fmt.Println("")
|
||||||
|
fmt.Println(os.Args[0] + " --width 1024 --height 768 --drift .1 --filename seascape.glsl")
|
||||||
|
fmt.Println(os.Args[0] + " --width 640 --height 480 --filename planetfall.glsl")
|
||||||
|
fmt.Println("")
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseFlags() {
|
||||||
|
var version string
|
||||||
|
var race bool
|
||||||
|
var filename string
|
||||||
|
var width int
|
||||||
|
var height int
|
||||||
|
var glDrift float64
|
||||||
|
var guiJunk string
|
||||||
|
|
||||||
|
flag.StringVar(&version, "version", "v0.1", "Set compiled in version string")
|
||||||
|
|
||||||
|
flag.StringVar(&filename, "filename", "seascape.glsl", "path to GLSL file")
|
||||||
|
flag.StringVar(&guiJunk, "gui", "something", "redo all this code")
|
||||||
|
flag.IntVar(&width, "width", 1024, "Width of the OpenGL Window")
|
||||||
|
flag.IntVar(&height, "height", 768, "Height of the OpenGL Window")
|
||||||
|
|
||||||
|
flag.Float64Var(&glDrift, "drift", 0.01, "Speed of the gradual camera drift")
|
||||||
|
flag.BoolVar(&race, "race", race, "Use race detector")
|
||||||
|
|
||||||
|
// Set the output if something fails to stdout rather than stderr
|
||||||
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
|
|
||||||
|
flag.Usage = customUsage
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if flag.Parsed() {
|
||||||
|
log.Println("flag.Parse() worked")
|
||||||
|
} else {
|
||||||
|
log.Println("flag.Parse() failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// keys := []string{"filename", "width", "height", "drift"}
|
||||||
|
// keys := []string{"width", "height", "drift"}
|
||||||
|
|
||||||
|
// keys := []string{"height"}
|
||||||
|
// config.LoadFlags(keys)
|
||||||
|
|
||||||
|
config.Set("width", width)
|
||||||
|
config.Set("height", height)
|
||||||
|
config.Set("glDrift", glDrift)
|
||||||
|
config.Set("filename", filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseConfig() {
|
||||||
|
config.WithOptions(config.ParseEnv)
|
||||||
|
parseFlags()
|
||||||
|
|
||||||
|
// config.LoadOSEnv([]string{"MAIL"})
|
||||||
|
// config.LoadOSEnv([]string{"USER"})
|
||||||
|
// config.LoadOSEnv([]string{"BUILDDEBUG"})
|
||||||
|
}
|
71
main.go
71
main.go
|
@ -9,37 +9,21 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"io/fs"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"github.com/faiface/pixel/pixelgl"
|
"github.com/faiface/pixel/pixelgl"
|
||||||
// "github.com/gookit/config"
|
"github.com/gookit/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sent via -ldflags
|
//go:embed *.glsl
|
||||||
var VERSION string
|
var glFile embed.FS
|
||||||
var BUILDTIME string
|
|
||||||
|
|
||||||
var PLUGIN string = "pixelgl"
|
|
||||||
|
|
||||||
//go:embed resources/*
|
|
||||||
var resources embed.FS
|
|
||||||
|
|
||||||
var pp *arg.Parser
|
|
||||||
|
|
||||||
// the glsl file
|
|
||||||
var glslFile string
|
|
||||||
|
|
||||||
func initPlugin() {
|
|
||||||
pp = arg.MustParse(&argv)
|
|
||||||
|
|
||||||
|
func init() {
|
||||||
log.Log(INFO, "Init()")
|
log.Log(INFO, "Init()")
|
||||||
|
|
||||||
me.myTree = initTree()
|
me.myTree = tree.New()
|
||||||
/*
|
|
||||||
me.myTree.PluginName = "nocui"
|
me.myTree.PluginName = "nocui"
|
||||||
// me.myTree.ActionFromChannel = doAction
|
// me.myTree.ActionFromChannel = doAction
|
||||||
|
|
||||||
|
@ -49,7 +33,6 @@ func initPlugin() {
|
||||||
me.myTree.SetLabel = SetLabel
|
me.myTree.SetLabel = SetLabel
|
||||||
me.myTree.SetText = SetText
|
me.myTree.SetText = SetText
|
||||||
me.myTree.AddText = AddText
|
me.myTree.AddText = AddText
|
||||||
*/
|
|
||||||
|
|
||||||
me.exit = false
|
me.exit = false
|
||||||
|
|
||||||
|
@ -59,7 +42,12 @@ func initPlugin() {
|
||||||
|
|
||||||
go simpleStdin()
|
go simpleStdin()
|
||||||
|
|
||||||
glslFile = loadGLSL(argv.Filename)
|
config.Set("width", 640)
|
||||||
|
config.Set("height", 480)
|
||||||
|
config.Set("glDrift", 0.01)
|
||||||
|
// config.Set("filename", "planetfall.glsl")
|
||||||
|
config.Set("filename", "seascape.glsl")
|
||||||
|
|
||||||
// I think this doesn't work as a goroutine because
|
// I think this doesn't work as a goroutine because
|
||||||
// opengl closes. This plugin probably has to wait
|
// opengl closes. This plugin probably has to wait
|
||||||
// until there is some sort of protobuf + socket interface
|
// until there is some sort of protobuf + socket interface
|
||||||
|
@ -72,38 +60,11 @@ func initPlugin() {
|
||||||
// I assume it's for testing the code in a stand alone way
|
// I assume it's for testing the code in a stand alone way
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
config.Set("width", 1024)
|
||||||
|
config.Set("height", 768)
|
||||||
|
config.Set("glDrift", 0.01)
|
||||||
|
config.Set("filename", "planetfall.glsl")
|
||||||
// This parses the command line arguments
|
// This parses the command line arguments
|
||||||
// parseConfig()
|
// parseConfig()
|
||||||
pixelgl.Run(run)
|
pixelgl.Run(run)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFileToString loads the contents of a file into a string
|
|
||||||
func loadGLSL(filename string) string {
|
|
||||||
var err error
|
|
||||||
var data []byte
|
|
||||||
|
|
||||||
//
|
|
||||||
data, err = os.ReadFile(filename)
|
|
||||||
if err == nil {
|
|
||||||
log.Println("found embedded file:", filename)
|
|
||||||
return string(data)
|
|
||||||
}
|
|
||||||
data, err = fs.ReadFile(resources, filename)
|
|
||||||
if len(data) == 0 {
|
|
||||||
log.Info("still could not find file", filename, err)
|
|
||||||
} else {
|
|
||||||
return string(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = "resources/seascape.glsl"
|
|
||||||
log.Println("did not find embedded file:", filename, err)
|
|
||||||
data, err = fs.ReadFile(resources, filename)
|
|
||||||
if len(data) == 0 {
|
|
||||||
log.Info("still could not find file", filename)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a string of the data to feed into
|
|
||||||
// canvas.SetFragmentShader(file)
|
|
||||||
return string(data)
|
|
||||||
}
|
|
||||||
|
|
21
psutil.go
21
psutil.go
|
@ -1,8 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/fs"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/faiface/pixel"
|
"github.com/faiface/pixel"
|
||||||
"github.com/faiface/pixel/pixelgl"
|
"github.com/faiface/pixel/pixelgl"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pixel Shader utility functions
|
// Pixel Shader utility functions
|
||||||
|
@ -40,3 +44,20 @@ func CenterWindow(win *pixelgl.Window) {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadFileToString loads the contents of a file into a string
|
||||||
|
func LoadFileToString(filename string) (string, error) {
|
||||||
|
embedf, err1 := fs.ReadFile(glFile, filename)
|
||||||
|
if err1 == nil {
|
||||||
|
log.Println("found embedded file:", filename)
|
||||||
|
return string(embedf), nil
|
||||||
|
} else {
|
||||||
|
log.Println("did not find embedded file:", filename)
|
||||||
|
log.Println("err", err1)
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadFile("/tmp/" + filename)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(b), nil
|
||||||
|
}
|
||||||
|
|
19
seascape.go
19
seascape.go
|
@ -5,17 +5,20 @@ import (
|
||||||
|
|
||||||
"github.com/go-gl/mathgl/mgl32"
|
"github.com/go-gl/mathgl/mgl32"
|
||||||
|
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/faiface/pixel"
|
"github.com/faiface/pixel"
|
||||||
"github.com/faiface/pixel/pixelgl"
|
"github.com/faiface/pixel/pixelgl"
|
||||||
|
"github.com/gookit/config"
|
||||||
"golang.org/x/image/colornames"
|
"golang.org/x/image/colornames"
|
||||||
)
|
)
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
// Set up window configs
|
// Set up window configs
|
||||||
|
log.Println("width = ", config.Int("width"), "height = ", config.String("height"))
|
||||||
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
|
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
|
||||||
Title: "Golang GLSL",
|
Title: "Golang GLSL",
|
||||||
// Bounds: pixel.R(0, 0, float64(width), float64(height)),
|
Bounds: pixel.R(0, 0, config.Float("width"), config.Float("height")),
|
||||||
Bounds: pixel.R(0, 0, argv.Width, argv.Height),
|
|
||||||
VSync: true,
|
VSync: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +35,17 @@ func run() {
|
||||||
// I am putting all shader example initializing stuff here for
|
// I am putting all shader example initializing stuff here for
|
||||||
// easier reference to those learning to use this functionality
|
// easier reference to those learning to use this functionality
|
||||||
|
|
||||||
|
log.Println("Load GSGL file = ", config.String("filename"))
|
||||||
|
fragSource, err := LoadFileToString(config.String("filename"))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
var uMouse mgl32.Vec4
|
var uMouse mgl32.Vec4
|
||||||
var uTime float32
|
var uTime float32
|
||||||
var glDrift float32 = argv.GLdrift
|
log.Println("glDrift = ", config.String("glDrift"))
|
||||||
|
var glDrift float32 = float32(config.Float("glDrift"))
|
||||||
|
|
||||||
canvas := win.Canvas()
|
canvas := win.Canvas()
|
||||||
uResolution := mgl32.Vec2{float32(win.Bounds().W()), float32(win.Bounds().H())}
|
uResolution := mgl32.Vec2{float32(win.Bounds().W()), float32(win.Bounds().H())}
|
||||||
|
@ -46,7 +57,7 @@ func run() {
|
||||||
"uDrift", &glDrift,
|
"uDrift", &glDrift,
|
||||||
)
|
)
|
||||||
|
|
||||||
canvas.SetFragmentShader(glslFile)
|
canvas.SetFragmentShader(fragSource)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
|
|
||||||
"go.wit.com/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,8 +13,8 @@ type guiWidget struct {
|
||||||
val map[string]int
|
val map[string]int
|
||||||
}
|
}
|
||||||
|
|
||||||
var initOnce sync.Once // run initPlugin() only once
|
// It's probably a terrible idea to call this 'me'
|
||||||
var me toolkitConfig // It's probably a terrible idea to call this 'me'
|
var me toolkitConfig
|
||||||
|
|
||||||
type toolkitConfig struct {
|
type toolkitConfig struct {
|
||||||
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
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()
|
||||||
|
}
|
72
treeInit.go
72
treeInit.go
|
@ -1,72 +0,0 @@
|
||||||
// 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