From 940591bb87d3bf409027023091584fbea6008e52 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 29 May 2019 16:16:09 -0700 Subject: [PATCH] more work on the splash text Signed-off-by: Jeff Carr --- colors.go | 3 --- test1/Makefile | 3 ++- test2/config.go | 4 ++-- test3/Makefile | 3 ++- test3/main.go | 37 ++++++++++++++----------------- test4/Makefile | 5 +---- test4/main.go | 59 +++++++------------------------------------------ 7 files changed, 31 insertions(+), 83 deletions(-) diff --git a/colors.go b/colors.go index ef4caf4..cc44327 100644 --- a/colors.go +++ b/colors.go @@ -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} diff --git a/test1/Makefile b/test1/Makefile index e07773d..861f79e 100644 --- a/test1/Makefile +++ b/test1/Makefile @@ -1,2 +1,3 @@ run: - go run *.go + go build + ./test1 diff --git a/test2/config.go b/test2/config.go index c4d48a8..8cc4ccb 100644 --- a/test2/config.go +++ b/test2/config.go @@ -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 { diff --git a/test3/Makefile b/test3/Makefile index e07773d..dae14ea 100644 --- a/test3/Makefile +++ b/test3/Makefile @@ -1,2 +1,3 @@ run: - go run *.go + go build + ./test3 diff --git a/test3/main.go b/test3/main.go index eff3cce..bf47b75 100644 --- a/test3/main.go +++ b/test3/main.go @@ -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) } diff --git a/test4/Makefile b/test4/Makefile index 5c926db..52515aa 100644 --- a/test4/Makefile +++ b/test4/Makefile @@ -1,6 +1,3 @@ -build: +run: go build ./test4 - -run: - go run *.go diff --git a/test4/main.go b/test4/main.go index 4783009..39d7aaa 100644 --- a/test4/main.go +++ b/test4/main.go @@ -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() }