From 67813ac698356e37b3a01a3d9da18b9a5a8dfabc Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 17 May 2019 11:35:03 -0700 Subject: [PATCH] move splash screen into a seperate file Signed-off-by: Jeff Carr --- example-splash/main.go | 40 --------------------------- example-splash/splash.go | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 example-splash/splash.go diff --git a/example-splash/main.go b/example-splash/main.go index ee65486..95b5154 100644 --- a/example-splash/main.go +++ b/example-splash/main.go @@ -42,46 +42,6 @@ func makeSplashPage() ui.Control { 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() { mainwin := ui.NewWindow("gui-example1", 300, 200, false) mainwin.OnClosing(func(*ui.Window) bool { diff --git a/example-splash/splash.go b/example-splash/splash.go new file mode 100644 index 0000000..191e1a3 --- /dev/null +++ b/example-splash/splash.go @@ -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() +}