-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwolabels2.go
41 lines (37 loc) · 892 Bytes
/
twolabels2.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
package main
import (
"gioui.org/app"
"gioui.org/f32"
"gioui.org/font/gofont"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget/material"
)
func main() {
go func() {
w := app.NewWindow()
th := material.NewTheme(gofont.Collection())
var ops op.Ops
// START OMIT
for e := range w.Events() {
if e, ok := e.(system.FrameEvent); ok {
gtx := layout.NewContext(&ops, e)
drawLabels(gtx, th) // HLdraw
e.Frame(gtx.Ops)
}
}
// END OMIT
}()
app.Main()
}
// START DRAW OMIT
func drawLabels(gtx layout.Context, th *material.Theme) {
gtx.Constraints.Min.Y = 0 // HLdraw
dimensions := material.H1(th, "One label").Layout(gtx) // HLdraw
op.Affine(f32.Affine2D{}.Offset(f32.Point{
Y: float32(dimensions.Size.Y), // HLdraw
})).Add(gtx.Ops)
material.H1(th, "Another label").Layout(gtx)
}
// END DRAW OMIT