more code cleanups
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
28280403bf
commit
77f7d1f0ca
|
@ -16,7 +16,7 @@ var buttonCounter int = 5
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// This will turn on all debugging
|
// This will turn on all debugging
|
||||||
gui.SetDebug(true)
|
// gui.SetDebug(true)
|
||||||
|
|
||||||
// myGui = gui.New().LoadToolkit("gocui")
|
// myGui = gui.New().LoadToolkit("gocui")
|
||||||
myGui = gui.New().LoadToolkit("andlabs")
|
myGui = gui.New().LoadToolkit("andlabs")
|
||||||
|
|
18
node.go
18
node.go
|
@ -12,24 +12,6 @@ func (n *Node) newNode(title string, t toolkit.WidgetType, custom func()) *Node
|
||||||
newN.WidgetType = t
|
newN.WidgetType = t
|
||||||
newN.Custom = custom
|
newN.Custom = custom
|
||||||
|
|
||||||
// TODO: This should not be defined for each widget. This has to be stupid
|
|
||||||
// or wait a second, is this where I send something to a channel?
|
|
||||||
newN.Custom = func() {
|
|
||||||
log(debugChange, "Trying to find Window Close. widgetType =", newN.WidgetType)
|
|
||||||
if (newN.WidgetType == toolkit.Window) {
|
|
||||||
log(debugChange, "Need to delete newN here")
|
|
||||||
n.Delete(newN)
|
|
||||||
}
|
|
||||||
if (newN.Custom == nil) {
|
|
||||||
log(debugChange, "newT.Custom() == nil. Not doing anything. SEND SOMETHING TO THE CHANNEL")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log(debugChange, "newT.Custom() START SEND SOMETHING TO THE CHANNEL node =", newN.Name)
|
|
||||||
// send something to the channel here????
|
|
||||||
newN.Custom()
|
|
||||||
log(debugChange, "newT.Custom() END SEND SOMETHING TO THE CHANNEL node =", newN.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
n.Append(newN)
|
n.Append(newN)
|
||||||
newN.parent = n
|
newN.parent = n
|
||||||
return newN
|
return newN
|
||||||
|
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"embed"
|
|
||||||
"git.wit.org/wit/gui/toolkit"
|
"git.wit.org/wit/gui/toolkit"
|
||||||
|
|
||||||
"github.com/andlabs/ui"
|
"github.com/andlabs/ui"
|
||||||
|
@ -10,9 +9,6 @@ import (
|
||||||
_ "github.com/andlabs/ui/winmanifest"
|
_ "github.com/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed resources
|
|
||||||
var res embed.FS
|
|
||||||
|
|
||||||
// this is the channel we get requests to make widgets
|
// this is the channel we get requests to make widgets
|
||||||
var pluginChan chan toolkit.Action
|
var pluginChan chan toolkit.Action
|
||||||
|
|
||||||
|
@ -27,32 +23,10 @@ func catchActionChannel() {
|
||||||
select {
|
select {
|
||||||
case a := <-pluginChan:
|
case a := <-pluginChan:
|
||||||
log(logNow, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name)
|
log(logNow, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name)
|
||||||
/*
|
|
||||||
// go Action(a)
|
|
||||||
if (uiMainUndef) {
|
|
||||||
log(logError,"catchActionChannel() main() was not run yet")
|
|
||||||
log(logError,"catchActionChannel() main() was not run yet")
|
|
||||||
log(logError,"catchActionChannel() main() was not run yet")
|
|
||||||
log(logError,"catchActionChannel() ui.Main() START")
|
|
||||||
log(logError,"catchActionChannel() ui.Main() START")
|
|
||||||
log(logError,"catchActionChannel() ui.Main() START")
|
|
||||||
log(logError,"catchActionChannel() ui.Main() START")
|
|
||||||
sleep(1)
|
|
||||||
// go ui.Main(demoUI)
|
|
||||||
// go ui.Main( func() {
|
|
||||||
// rawAction(a)
|
|
||||||
// })
|
|
||||||
// probably not needed, but in here for now under development
|
|
||||||
uiMainUndef = false
|
|
||||||
sleep(1)
|
|
||||||
} else {
|
|
||||||
log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
|
||||||
rawAction(a)
|
|
||||||
log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
||||||
muAction.Lock()
|
muAction.Lock()
|
||||||
|
// TODO ui.QueueMain(f)
|
||||||
|
// TODO ui.QueueMain( func() {rawAction(a)} )
|
||||||
rawAction(a)
|
rawAction(a)
|
||||||
muAction.Unlock()
|
muAction.Unlock()
|
||||||
log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
||||||
|
@ -60,13 +34,12 @@ func catchActionChannel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Other goroutines must use this to access the GUI
|
||||||
func main(f func()) {
|
//
|
||||||
log(debugNow, "Main() START (using gtk via andlabs/ui)")
|
// You can not acess / process the GUI thread directly from
|
||||||
f() // support the old way. deprecate this
|
// 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
|
// this sets the channel to send user events back from the plugin
|
||||||
func Callback(guiCallback chan toolkit.Action) {
|
func Callback(guiCallback chan toolkit.Action) {
|
||||||
callback = guiCallback
|
callback = guiCallback
|
||||||
|
@ -76,21 +49,6 @@ func PluginChannel() chan toolkit.Action {
|
||||||
return pluginChan
|
return pluginChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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.)
|
|
||||||
//
|
|
||||||
// For example: Queue(NewWindow())
|
|
||||||
//
|
|
||||||
func queue(f func()) {
|
|
||||||
log(logNow, "Sending function to ui.QueueMain()")
|
|
||||||
log(logNow, "using gui.Queue() in this plugin DOES BREAK. TODO: solve this with channels")
|
|
||||||
ui.QueueMain(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
|
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
|
||||||
func init() {
|
func init() {
|
||||||
log(logNow, "Init() START")
|
log(logNow, "Init() START")
|
||||||
|
@ -107,17 +65,5 @@ func init() {
|
||||||
demoUI()
|
demoUI()
|
||||||
})
|
})
|
||||||
go catchActionChannel()
|
go catchActionChannel()
|
||||||
/*
|
|
||||||
// go catchActionChannel()
|
|
||||||
go uiMain.Do(func() {
|
|
||||||
ui.Main(demoUI)
|
|
||||||
// go catchActionChannel()
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
log(logNow, "Init() END")
|
log(logNow, "Init() END")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: properly exit the plugin since Quit() doesn't do it
|
|
||||||
func Quit() {
|
|
||||||
log(debugToolkit, "Quit() TODO: close the toolkit cleanly")
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 9.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
// sets defaults and establishes communication
|
// sets defaults and establishes communication
|
||||||
// to this toolkit from the wit/gui golang package
|
// to this toolkit from the wit/gui golang package
|
||||||
func Init() {
|
func init() {
|
||||||
log(logInfo, "Init() of awesome-gocui")
|
log(logInfo, "Init() of awesome-gocui")
|
||||||
me.defaultWidth = 10
|
me.defaultWidth = 10
|
||||||
me.defaultHeight = 2 // this means by default one line of text in a button
|
me.defaultHeight = 2 // this means by default one line of text in a button
|
||||||
|
|
Loading…
Reference in New Issue