2019-05-16 13:42:28 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
import "log"
|
|
|
|
import "fmt"
|
2019-05-17 15:19:46 -05:00
|
|
|
import "os"
|
2019-05-16 13:42:28 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
var mainwin *ui.Window
|
|
|
|
var hbox *ui.Box
|
|
|
|
|
|
|
|
func makeSplashPage() ui.Control {
|
|
|
|
hbox = ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
|
|
|
|
group := ui.NewGroup("Numbers")
|
|
|
|
group.SetMargined(true)
|
|
|
|
hbox.Append(group, true)
|
|
|
|
|
2019-05-17 16:25:40 -05:00
|
|
|
vbox := ui.NewVerticalBox()
|
2019-05-16 13:42:28 -05:00
|
|
|
vbox.SetPadded(true)
|
|
|
|
group.SetChild(vbox)
|
|
|
|
|
|
|
|
spinbox := ui.NewSpinbox(47, 100)
|
|
|
|
slider := ui.NewSlider(21, 100)
|
|
|
|
pbar := ui.NewProgressBar()
|
|
|
|
|
|
|
|
spinbox.OnChanged(func(*ui.Spinbox) {
|
|
|
|
slider.SetValue(spinbox.Value())
|
|
|
|
pbar.SetValue(spinbox.Value())
|
|
|
|
})
|
|
|
|
slider.OnChanged(func(*ui.Slider) {
|
|
|
|
spinbox.SetValue(slider.Value())
|
|
|
|
pbar.SetValue(slider.Value())
|
|
|
|
})
|
|
|
|
vbox.Append(spinbox, false)
|
|
|
|
vbox.Append(slider, false)
|
|
|
|
vbox.Append(pbar, false)
|
|
|
|
|
|
|
|
return hbox
|
|
|
|
}
|
|
|
|
|
|
|
|
func setupUI() {
|
2019-05-19 21:21:35 -05:00
|
|
|
mainwin := ui.NewWindow("gui-example1", 300, 200, true)
|
2019-05-16 13:42:28 -05:00
|
|
|
mainwin.OnClosing(func(*ui.Window) bool {
|
|
|
|
ui.Quit()
|
2019-05-17 15:19:46 -05:00
|
|
|
os.Exit(0)
|
2019-05-16 13:42:28 -05:00
|
|
|
return true
|
|
|
|
})
|
|
|
|
ui.OnShouldQuit(func() bool {
|
|
|
|
mainwin.Destroy()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
tab := ui.NewTab()
|
|
|
|
mainwin.SetChild(tab)
|
|
|
|
mainwin.SetMargined(true)
|
|
|
|
|
|
|
|
tab.Append("WIT Splash", makeSplashPage())
|
|
|
|
tab.SetMargined(0, true)
|
|
|
|
|
|
|
|
mainwin.Show()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2019-05-17 16:25:40 -05:00
|
|
|
ui.Main(addAccountWindow)
|
|
|
|
|
2019-05-19 21:21:35 -05:00
|
|
|
ui.Main(showSplash)
|
|
|
|
|
2019-05-17 15:19:46 -05:00
|
|
|
go ui.Main(setupUI)
|
2019-05-16 13:42:28 -05:00
|
|
|
|
2019-05-17 13:01:34 -05:00
|
|
|
// locks up GTK after a while (50 times)
|
2019-05-16 13:42:28 -05:00
|
|
|
time.Sleep(1000 * time.Millisecond)
|
|
|
|
count := 0
|
2019-05-17 13:23:48 -05:00
|
|
|
|
|
|
|
var newgroup *ui.Group
|
|
|
|
|
|
|
|
name := "Test " + fmt.Sprintf("%d", count)
|
|
|
|
log.Println("name=",name)
|
|
|
|
newgroup = ui.NewGroup(name)
|
|
|
|
newgroup.SetMargined(true)
|
|
|
|
hbox.Append(newgroup, false)
|
|
|
|
|
|
|
|
// display the splash screen info
|
|
|
|
log.Println("sleep for 3")
|
|
|
|
time.Sleep(3000 * time.Millisecond)
|
|
|
|
|
|
|
|
hbox.Delete(1)
|
|
|
|
// newgroup.Delete()
|
|
|
|
// can't destroy when there is a parent
|
|
|
|
newgroup.Destroy()
|
|
|
|
newgroup = nil
|
|
|
|
|
|
|
|
// wait forever here
|
2019-05-16 13:42:28 -05:00
|
|
|
for {
|
2019-05-17 13:23:48 -05:00
|
|
|
log.Println("sleep for 3 forever here")
|
|
|
|
time.Sleep(3000 * time.Millisecond)
|
2019-05-16 13:42:28 -05:00
|
|
|
}
|
|
|
|
}
|