simple draw area example

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-22 13:25:43 -07:00
parent 59e1838663
commit 81df3e09fc
2 changed files with 10 additions and 91 deletions

View File

@ -8,7 +8,7 @@ import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/cloud-control-panel/splash"
import "git.wit.com/wit/cloud-control-panel/account1"
import "git.wit.com/wit/cloud-control-panel/account2"
// import "git.wit.com/wit/cloud-control-panel/account2"
import "github.com/davecgh/go-spew/spew"
@ -33,9 +33,8 @@ func main() {
ui.Main(makeCloudWindow)
ui.Main(account1.AddAccountWindow)
ui.Main(account2.AddAccountWindow)
// ui.Main(account1.AddAccountWindow)
// ui.Main(account2.AddAccountWindow)
}
func buttonClick(i int) {
@ -43,16 +42,13 @@ func buttonClick(i int) {
}
func watchGUI() {
// log.Println("Sleep()")
// time.Sleep(2000 * time.Millisecond)
for {
log.Println("Sleep()")
time.Sleep(200 * time.Millisecond)
if (state == "splash") {
log.Println("Display the splash box")
smallBox = splash.ShowSplashBox(cloudBox, nil, splashClose)
smallBox = account1.AddAccountBox(cloudBox, splashClose)
// newbox.SetPadded(true)
state = "done"
}
@ -66,7 +62,7 @@ func watchGUI() {
}
if (state == "account1") {
log.Println("Display the splash box")
smallBox = account1.AddAccountBox(cloudBox, splashClose)
smallBox = splash.ShowSplashBox(cloudBox, nil, splashClose)
// newbox.SetPadded(true)
state = "done"
}

View File

@ -1,33 +1,14 @@
package main
import "os"
import "log"
import "time"
import "os/signal"
import "github.com/davecgh/go-spew/spew"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/cloud-control-panel/splash"
// import "git.wit.com/wit/cloud-control-panel/account1"
// import "git.wit.com/wit/cloud-control-panel/account2"
var atest chan int
func main() {
/*
ui.Main(splash.ShowSplash)
ui.Main(account1.AddAccountWindow)
ui.Main(account2.AddAccountWindow)
ui.Main(addAccountWindow)
ui.Main(showSplash)
*/
go ui.Main(setupUI)
beautifulAndFacinatingChannel()
// ui.Main(testFor)
ui.Main(setupUI)
}
func setupUI() {
@ -39,8 +20,6 @@ func setupUI() {
})
ui.OnShouldQuit(func() bool {
mainwin.Destroy()
test := 4
atest <- test
return true
})
@ -50,67 +29,11 @@ func setupUI() {
mainwin.Show()
vbox := splash.ShowSplashBox(nil, atest)
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
splash.ShowSplashBox(vbox, nil, nil)
tab.Append("WIT Splash", vbox)
tab.SetMargined(0, true)
}
func somefunc(testing os.Signal) {
// return 1
}
type Newish struct {
A <-chan int
r string
}
//
// this is a facinating code snippet that I wanted to leave here because it is
// so interesting. Complements to the gorilla websocket example developers
//
func beautifulAndFacinatingChannel() {
done := make(chan struct{})
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
ticker := time.NewTicker(time.Second * 1)
// atest := make(chan int, 1)
atest = make(chan int)
newthing := &Newish{
A: atest,
r: "something",
}
defer ticker.Stop()
defer close(done)
for {
select {
case <-done:
log.Println("case <-done is EMPTY?")
return
case t := <-ticker.C:
log.Println("test NewTicker()", t.String())
spew.Dump(ticker)
case j := <-atest:
log.Println("GOT HERE!!!! test func() j=", j)
close(done)
case <-interrupt:
log.Println("interrupt")
newthing.r = "four"
spew.Dump(newthing)
// could do final things here when kill or ctrl-c
select {
case <-done:
log.Println("case <-done is EMPTY?")
case <-time.After(time.Second):
log.Println("case <-second timer fired again")
}
return
}
}
}