more experiments on stability

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-30 00:50:57 -07:00
parent b213a90e20
commit d96a94e977
6 changed files with 133 additions and 14 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ example-UI-table/example-UI-table
example-dnssecsocket/example-dnssecsocket
example-table/example-table
example-aminal/example-aminal
example-multiple-windows/example-multiple-windows
test1/test1
test2/test2

View File

@ -0,0 +1,3 @@
run:
go build
./example-multiple-windows

View File

@ -0,0 +1,117 @@
package main
// import "os"
import "log"
import "fmt"
import "time"
import "github.com/davecgh/go-spew/spew"
import "git.wit.com/wit/gui"
import pb "git.wit.com/wit/witProtobuf"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
var first *gui.WindowMap
func main() {
var c *pb.Config
c = pb.MakeDefaultConfig()
i := 1
c.Width = int32(400 + 50 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
first = StartNewWindow(c, true, "SPLASH")
i += 1
c.Width = int32(400 + 50 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
StartNewWindow(c, false, "BLAH")
i += 1
c.Width = int32(400 + 50 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
StartNewWindow(c, false, "BLAH")
for {
i += 1
c.Width = int32(400 + 50 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
StartNewWindow(c, false, "SPLASH")
i += 1
c.Width = int32(400 + 50 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
StartNewWindow(c, false, "BLAH")
}
}
func StartNewWindow(c *pb.Config, bg bool, action string) *gui.WindowMap {
log.Println("InitNewWindow() Create a new window")
var newWindowMap *gui.WindowMap
newWindowMap = new(gui.WindowMap)
newWindowMap.C = c
/*
ui.OnShouldQuit(func() bool {
// mouseClick(&newBM)
ui.Quit()
return true
})
*/
time.Sleep(1000 * time.Millisecond)
if (bg) {
log.Println("ShowWindow() IN NEW GOROUTINE")
go ui.Main(func() {
InitWindow(newWindowMap)
})
time.Sleep(2000 * time.Millisecond)
} else {
log.Println("ShowWindow() WAITING for ui.Main()")
ui.Main(func() {
InitWindow(newWindowMap)
})
}
return newWindowMap
}
func InitWindow(wm *gui.WindowMap) {
log.Println("InitWindow() NEW WINDOW wm =", wm)
c := wm.C
wm.W = ui.NewWindow("", int(c.Width), int(c.Height), true)
// wm.W.SetBorderless(false)
blah := wm
wm.W.OnClosing(func(*ui.Window) bool {
log.Println("InitWindow() OnClosing() blah")
log.Println("InitWindow() OnClosing() blah")
log.Println("InitWindow() OnClosing() blah")
log.Println("InitWindow() OnClosing() blah")
spew.Dump(blah)
spew.Dump(wm)
wm.C = nil
log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING wm=", wm)
spew.Dump(wm)
spew.Dump(wm.W)
// mouseClick(&newBM)
if (wm.W != nil) {
wm.W.Hide()
}
time.Sleep(1000 * time.Millisecond)
spew.Dump(wm)
// wm.W.Destroy()
ui.Quit()
time.Sleep(1000 * time.Millisecond)
return true
})
// wm.W.SetChild(wm.T)
// wm.W.SetMargined(true)
log.Println("InitWindow() Show() wm.Action =", wm.Action)
wm.W.Show()
}

10
main.go
View File

@ -105,8 +105,8 @@ func main() {
onExit(err)
}
gui.Data.Width = int(config.Width)
gui.Data.Height = int(config.Height)
// gui.Data.Width = int(config.Width)
// gui.Data.Height = int(config.Height)
// use this to discover what the OS thinks it's hostname is
// seems to be cross platform (?)
@ -145,12 +145,6 @@ func main() {
// make this the main loop in an attempt to figure out the crashes
// do not change this until the GUI is stable
gui.StartNewWindow(config, false, "SPLASH")
// gui.Data.Window1 = new(gui.WindowMap)
// gui.Data.Window1.AreaText = getSplashText()
// this crashes here. crazy!
// gui.Data.Window1.AreaText = getNEWTEXT()
// gui.GoMainWindow()
}
// This is the handler for all mosue clicks (buttons, areas, etc))

View File

@ -5,7 +5,6 @@ import "git.wit.com/wit/gui"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func getSplashText() *ui.AttributedString {
var aText *ui.AttributedString
aText = ui.NewAttributedString("Click to continue")

View File

@ -2,6 +2,7 @@ package main
import "os"
import "log"
import "fmt"
import "github.com/davecgh/go-spew/spew"
@ -17,22 +18,26 @@ func main() {
gui.Data.MouseClick = mainMouseClick
i := 0
i := 1
gui.Data.Hostname = "splash " + string(i)
c.Width += int32(100 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
gui.StartNewWindow(c, true, "SPLASH")
i += 1
gui.Data.Hostname = "splash " + string(i)
c.Width += int32(100 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
gui.StartNewWindow(c, true, "BLAH")
for {
i += 1
gui.Data.Hostname = "splash " + string(i)
c.Width += int32(100 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
gui.StartNewWindow(c, false, "SPLASH")
i += 1
gui.Data.Hostname = "splash " + string(i)
c.Width += int32(100 * i)
c.Hostname = fmt.Sprintf("splash %d", i)
gui.StartNewWindow(c, false, "BLAH")
}
}