-
Notifications
You must be signed in to change notification settings - Fork 0
/
goui.go
46 lines (36 loc) · 714 Bytes
/
goui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"github.com/andlabs/ui"
)
type goUI struct {
child *ui.Box
window *ui.Window
}
func (g goUI) Start() {
ui.Main(func() {
if g.window == nil {
g.window = ui.NewWindow("Default goUI title", 640, 480, true)
}
g.window.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
g.window.Destroy()
return true
})
if g.child != nil {
g.window.SetChild(g.child)
}
g.window.Show()
})
}
func (g goUI) Window(title string, width int, height int, hasMenubar bool) *goUI {
g.window = ui.NewWindow(title, width, height, hasMenubar)
return &g
}
func App(child *ui.Box) *goUI {
ui := goUI{}
ui.child = child
return &ui
}