fyne changes to see if it can work
This commit is contained in:
parent
dcd32c255c
commit
f65d80862e
4
Makefile
4
Makefile
|
@ -26,6 +26,10 @@ non-plugin:
|
|||
go build -v -x
|
||||
./fyne
|
||||
|
||||
GO111-non-plugin:
|
||||
GO111MODULE=off go build -v -x
|
||||
./fyne
|
||||
|
||||
check-git-clean:
|
||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||
|
||||
|
|
15
README.md
15
README.md
|
@ -1,5 +1,18 @@
|
|||
# nogui
|
||||
# fyne
|
||||
|
||||
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.
|
||||
|
||||
fyne appears to require:
|
||||
runtime.LockOSThread() // Ensure main stays on one OS thread
|
||||
a := app.New()
|
||||
w := a.NewWindow("Fyne Plugin Fix")
|
||||
w.ShowAndRun()
|
||||
|
||||
error:
|
||||
gui doing TestDraw() Forge: (this kinda works sometimes)
|
||||
panic: Run() or ShowAndRun() must be called from main goroutine
|
||||
|
||||
so for fyne to work, there must be a protocol buffer GO GUI plugin first that
|
||||
can spawn and talk to fyne
|
||||
|
|
58
action.go
58
action.go
|
@ -7,6 +7,8 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"go.wit.com/lib/protobuf/guipb"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
|
@ -105,22 +107,54 @@ func addText(n *tree.Node, s string) {
|
|||
// 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")
|
||||
}
|
||||
|
||||
func showTable(t *guipb.Table) {
|
||||
log.Info("gocui: should show table here")
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
log.Info("gocui: table.Title", t.Title)
|
||||
}
|
||||
|
||||
func enableWidget(n *tree.Node) {
|
||||
tk := n.TK.(*guiWidget)
|
||||
tk.Enable()
|
||||
}
|
||||
|
||||
func disableWidget(n *tree.Node) {
|
||||
tk := n.TK.(*guiWidget)
|
||||
tk.Disable()
|
||||
}
|
||||
|
||||
func showWidget(n *tree.Node) {
|
||||
tk := n.TK.(*guiWidget)
|
||||
tk.Show()
|
||||
}
|
||||
|
||||
func hideWidget(n *tree.Node) {
|
||||
tk := n.TK.(*guiWidget)
|
||||
if n.WidgetType == widget.Window {
|
||||
// tk.windowFrame.Hide()
|
||||
// tk.hideWidgets()
|
||||
}
|
||||
tk.Hide()
|
||||
tk.deleteWidget()
|
||||
}
|
||||
|
||||
func (tk *guiWidget) deleteWidget() {
|
||||
log.Info("gocui deleteWidget() looking for child to delete:", tk.cuiName)
|
||||
p := tk.parent
|
||||
for i, child := range p.children {
|
||||
if tk == child {
|
||||
log.Info("deleteWidget() found parent with child to delete:", i, child.cuiName)
|
||||
p.children = slices.Delete(p.children, i, i+1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
4
args.go
4
args.go
|
@ -17,8 +17,8 @@ var WARN *log.LogFlag
|
|||
var ERROR *log.LogFlag
|
||||
|
||||
func init() {
|
||||
full := "toolkit/nocui"
|
||||
short := "nocui"
|
||||
full := "toolkit/fyne"
|
||||
short := "fyne"
|
||||
|
||||
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
|
||||
INFO = log.NewFlag("INFO", true, full, short, "normal debugging stuff")
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var a fyne.App
|
||||
|
@ -16,6 +17,7 @@ var w fyne.Window
|
|||
var w2 fyne.Window
|
||||
|
||||
func fynetest() {
|
||||
log.Info("FYNE TEST START")
|
||||
a = app.New()
|
||||
w = a.NewWindow("Hello")
|
||||
|
||||
|
@ -28,6 +30,7 @@ func fynetest() {
|
|||
}),
|
||||
))
|
||||
|
||||
log.Info("FYNE TEST SHOW")
|
||||
w.Show()
|
||||
|
||||
// bobWindow()
|
||||
|
|
54
main.go
54
main.go
|
@ -8,34 +8,36 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"fyne.io/fyne/v2/app"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var PLUGIN string = "fyne"
|
||||
|
||||
func blah() {
|
||||
fynetest()
|
||||
a.Run()
|
||||
}
|
||||
|
||||
func initPlugin() {
|
||||
log.Log(INFO, "Init()")
|
||||
|
||||
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.exit = false
|
||||
|
||||
log.Log(INFO, "Init() END")
|
||||
|
||||
showOptions()
|
||||
|
||||
go simpleStdin()
|
||||
log.Log(INFO, "Init() FYNE END")
|
||||
// blah()
|
||||
|
||||
me.myTree.InitOK()
|
||||
}
|
||||
|
||||
func init() {
|
||||
// fynetest()
|
||||
// a.Run()
|
||||
}
|
||||
|
||||
// this must be defined for plugin's, but is never run
|
||||
|
@ -44,3 +46,25 @@ func main() {
|
|||
fynetest()
|
||||
a.Run()
|
||||
}
|
||||
|
||||
// this is called at the very initial connection
|
||||
// between the app and this gocui plugin
|
||||
// this is a good place to initialize gocui's default behavior
|
||||
func toolkitInit() {
|
||||
log.Log(INFO, "TOOLKIT Init()")
|
||||
|
||||
me.exit = false
|
||||
showOptions()
|
||||
log.Log(INFO, "TOOLKIT Init() END")
|
||||
|
||||
fynetest()
|
||||
go a.Run()
|
||||
}
|
||||
|
||||
func testmain() {
|
||||
runtime.LockOSThread() // Ensure main stays on one OS thread
|
||||
a := app.New()
|
||||
w := a.NewWindow("Fyne Plugin Fix")
|
||||
w.ShowAndRun()
|
||||
// use w.QueueUpdate() to talk to fyne (?)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (tk *guiWidget) WidgetType() widget.WidgetType {
|
||||
if tk.node == nil {
|
||||
return widget.Label
|
||||
}
|
||||
return tk.node.WidgetType
|
||||
}
|
||||
|
||||
func (tk *guiWidget) WidgetId() int {
|
||||
return tk.node.WidgetId
|
||||
}
|
||||
|
||||
func (tk *guiWidget) GetLabel() string {
|
||||
return tk.node.GetLabel()
|
||||
}
|
||||
|
||||
func (tk *guiWidget) IsEnabled() bool {
|
||||
return tk.node.IsEnabled()
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Checked() bool {
|
||||
return tk.node.State.Checked
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Hidden() bool {
|
||||
if tk.node == nil {
|
||||
return false
|
||||
}
|
||||
if tk.parent == nil {
|
||||
return tk.node.Hidden()
|
||||
}
|
||||
if tk.parent.WidgetId() == 0 {
|
||||
return tk.node.Hidden()
|
||||
}
|
||||
if tk.parent.Hidden() {
|
||||
return true
|
||||
}
|
||||
return tk.node.Hidden()
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Direction() widget.Orientation {
|
||||
return tk.node.State.Direction
|
||||
}
|
||||
|
||||
func (tk *guiWidget) GridW() int {
|
||||
return tk.node.State.AtW
|
||||
}
|
||||
|
||||
func (tk *guiWidget) GridH() int {
|
||||
return tk.node.State.AtH
|
||||
}
|
||||
|
||||
func (tk *guiWidget) SetChecked(b bool) {
|
||||
tk.node.State.Checked = b
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (tk *guiWidget) Show() {
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Hide() {
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Disable() {
|
||||
if tk == nil {
|
||||
log.Info("widget is nil")
|
||||
return
|
||||
}
|
||||
|
||||
switch tk.WidgetType() {
|
||||
case widget.Box:
|
||||
return
|
||||
case widget.Button:
|
||||
return
|
||||
default:
|
||||
log.Log(NOW, "fixme")
|
||||
}
|
||||
}
|
||||
|
||||
func (tk *guiWidget) Enable() {
|
||||
if tk == nil {
|
||||
log.Info("widget is nil")
|
||||
return
|
||||
}
|
||||
|
||||
switch tk.WidgetType() {
|
||||
case widget.Box:
|
||||
// hideDisable()
|
||||
return
|
||||
case widget.Button:
|
||||
// tk.restoreEnableColor()
|
||||
return
|
||||
default:
|
||||
log.Log(NOW, "fixme")
|
||||
}
|
||||
}
|
2
stdin.go
2
stdin.go
|
@ -33,7 +33,7 @@ func showOptions() {
|
|||
func simpleStdin() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Warn("nocui YAHOOOO Recovered in simpleStdin()", r)
|
||||
log.Warn("fyne YAHOOOO Recovered in simpleStdin()", r)
|
||||
log.Println("Recovered from panic:", r)
|
||||
log.Println("Stack trace:")
|
||||
debug.PrintStack()
|
||||
|
|
|
@ -8,6 +8,10 @@ import (
|
|||
|
||||
// stores the raw toolkit internals
|
||||
type guiWidget struct {
|
||||
parent *guiWidget
|
||||
children []*guiWidget
|
||||
node *tree.Node // the pointer back to the tree
|
||||
cuiName string
|
||||
Width int
|
||||
Height int
|
||||
|
||||
|
|
18
treeInit.go
18
treeInit.go
|
@ -32,6 +32,9 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
@ -49,9 +52,20 @@ func Callback(guiCallback chan widget.Action) {
|
|||
|
||||
func PluginChannel() chan widget.Action {
|
||||
initOnce.Do(initPlugin)
|
||||
for {
|
||||
if me.myTree != nil {
|
||||
break
|
||||
}
|
||||
log.Info("me.myTree == nil")
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
}
|
||||
return me.myTree.PluginChannel()
|
||||
}
|
||||
|
||||
func FrozenChannel() chan widget.Action {
|
||||
return me.myTree.FrozenChannel()
|
||||
}
|
||||
|
||||
func initTree() *tree.TreeInfo {
|
||||
t := tree.New()
|
||||
t.PluginName = PLUGIN
|
||||
|
@ -64,7 +78,11 @@ func initTree() *tree.TreeInfo {
|
|||
t.Enable = enableWidget
|
||||
t.Disable = disableWidget
|
||||
|
||||
t.Show = showWidget
|
||||
t.Hide = hideWidget
|
||||
|
||||
t.SetChecked = setChecked
|
||||
t.ToolkitInit = toolkitInit
|
||||
t.ToolkitClose = toolkitClose
|
||||
t.ShowTable = showTable
|
||||
|
||||
|
|
Loading…
Reference in New Issue