more work on the splash text

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 16:16:09 -07:00
parent 37046dd791
commit 940591bb87
7 changed files with 31 additions and 83 deletions

View File

@ -4,12 +4,9 @@ import "fmt"
import "image/color"
import "runtime"
// import "github.com/golang/protobuf/proto"
import pb "git.wit.com/wit/witProtobuf"
import "git.wit.com/wit/gui"
// import "github.com/andlabs/ui"
var windowsTextVeryLightGrey = color.RGBA{10, 10, 10, 10}
var windowsTextBlack = color.RGBA{200, 200, 200, 200}
var windowsTextWhite = color.RGBA{255, 255, 255, 255}

View File

@ -1,2 +1,3 @@
run:
go run *.go
go build
./test1

View File

@ -25,11 +25,11 @@ import "github.com/davecgh/go-spew/spew"
func loadDefaultConfig(a string) pb.Config {
sets := pb.Config{}
b, err := ioutil.ReadFile("../resources/protobuf-config.json")
b, err := ioutil.ReadFile("../resources/cloud-control-panel.json")
if err != nil {
log.Println("ioutil.ReadFile() ERROR =", err)
}
log.Println("ioutil.ReadFile() b =", b)
// log.Println("ioutil.ReadFile() b =", b)
err = jsonpb.Unmarshal(strings.NewReader(string(b)), &sets)
if err != nil {

View File

@ -1,2 +1,3 @@
run:
go run *.go
go build
./test3

View File

@ -1,5 +1,6 @@
package main
import "log"
import "os"
import "github.com/andlabs/ui"
@ -7,31 +8,25 @@ import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/gui"
func TestAttributedString() *ui.AttributedString {
newText := ui.NewAttributedString("")
gui.AreaAppendText(newText, "Welcome to the Cloud Control Panel\n", ui.TextSize(16), ui.TextColor{0.0, 0.0, 0.8, .8}) // "RGBT"
return newText
}
func main() {
// THIS CRASHES IF YOU RUN IT HERE
// text := TestAttributedString()
// log.Println("text =", text)
ui.Main(setupUI)
}
func setupUI() {
mainwin := ui.NewWindow("gui-example1", 640, 480, true)
mainwin.OnClosing(func(*ui.Window) bool {
ui.Quit()
os.Exit(0)
return true
})
ui.OnShouldQuit(func() bool {
mainwin.Destroy()
return true
})
tab := ui.NewTab()
mainwin.SetChild(tab)
mainwin.SetMargined(true)
vbox := gui.ShowSplashBox(nil, nil, nil)
tab.Append("WIT Splash", vbox)
tab.SetMargined(0, true)
mainwin.Show()
// this doesn't crash here
text := TestAttributedString()
log.Println("text =", text)
os.Exit(0)
}

View File

@ -1,6 +1,3 @@
build:
run:
go build
./test4
run:
go run *.go

View File

@ -1,58 +1,15 @@
package main
import "log"
import "time"
import "os"
// import "os"
// import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "git.wit.com/wit/gui"
func main() {
gui.Data.ButtonClick = buttonClick
gui.Data.ButtonClickNew = buttonClickNew
go gui.GoMainWindow()
watchGUI()
}
func buttonClickNew(b *gui.ButtonMap) {
log.Println("test4 buttonClickNew() b =", b)
log.Println("\tb.Name", b.Name)
log.Println("\tb.Note", b.Note)
if (b.Note == "BACK") {
gui.Data.State = "splash"
}
if (gui.Data.State == "splash") {
gui.ShowAccountQuestionTab()
gui.Data.State = "account1"
return
} else if (gui.Data.State == "account1") {
gui.ShowAccountTab()
gui.Data.State = "main"
} else if (gui.Data.State == "main") {
gui.ShowMainTab()
gui.Data.State = "done"
}
}
func buttonClick(i int, s string) {
log.Println("test4 buttonClick() i, s =", i, s)
}
func watchGUI() {
log.Println("Sleep(2000)")
time.Sleep(2000 * time.Millisecond)
for {
log.Println("Sleep() in watchGUI() gui.Data.State =", gui.Data.State)
time.Sleep(2000 * time.Millisecond)
if (gui.Data.State == "kill") {
log.Println("gui.State = kill")
log.Println("gui.State = kill")
log.Println("gui.State = kill")
os.Exit(0)
}
}
gui.Data.Window1 = new(gui.WindowMap)
gui.Data.Window1.AreaText = ui.NewAttributedString("Click to continue")
gui.GoMainWindow()
}