GROUP: implement 'group' in toolkit/
move gui.group into toolkit remove duplicate code update demo
This commit is contained in:
parent
25a6d6a346
commit
e823dd78de
|
@ -1,4 +1,3 @@
|
|||
*.swp
|
||||
cmds/gui-example/gui-example
|
||||
cmds/gui-demo/gui-demo
|
||||
cmds/helloworld/helloworld
|
||||
|
|
7
Makefile
7
Makefile
|
@ -9,9 +9,12 @@ update:
|
|||
git pull
|
||||
go get -v -t -u ./...
|
||||
|
||||
examples:
|
||||
examples: examples-gui-demo examples-helloworld
|
||||
|
||||
examples-helloworld:
|
||||
make -C cmds/helloworld
|
||||
make -C cmds/gui-example
|
||||
|
||||
examples-gui-demo:
|
||||
make -C cmds/gui-demo
|
||||
|
||||
doc:
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
|
||||
import "git.wit.org/wit/gui"
|
||||
|
||||
func demoClick (n *gui.Node) {
|
||||
log.Println("demoClick() Dumping node:")
|
||||
n.Dump()
|
||||
}
|
||||
|
||||
func addDemoTab(n *gui.Node, title string) {
|
||||
newNode := n.AddTab(title, nil)
|
||||
if (gui.Config.Debug) {
|
||||
newNode.Dump()
|
||||
}
|
||||
newNode.ListChildren(false)
|
||||
|
||||
groupNode1 := newNode.AddGroup("group 1")
|
||||
groupNode1.AddComboBox("demoCombo1", "foo", "bar", "stuff")
|
||||
groupNode1.AddComboBox("demoCombo3", "foo 3", "bar", "stuff")
|
||||
|
||||
groupNode1.Dump()
|
||||
|
||||
butNode1 := groupNode1.AddButton("button1", demoClick)
|
||||
butNode1.Dump()
|
||||
|
||||
butNode2 := groupNode1.AddButton("button2", demoClick)
|
||||
butNode2.Dump()
|
||||
|
||||
groupNode2 := newNode.AddGroup("group 2")
|
||||
groupNode2.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
|
||||
}
|
|
@ -22,19 +22,7 @@ func main() {
|
|||
|
||||
// This initializes the first window
|
||||
func initGUI() {
|
||||
gui.Config.Title = "WIT GUI Window Demo 1"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 480
|
||||
gui.Config.Exit = myExit
|
||||
node1 := gui.NewWindow()
|
||||
addDemoTab(node1, "A Simple Tab Demo")
|
||||
|
||||
gui.Config.Title = "WIT GUI Window Demo 2"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 240
|
||||
gui.Config.Exit = myExit
|
||||
node2 := gui.NewWindow()
|
||||
node2.DemoAndlabsUiTab("A Simple andlabs/ui Tab Demo")
|
||||
gui.ToolkitDemoWindow()
|
||||
}
|
||||
|
||||
// This demonstrates how to properly interact with the GUI
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
run: build
|
||||
./gui-example
|
||||
|
||||
build:
|
||||
GO111MODULE="off" go get -v .
|
||||
GO111MODULE="off" go build
|
|
@ -1,105 +0,0 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
import "reflect"
|
||||
|
||||
import "git.wit.org/wit/gui"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func demoClick (n *gui.Node) {
|
||||
log.Println("demoClick() Dumping node:")
|
||||
n.Dump()
|
||||
}
|
||||
|
||||
var username = "jcarr"
|
||||
var hostname = "fire"
|
||||
|
||||
func newClick (n *gui.Node) {
|
||||
var tmp []string
|
||||
junk := "ssh -v " + username + "@" + hostname
|
||||
log.Println("junk = " , junk)
|
||||
xterm(junk)
|
||||
log.Println("tmp = " , reflect.ValueOf(tmp).Kind())
|
||||
// spew.Dump(tmp)
|
||||
}
|
||||
|
||||
func addDemoTab(n *gui.Node, title string) {
|
||||
newNode := n.AddTab(title, nil)
|
||||
if (gui.Config.Debug) {
|
||||
newNode.Dump()
|
||||
}
|
||||
newNode.ListChildren(false)
|
||||
|
||||
groupNode1 := newNode.AddGroup("group 1")
|
||||
cbNode := groupNode1.AddComboBox("username", "root", "jcarr", "hugo")
|
||||
cbNode.OnChanged = func (cbNode *gui.Node) {
|
||||
username = cbNode.GetText()
|
||||
}
|
||||
groupNode1.AddComboBox("demoCombo3", "foo 3", "bar", "stuff")
|
||||
|
||||
groupNode1.Dump()
|
||||
|
||||
butNode1 := groupNode1.AddButton("button1", demoClick)
|
||||
butNode1.Dump()
|
||||
|
||||
butNode2 := groupNode1.AddButton("button2", newClick)
|
||||
butNode2.Dump()
|
||||
|
||||
groupNode2 := newNode.AddGroup("group 2")
|
||||
groupNode2.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
|
||||
|
||||
gNode := newNode.AddGroup("domU")
|
||||
makeSSHbutton(gNode, "hugo@www", "www.wit.org")
|
||||
makeSSHbutton(gNode, "check.lab", "check.lab.wit.org")
|
||||
makeSSHbutton(gNode, "gobuild.lab", "gobuild.lab.wit.org")
|
||||
makeSSHbutton(gNode, "gobuild2.lab", "gobuild2.lab.wit.org")
|
||||
|
||||
/////////////////////////////// Column DNS ////////////////////////////////
|
||||
gNode = newNode.AddGroup("dns")
|
||||
makeSSHbutton(gNode, "bind.wit.org", "bind.wit.org")
|
||||
makeSSHbutton(gNode, "ns1.wit.com", "ns1.wit.com")
|
||||
makeSSHbutton(gNode, "ns2.wit.com", "ns2.wit.com")
|
||||
makeSSHbutton(gNode, "coredns", "coredns.lab.wit.org")
|
||||
|
||||
/////////////////////////////// PHYS 530 //////////////////////////////////
|
||||
gNode = newNode.AddGroup("phys 530")
|
||||
// makeXtermButton(gNode, "openwrt", "SUBDOMAIN", "ssh -4 -v root@openwrt")
|
||||
gNode.AddButton("openwrt", func (*gui.Node) {
|
||||
stuff := "ssh -4 -v root@openwrt"
|
||||
xterm(stuff)
|
||||
})
|
||||
makeSSHbutton (gNode, "mirrors", "mirrors.wit.org")
|
||||
makeSSHbutton (gNode, "node004", "node004.lab.wit.org")
|
||||
makeSSHbutton (gNode, "lenovo-z70", "lenovo-z70.lab.wit.org")
|
||||
|
||||
/////////////////////////////// PHYS 522 //////////////////////////////////
|
||||
gNode = newNode.AddGroup("phys 522")
|
||||
// makeXtermButton(gNode, "openwrt2", "SUBDOMAIN", "ssh -4 -v root@openwrt2")
|
||||
gNode.AddButton("openwrt2", func (*gui.Node) {
|
||||
stuff := "ssh -4 -v root@openwrt2"
|
||||
xterm(stuff)
|
||||
})
|
||||
makeSSHbutton (gNode, "fire.lab", "fire.lab.wit.org")
|
||||
makeSSHbutton (gNode, "predator", "predator.lab.wit.org")
|
||||
|
||||
/////////////////////////////// FLOAT /////////////////////////////////////
|
||||
gNode = newNode.AddGroup("float")
|
||||
makeSSHbutton(gNode, "root@asus-n501vw", "asus-n501vw.lab.wit.org")
|
||||
}
|
||||
|
||||
func makeSSHbutton (n *gui.Node, name string, hostname string) {
|
||||
bNode := n.AddButton(name, func (*gui.Node) {
|
||||
var tmp []string
|
||||
if (username == "") {
|
||||
username = "root"
|
||||
}
|
||||
junk := "ssh -v " + username + "@" + hostname
|
||||
log.Println("junk = " , junk)
|
||||
log.Println("username = '" + username + "'")
|
||||
xterm(junk)
|
||||
log.Println("tmp = " , reflect.ValueOf(tmp).Kind())
|
||||
spew.Dump(tmp)
|
||||
})
|
||||
bNode.Dump()
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.wit.org/wit/gui"
|
||||
)
|
||||
|
||||
// This initializes the first window
|
||||
//
|
||||
// Then starts a goroutine to demonstrate how to
|
||||
// inject things into the GUI
|
||||
func main() {
|
||||
log.Println("Starting my Control Panel")
|
||||
|
||||
go gui.Main(initGUI)
|
||||
|
||||
watchGUI()
|
||||
}
|
||||
|
||||
// This initializes the first window
|
||||
func initGUI() {
|
||||
gui.Config.Title = "WIT GUI Window Demo 1"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 480
|
||||
gui.Config.Exit = myExit
|
||||
node1 := gui.NewWindow()
|
||||
addDemoTab(node1, "A Simple Tab Demo")
|
||||
|
||||
gui.Config.Title = "WIT GUI Window Demo 2"
|
||||
gui.Config.Width = 640
|
||||
gui.Config.Height = 240
|
||||
gui.Config.Exit = myExit
|
||||
node2 := gui.NewWindow()
|
||||
node2.DemoAndlabsUiTab("A Simple andlabs/ui Tab Demo")
|
||||
}
|
||||
|
||||
// This demonstrates how to properly interact with the GUI
|
||||
// You can not involke the GUI from external goroutines in most cases.
|
||||
func watchGUI() {
|
||||
var i = 1
|
||||
for {
|
||||
log.Println("Waiting", i, "seconds")
|
||||
i += 1
|
||||
time.Sleep(1 * time.Second)
|
||||
if i == 4 {
|
||||
log.Println("Opening a Debug Window via the gui.Queue()")
|
||||
gui.Config.Width = 800
|
||||
gui.Config.Height = 300
|
||||
gui.Config.Exit = myDebugExit
|
||||
gui.Queue(gui.DebugWindow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func myExit(n *gui.Node) {
|
||||
log.Println()
|
||||
log.Println("Entered myExit() on node.Name =", n.Name)
|
||||
log.Println()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func myDebugExit(n *gui.Node) {
|
||||
log.Println("Entered myDebugExit() on node.Name =", n.Name)
|
||||
log.Println("Don't actually os.Exit()")
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
import "strings"
|
||||
import "os"
|
||||
import "os/exec"
|
||||
import "io/ioutil"
|
||||
import "errors"
|
||||
// import "bufio"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
/*
|
||||
import "time"
|
||||
import "runtime"
|
||||
import "runtime/debug"
|
||||
import "runtime/pprof"
|
||||
|
||||
import "git.wit.org/wit/gui"
|
||||
import "git.wit.org/wit/shell"
|
||||
import "github.com/gobuffalo/packr"
|
||||
*/
|
||||
|
||||
func runSimpleCommand(s string) {
|
||||
cmd := strings.TrimSpace(s) // this is like 'chomp' in perl
|
||||
cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl
|
||||
cmdArgs := strings.Fields(cmd)
|
||||
runLinuxCommand(cmdArgs)
|
||||
}
|
||||
|
||||
var geom string = "120x30+500+500"
|
||||
|
||||
func xterm(cmd string) {
|
||||
var tmp []string
|
||||
var argsXterm = []string{"nohup", "xterm", "-geometry", geom}
|
||||
tmp = append(argsXterm, "-hold", "-e", cmd)
|
||||
log.Println("xterm cmd=", cmd)
|
||||
go runCommand(tmp)
|
||||
}
|
||||
|
||||
func runCommand(cmdArgs []string) {
|
||||
log.Println("runCommand() START", cmdArgs)
|
||||
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
||||
// process := exec.Command("xterm", "-e", "ping localhost")
|
||||
log.Println("runCommand() process.Start()")
|
||||
process.Start()
|
||||
log.Println("runCommand() process.Wait()")
|
||||
err := process.Wait()
|
||||
lookupError(err)
|
||||
log.Println("runCommand() NEED TO CHECK THE TIME HERE TO SEE IF THIS WORKED")
|
||||
log.Println("runCommand() OTHERWISE INFORM THE USER")
|
||||
log.Println("runCommand() END", cmdArgs)
|
||||
}
|
||||
|
||||
func lookupError(err error) {
|
||||
var (
|
||||
ee *exec.ExitError
|
||||
pe *os.PathError
|
||||
)
|
||||
|
||||
if errors.As(err, &ee) {
|
||||
log.Println("ran, but non-zero exit code =", ee.ExitCode()) // ran, but non-zero exit code
|
||||
} else if errors.As(err, &pe) {
|
||||
log.Printf("os.PathError = %v", pe) // "no such file ...", "permission denied" etc.
|
||||
} else if err != nil {
|
||||
log.Printf("something really bad happened general err = %v", err) // something really bad happened!
|
||||
if exitError, ok := err.(*exec.ExitError); ok {
|
||||
log.Printf("exitError.ExitCode() is %d\n", exitError.ExitCode())
|
||||
}
|
||||
} else {
|
||||
log.Println("success! // ran without error (exit code zero)")
|
||||
}
|
||||
}
|
||||
|
||||
func runLinuxCommand(cmdArgs []string) (string, error) {
|
||||
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
||||
|
||||
process.Stdin = os.Stdin
|
||||
process.Stderr = os.Stderr
|
||||
|
||||
stdOut, err := process.StdoutPipe()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err := process.Start(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
bytes, err := ioutil.ReadAll(stdOut)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = process.Wait()
|
||||
lookupError(err)
|
||||
|
||||
log.Println(string(bytes))
|
||||
return string(bytes), err
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
run: build
|
||||
./helloworld
|
||||
|
||||
build:
|
||||
build-release:
|
||||
go get -v -u -x .
|
||||
go build
|
||||
|
||||
build-master:
|
||||
build:
|
||||
GO111MODULE="off" go get -v -x .
|
||||
GO111MODULE="off" go build
|
||||
./helloworld
|
||||
|
|
|
@ -26,8 +26,9 @@ func initGUI() {
|
|||
func addDemoTab(n *gui.Node, title string) {
|
||||
newNode := n.AddTab(title, nil)
|
||||
|
||||
groupNode1 := newNode.AddGroup("group 1")
|
||||
groupNode1.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
|
||||
g := newNode.NewGroup("group 1")
|
||||
// g.Dump()
|
||||
g.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
|
||||
}
|
||||
|
||||
func myDefaultExit(n *gui.Node) {
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package gui
|
||||
|
||||
// import "log"
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
var mybox *ui.Box
|
||||
|
||||
func (n *Node) AddGroup(title string) *Node {
|
||||
if (n == nil) {
|
||||
return nil
|
||||
}
|
||||
hbox := n.uiBox
|
||||
if (hbox == nil) {
|
||||
return n
|
||||
}
|
||||
group := ui.NewGroup(title)
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
|
||||
newNode := n.AddNode(title)
|
||||
newNode.uiBox = vbox
|
||||
return newNode
|
||||
}
|
2
doc.go
2
doc.go
|
@ -38,7 +38,7 @@ sections below for further details on formatting and configuration options.
|
|||
func addDemoTab(n *gui.Node, title string) {
|
||||
newNode := n.AddTab(title, nil)
|
||||
|
||||
groupNode1 := newNode.AddGroup("group 1")
|
||||
groupNode1 := newNode.NewGroup("group 1")
|
||||
groupNode1.AddComboBox("demoCombo2", "more 1", "more 2", "more 3")
|
||||
}
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -5,5 +5,5 @@ go 1.17
|
|||
require (
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69
|
||||
golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf
|
||||
)
|
||||
|
|
24
go.sum
24
go.sum
|
@ -2,10 +2,34 @@ github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e h1:wSQCJiig/QkoUnpvelSP
|
|||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e/go.mod h1:5G2EjwzgZUPnnReoKvPWVneT8APYbyKkihDVAHUi0II=
|
||||
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/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY=
|
||||
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
|
||||
golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf h1:nq7IoIHc0jQHd2/cn0Oedp7Z9gH80pVTiDd9bF7u+O4=
|
||||
golang.org/x/image v0.0.0-20221017200508-ffcb3fe7d1bf/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
|
||||
import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
func (n *Node) NewGroup(name string) *Node {
|
||||
var t *toolkit.Toolkit
|
||||
var gNode, bNode *Node
|
||||
log.Println("toolkit.NewGroup() START", name)
|
||||
|
||||
// make a *Node with a *toolkit.Group
|
||||
gNode = n.AddNode(name + " part1")
|
||||
t = toolkit.NewGroup(n.uiBox, name)
|
||||
gNode.Toolkit = t
|
||||
gNode.Dump()
|
||||
|
||||
// make a *Node with a *toolkit.Box
|
||||
bNode = n.AddNode(name + " part2")
|
||||
bNode.Toolkit = t.NewBox()
|
||||
bNode.uiBox = bNode.Toolkit.GetBox()
|
||||
bNode.Dump()
|
||||
return bNode
|
||||
}
|
||||
|
||||
func (n *Node) AddGroup(title string) *Node {
|
||||
return n.NewGroup(title)
|
||||
}
|
||||
|
||||
func (n *Node) AddGroupOld(title string) *Node {
|
||||
if (n == nil) {
|
||||
return nil
|
||||
}
|
||||
hbox := n.uiBox
|
||||
if (hbox == nil) {
|
||||
return n
|
||||
}
|
||||
group := ui.NewGroup(title)
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
|
||||
newNode := n.AddNode(title)
|
||||
newNode.uiBox = vbox
|
||||
return newNode
|
||||
}
|
||||
|
||||
/*
|
||||
func (n *Node) NewGroup(title string) *Node {
|
||||
group := ui.NewGroup(title)
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
*/
|
|
@ -62,6 +62,7 @@ type Node struct {
|
|||
|
||||
uiControl *ui.Control
|
||||
uiButton *ui.Button
|
||||
uiGroup *ui.Group
|
||||
uiSlider *ui.Slider
|
||||
uiSpinbox *ui.Spinbox
|
||||
uiWindow *ui.Window
|
||||
|
@ -96,11 +97,11 @@ func (n *Node) Dump() {
|
|||
if (n.window != nil) {
|
||||
IndentPrintln("window = ", n.window)
|
||||
}
|
||||
if (n.window != nil) {
|
||||
if (n.box != nil) {
|
||||
IndentPrintln("box = ", n.box)
|
||||
}
|
||||
|
||||
if (n.window != nil) {
|
||||
if (n.uiWindow != nil) {
|
||||
IndentPrintln("uiWindow = ", n.uiWindow)
|
||||
}
|
||||
if (n.uiTab != nil) {
|
||||
|
@ -109,6 +110,10 @@ func (n *Node) Dump() {
|
|||
if (n.uiBox != nil) {
|
||||
IndentPrintln("uiBox = ", n.uiBox)
|
||||
}
|
||||
if (n.Toolkit != nil) {
|
||||
IndentPrintln("Toolkit = ", n.Toolkit)
|
||||
n.Toolkit.Dump()
|
||||
}
|
||||
if (n.uiControl != nil) {
|
||||
IndentPrintln("uiControl = ", n.uiControl)
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ func DemoNumbersPage(w *ui.Window) *Toolkit {
|
|||
t.uiBox = makeNumbersPage()
|
||||
t.uiBox.SetPadded(true)
|
||||
w.SetChild(t.uiBox)
|
||||
w.SetTitle("Internal demo of andlabs/ui toolkit")
|
||||
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolbox.DemoNumbersPage()")
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package toolkit
|
||||
|
||||
import "log"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
// make new Group here
|
||||
func NewGroup(b *ui.Box, title string) *Toolkit {
|
||||
var t Toolkit
|
||||
|
||||
if (b == nil) {
|
||||
log.Println("gui.ToolboxNode.NewSpinbox() node.UiBox == nil. I can't add a range UI element without a place to put it")
|
||||
return &t
|
||||
}
|
||||
|
||||
log.Println("gui.Toolbox.NewGroup() create", title)
|
||||
g := ui.NewGroup(title)
|
||||
g.SetMargined(true)
|
||||
t.uiGroup = g
|
||||
t.uiBox = b
|
||||
t.uiBox.Append(g, false)
|
||||
|
||||
return &t
|
||||
}
|
||||
|
||||
// create a new box
|
||||
func (t *Toolkit) GetBox() *ui.Box {
|
||||
return t.uiBox
|
||||
}
|
||||
|
||||
// create a new box
|
||||
func (t *Toolkit) NewBox() *Toolkit {
|
||||
log.Println("gui.Toolbox.NewBox() START create default")
|
||||
if (t.uiGroup != nil) {
|
||||
log.Println("gui.Toolbox.NewBox() is a Group")
|
||||
var newTK Toolkit
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
t.uiGroup.SetChild(vbox)
|
||||
newTK.uiBox = vbox
|
||||
|
||||
return &newTK
|
||||
}
|
||||
log.Println("gui.Toolbox.NewBox() FAILED")
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
func (n *Node) NewGroup(title string) *Node {
|
||||
group := ui.NewGroup(title)
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
*/
|
|
@ -23,6 +23,7 @@ type Toolkit struct {
|
|||
uiButton *ui.Button
|
||||
uiControl *ui.Control
|
||||
uiEntry *ui.Entry
|
||||
uiGroup *ui.Group
|
||||
uiLabel *ui.Label
|
||||
uiSlider *ui.Slider
|
||||
uiSpinbox *ui.Spinbox
|
||||
|
@ -31,6 +32,11 @@ type Toolkit struct {
|
|||
uiWindow *ui.Window
|
||||
}
|
||||
|
||||
func (t *Toolkit) Dump() {
|
||||
log.Println("gui.Toolkit.Dump() uiBox =", t.uiBox)
|
||||
log.Println("gui.Toolkit.Dump() uiGroup =", t.uiGroup)
|
||||
}
|
||||
|
||||
func (t *Toolkit) GetText() string {
|
||||
if (DebugToolkit) {
|
||||
log.Println("gui.Toolkit.Text() Enter")
|
||||
|
|
|
@ -31,7 +31,7 @@ func GolangDebugWindow() {
|
|||
|
||||
|
||||
/////////////////////////////// Column DEBUG GOLANG //////////////////////
|
||||
g := t.AddGroup("GO Language")
|
||||
g := t.NewGroup("GO Language")
|
||||
|
||||
g.AddButton("runtime.Stack()", func (*Node) {
|
||||
log.Println("\tSTART")
|
||||
|
|
|
@ -17,7 +17,7 @@ func ToolkitDemoWindow() {
|
|||
var w, d *Node
|
||||
var tk *toolkit.Toolkit
|
||||
|
||||
w = NewStandardWindow("Demo the GUI Toolkit")
|
||||
w = NewStandardWindow("Demo of the GUI Toolkit")
|
||||
|
||||
d = w.makeNode("demo", 767, 676 + Config.counter)
|
||||
d.Name = "demo"
|
||||
|
|
Loading…
Reference in New Issue