2021-10-06 08:36:28 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
import (
|
|
|
|
"log"
|
2022-11-06 12:59:24 -06:00
|
|
|
"os"
|
2021-10-06 10:43:58 -05:00
|
|
|
)
|
2021-10-06 08:36:28 -05:00
|
|
|
|
2022-10-20 06:55:42 -05:00
|
|
|
import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
|
|
|
|
|
2022-11-06 12:59:24 -06:00
|
|
|
const Xaxis = 0 // stack things horizontally
|
|
|
|
const Yaxis = 1 // stack things vertically
|
2022-10-20 06:55:42 -05:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
log.Println("gui.init() has been run")
|
|
|
|
|
|
|
|
Config.counter = 0
|
|
|
|
Config.prefix = "wit"
|
|
|
|
|
2022-11-06 12:59:24 -06:00
|
|
|
// Config.Options.Debug = true
|
|
|
|
// Config.Options.DebugNode = true
|
|
|
|
// Config.Options.DebugTabs = true
|
|
|
|
|
|
|
|
title := "guiBinaryTree"
|
2022-10-20 06:55:42 -05:00
|
|
|
w := 640
|
|
|
|
h := 480
|
|
|
|
|
2022-11-06 12:59:24 -06:00
|
|
|
// Populates the top of the binary tree
|
2022-10-20 06:55:42 -05:00
|
|
|
Config.master = addNode(title, w, h)
|
2022-11-06 12:59:24 -06:00
|
|
|
if (Config.Options.Debug) {
|
|
|
|
Config.master.Dump()
|
|
|
|
}
|
2022-11-06 19:57:20 -06:00
|
|
|
|
2022-11-09 08:38:50 -06:00
|
|
|
// load the gocui plugin
|
|
|
|
PlugGocli = LoadPlugin("../../toolkit/gocui.so")
|
|
|
|
PlugGocliOk = false
|
2022-10-20 06:55:42 -05:00
|
|
|
}
|
|
|
|
|
2021-10-06 08:36:28 -05:00
|
|
|
func Main(f func()) {
|
2022-11-06 19:57:20 -06:00
|
|
|
if (Config.Options.Debug) {
|
|
|
|
log.Println("Starting gui.Main() (using gtk via andlabs/ui)")
|
|
|
|
}
|
2022-10-20 06:55:42 -05:00
|
|
|
toolkit.Main(f)
|
2021-10-06 08:36:28 -05:00
|
|
|
}
|
|
|
|
|
2021-10-31 14:21:36 -05:00
|
|
|
// Other goroutines must use this to access the GUI
|
2021-10-06 08:36:28 -05:00
|
|
|
//
|
|
|
|
// You can not acess / process the GUI thread directly from
|
2021-10-06 10:43:58 -05:00
|
|
|
// other goroutines. This is due to the nature of how
|
2021-10-06 08:36:28 -05:00
|
|
|
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
|
2022-10-20 06:55:42 -05:00
|
|
|
// For example: gui.Queue(NewWindow())
|
2021-10-06 08:36:28 -05:00
|
|
|
func Queue(f func()) {
|
|
|
|
log.Println("Sending function to gui.Main() (using gtk via andlabs/ui)")
|
2022-10-20 06:55:42 -05:00
|
|
|
toolkit.Queue(f)
|
2021-10-06 08:36:28 -05:00
|
|
|
}
|
2022-11-06 12:59:24 -06:00
|
|
|
|
|
|
|
// The window is destroyed but the application does not quit
|
|
|
|
func StandardClose(n *Node) {
|
|
|
|
if (Config.Options.Debug) {
|
|
|
|
log.Println("wit/gui Standard Window Close. name =", n.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The window is destroyed but the application does not quit
|
|
|
|
func StandardExit(n *Node) {
|
|
|
|
if (Config.Options.Debug) {
|
|
|
|
log.Println("wit/gui Standard Window Exit. running os.Exit()")
|
|
|
|
}
|
|
|
|
os.Exit(0)
|
|
|
|
}
|