From 6984b0dbc06e2972f7847974fca1b8d8b59e60de Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 22 May 2019 20:30:48 -0700 Subject: [PATCH] all local variables are in Data{} Signed-off-by: Jeff Carr --- gui.go | 8 ++++++++ splash.go | 31 ++----------------------------- tabWindow.go | 32 +++++++++++++------------------- 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/gui.go b/gui.go index 4d5810b..c6414ba 100644 --- a/gui.go +++ b/gui.go @@ -22,13 +22,21 @@ type GuiDataStructure struct { Height int ButtonClick func(int, string) CurrentVM string + MyArea *ui.Area + // stuff for the splash screen / setup tabs cloudWindow *ui.Window + cloudTab *ui.Tab + cloudBox *ui.Box + smallBox *ui.Box + mainwin *ui.Window maintab *ui.Tab tabcount int allButtons []ButtonMap + + // stuff for the 'area' fontButton *ui.FontButton attrstr *ui.AttributedString diff --git a/splash.go b/splash.go index 5891da9..17b460f 100644 --- a/splash.go +++ b/splash.go @@ -10,41 +10,14 @@ import "runtime" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -var MyArea *ui.Area - -func ShowSplash() *ui.Window { - splashWin := ui.NewWindow("", 640, 480, true) - splashWin.SetBorderless(true) - splashWin.OnClosing(func(*ui.Window) bool { - ui.Quit() - return true - }) - ui.OnShouldQuit(func() bool { - splashWin.Destroy() - return true - }) - - vbox := ui.NewVerticalBox() - vbox.SetPadded(true) - splashWin.SetChild(vbox) - splashWin.SetMargined(true) - - // This displays the window - // splashWin.Show() - - ShowSplashBox(vbox, nil, nil) - - return splashWin -} - func ShowSplashBox(vbox *ui.Box, atest chan int, custom func(int, string)) *ui.Box { newbox := ui.NewVerticalBox() newbox.SetPadded(true) makeAttributedString() - MyArea = makeSplashArea(custom) + Data.MyArea = makeSplashArea(custom) - newbox.Append(MyArea, true) + newbox.Append(Data.MyArea, true) if runtime.GOOS == "linux" { newbox.Append(ui.NewLabel("OS: Linux"), false) diff --git a/tabWindow.go b/tabWindow.go index 5543e8e..72e4109 100644 --- a/tabWindow.go +++ b/tabWindow.go @@ -8,12 +8,6 @@ import _ "github.com/andlabs/ui/winmanifest" // import "github.com/davecgh/go-spew/spew" -// var cloudWindow *ui.Window -var cloudTab *ui.Tab -var cloudBox *ui.Box -var smallBox *ui.Box -var state string - func buttonClick(i int, s string) { log.Println("gui.buttonClick() i, s =", i, s) log.Println("Figure out what to do here") @@ -27,25 +21,25 @@ func buttonClick(i int, s string) { } func ShowAccountQuestionTab() { - cloudTab.Delete(0) + Data.cloudTab.Delete(0) log.Println("Sleep(1000)") time.Sleep(1000 * time.Millisecond) - smallBox = AddAccountQuestionBox(nil, buttonClick) - cloudTab.InsertAt("New Account?", 0, smallBox) - cloudTab.SetMargined(0, true) + Data.smallBox = AddAccountQuestionBox(nil, buttonClick) + Data.cloudTab.InsertAt("New Account?", 0, Data.smallBox) + Data.cloudTab.SetMargined(0, true) } func ShowAccountTab() { - cloudTab.Delete(0) + Data.cloudTab.Delete(0) log.Println("Sleep(1000)") time.Sleep(1000 * time.Millisecond) - smallBox = AddAccountBox(buttonClick) - cloudTab.InsertAt("Add Account", 0, smallBox) - cloudTab.SetMargined(0, true) + Data.smallBox = AddAccountBox(buttonClick) + Data.cloudTab.InsertAt("Add Account", 0, Data.smallBox) + Data.cloudTab.SetMargined(0, true) } func GoMainWindow() { @@ -64,14 +58,14 @@ func makeCloudWindow() { return true }) - cloudTab = ui.NewTab() - Data.cloudWindow.SetChild(cloudTab) + Data.cloudTab = ui.NewTab() + Data.cloudWindow.SetChild(Data.cloudTab) Data.cloudWindow.SetMargined(true) - cloudBox = ShowSplashBox(nil, nil, buttonClick) + Data.cloudBox = ShowSplashBox(nil, nil, buttonClick) - cloudTab.Append("WIT Splash", cloudBox) - cloudTab.SetMargined(0, true) + Data.cloudTab.Append("WIT Splash", Data.cloudBox) + Data.cloudTab.SetMargined(0, true) Data.cloudWindow.Show() Data.State = "splash"