forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 1.21 KB
/
main.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
47
48
49
50
51
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"time"
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/samples/flags"
"github.com/google/gxui/themes/dark"
)
func appMain(driver gxui.Driver) {
theme := dark.CreateTheme(driver)
label := theme.CreateLabel()
label.SetText("This is a progress bar:")
progressBar := theme.CreateProgressBar()
progressBar.SetDesiredSize(math.Size{W: 400, H: 20})
progressBar.SetTarget(100)
layout := theme.CreateLinearLayout()
layout.AddChild(label)
layout.AddChild(progressBar)
layout.SetHorizontalAlignment(gxui.AlignCenter)
window := theme.CreateWindow(800, 600, "Progress bar")
window.SetScale(flags.DefaultScaleFactor)
window.AddChild(layout)
window.OnClose(driver.Terminate)
progress := 0
pause := time.Millisecond * 500
var timer *time.Timer
timer = time.AfterFunc(pause, func() {
driver.Call(func() {
progress = (progress + 3) % progressBar.Target()
progressBar.SetProgress(progress)
timer.Reset(pause)
})
})
}
func main() {
gl.StartDriver(appMain)
}