start moving everything into a common structure (gui.Data)

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-22 19:05:25 -07:00
parent 522581dbaf
commit 9189fcde04
2 changed files with 24 additions and 25 deletions

21
gui.go
View File

@ -12,22 +12,24 @@ var mainwin *ui.Window
var maintab *ui.Tab var maintab *ui.Tab
var tabcount int var tabcount int
var Width int
var Height int var Height int
var allButtons []ButtonMap var allButtons []ButtonMap
var internalDS GuiDS
func GetDataStructures() *GuiDS { //
return &internalDS // All GUI Data Structures and functions that are external
} // If you need cross platform support, these might only
// be the safe way to interact with the GUI
//
var Data GuiDataStructure
// All GUI Data Structures that are external type GuiDataStructure struct {
type GuiDS struct {
State string State string
MainWindow *ui.Window MainWindow *ui.Window
Width int
ButtonClick func(int, string) ButtonClick func(int, string)
cloudWindow *ui.Window
} }
type TableColumnData struct { type TableColumnData struct {
@ -48,7 +50,7 @@ type ButtonMap struct {
} }
func setupUI() { func setupUI() {
mainwin = ui.NewWindow("Cloud Control Panel", Width, Height, false) mainwin = ui.NewWindow("Cloud Control Panel", Data.Width, Height, false)
mainwin.OnClosing(func(*ui.Window) bool { mainwin.OnClosing(func(*ui.Window) bool {
ui.Quit() ui.Quit()
return true return true
@ -172,9 +174,6 @@ func DoGUI() {
} }
} }
func defaultMouseEvent() {
}
func defaultButtonClick(button *ui.Button) { func defaultButtonClick(button *ui.Button) {
log.Println("defaultButtonClick() button =", button) log.Println("defaultButtonClick() button =", button)
for key, foo := range allButtons { for key, foo := range allButtons {

View File

@ -8,7 +8,7 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew" // import "github.com/davecgh/go-spew/spew"
var cloudWindow *ui.Window // var cloudWindow *ui.Window
var cloudTab *ui.Tab var cloudTab *ui.Tab
var cloudBox *ui.Box var cloudBox *ui.Box
var smallBox *ui.Box var smallBox *ui.Box
@ -26,7 +26,11 @@ func splashClose(a int, b string) {
} }
func buttonClick(i int, s string) { func buttonClick(i int, s string) {
log.Println("test2 buttonClick() i, s =", i, s) log.Println("gui.buttonClick() i, s =", i, s)
log.Println("Figure out what to do here")
log.Println("Figure out what to do here")
log.Println("Figure out what to do here")
/*
cloudTab.Delete(0) cloudTab.Delete(0)
log.Println("Sleep(2000)") log.Println("Sleep(2000)")
@ -35,6 +39,7 @@ func buttonClick(i int, s string) {
smallBox = AddAccountBox(nil, splashClose) smallBox = AddAccountBox(nil, splashClose)
cloudTab.InsertAt("Intro", 0, smallBox) cloudTab.InsertAt("Intro", 0, smallBox)
cloudTab.SetMargined(0, true) cloudTab.SetMargined(0, true)
*/
} }
func ShowAccountTab() { func ShowAccountTab() {
@ -53,31 +58,26 @@ func GoMainWindow() {
} }
func makeCloudWindow() { func makeCloudWindow() {
cloudWindow := ui.NewWindow("", 640, 480, true) Data.cloudWindow = ui.NewWindow("", 640, 480, true)
// cloudWindow.SetBorderless(true) // cloudWindow.SetBorderless(true)
cloudWindow.OnClosing(func(*ui.Window) bool { Data.cloudWindow.OnClosing(func(*ui.Window) bool {
ui.Quit() ui.Quit()
return true return true
}) })
ui.OnShouldQuit(func() bool { ui.OnShouldQuit(func() bool {
cloudWindow.Destroy() Data.cloudWindow.Destroy()
return true return true
}) })
// cloudBox = ui.NewVerticalBox()
// cloudBox.SetPadded(true)
// cloudWindow.SetChild(cloudBox)
// cloudWindow.SetMargined(true)
cloudTab = ui.NewTab() cloudTab = ui.NewTab()
cloudWindow.SetChild(cloudTab) Data.cloudWindow.SetChild(cloudTab)
cloudWindow.SetMargined(true) Data.cloudWindow.SetMargined(true)
cloudBox = ShowSplashBox(nil, nil, buttonClick) cloudBox = ShowSplashBox(nil, nil, buttonClick)
cloudTab.Append("WIT Splash", cloudBox) cloudTab.Append("WIT Splash", cloudBox)
cloudTab.SetMargined(0, true) cloudTab.SetMargined(0, true)
cloudWindow.Show() Data.cloudWindow.Show()
// state = "done" Data.State = "splash done"
} }