forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (42 loc) · 1.34 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
52
53
54
package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/samples/flags"
)
func appMain(driver gxui.Driver) {
theme := flags.CreateTheme(driver)
label1 := theme.CreateLabel()
label1.SetColor(gxui.White)
label1.SetText("1x1")
cell1x1 := theme.CreateLinearLayout()
cell1x1.SetBackgroundBrush(gxui.CreateBrush(gxui.Blue40))
cell1x1.SetHorizontalAlignment(gxui.AlignCenter)
cell1x1.AddChild(label1)
label2 := theme.CreateLabel()
label2.SetColor(gxui.White)
label2.SetText("2x1")
cell2x1 := theme.CreateLinearLayout()
cell2x1.SetBackgroundBrush(gxui.CreateBrush(gxui.Green40))
cell2x1.SetHorizontalAlignment(gxui.AlignCenter)
cell2x1.AddChild(label2)
label3 := theme.CreateLabel()
label3.SetColor(gxui.White)
label3.SetText("1x2")
cell1x2 := theme.CreateLinearLayout()
cell1x2.SetBackgroundBrush(gxui.CreateBrush(gxui.Red40))
cell1x2.SetHorizontalAlignment(gxui.AlignCenter)
cell1x2.AddChild(label3)
table := theme.CreateTableLayout()
table.SetGrid(3, 2) // columns, rows
// row, column, horizontal span, vertical span
table.SetChildAt(0, 0, 1, 1, cell1x1)
table.SetChildAt(0, 1, 2, 1, cell2x1)
table.SetChildAt(2, 0, 1, 2, cell1x2)
window := theme.CreateWindow(800, 600, "Table")
window.AddChild(table)
window.OnClose(driver.Terminate)
}
func main() {
gl.StartDriver(appMain)
}