move splash screen into a seperate file

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-17 11:35:03 -07:00
parent 287dff1a08
commit 67813ac698
2 changed files with 58 additions and 40 deletions

View File

@ -42,46 +42,6 @@ func makeSplashPage() ui.Control {
return hbox return hbox
} }
func showSplash() {
splashWin := ui.NewWindow("Splash Screen", 640, 480, false)
splashWin.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
splashWin.Destroy()
return true
})
tab := ui.NewTab()
splashWin.SetChild(tab)
splashWin.SetMargined(true)
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
group := ui.NewGroup("Numbers")
group.SetMargined(true)
hbox.Append(group, true)
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
group.SetChild(vbox)
okButton := ui.NewButton("OK")
okButton.OnClicked(func(*ui.Button) {
log.Println("OK. Closing window.")
splashWin.Destroy()
ui.Quit()
})
vbox.Append(okButton, false)
tab.Append("WIT Splash", hbox)
tab.SetMargined(0, true)
splashWin.Show()
}
func setupUI() { func setupUI() {
mainwin := ui.NewWindow("gui-example1", 300, 200, false) mainwin := ui.NewWindow("gui-example1", 300, 200, false)
mainwin.OnClosing(func(*ui.Window) bool { mainwin.OnClosing(func(*ui.Window) bool {

58
example-splash/splash.go Normal file
View File

@ -0,0 +1,58 @@
package main
// import "time"
import "log"
// import "fmt"
import "runtime"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func showSplash() {
splashWin := ui.NewWindow("Splash Screen", 640, 480, false)
splashWin.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
splashWin.Destroy()
return true
})
tab := ui.NewTab()
splashWin.SetChild(tab)
splashWin.SetMargined(true)
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
group := ui.NewGroup("Numbers")
group.SetMargined(true)
hbox.Append(group, true)
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
group.SetChild(vbox)
okButton := ui.NewButton("OK")
okButton.OnClicked(func(*ui.Button) {
log.Println("OK. Closing window.")
splashWin.Destroy()
ui.Quit()
})
vbox.Append(okButton, false)
if runtime.GOOS == "linux" {
vbox.Append(ui.NewLabel("OS: Linux"), false)
} else if runtime.GOOS == "windows" {
vbox.Append(ui.NewLabel("OS: Windows"), false)
} else {
vbox.Append(ui.NewLabel("OS: " + runtime.GOOS), false)
}
tab.Append("WIT Splash", hbox)
tab.SetMargined(0, true)
splashWin.Show()
}