Layout improvements: do not draw the stopwatch if there is not
enough room for it.
This commit is contained in:
parent
31fa374c7f
commit
6e020858d9
27
main.go
27
main.go
|
@ -300,10 +300,8 @@ func eventloop() {
|
|||
}
|
||||
|
||||
swidth := new(int)
|
||||
*swidth = 900
|
||||
hrpage = func() {
|
||||
stopbtn := func() {
|
||||
gtx.Constraints.Width.Min = *swidth
|
||||
gtx.Constraints.Height.Min = 100
|
||||
layout.UniformInset(unit.Dp(2)).Layout(gtx, func() {
|
||||
th.Button("Disconnect").Layout(gtx, backBtn)
|
||||
|
@ -325,7 +323,10 @@ func eventloop() {
|
|||
*swidth = s2
|
||||
}
|
||||
})
|
||||
c3 := f3.Rigid(gtx, stopwatch)
|
||||
var c3 layout.FlexChild
|
||||
if gtx.Constraints.Width.Max > 370 {
|
||||
c3 = f3.Rigid(gtx, stopwatch)
|
||||
}
|
||||
c4 := f3.Rigid(gtx, stopbtn)
|
||||
f3.Layout(gtx,
|
||||
c1,
|
||||
|
@ -346,9 +347,26 @@ func eventloop() {
|
|||
stopwatch()
|
||||
})
|
||||
})
|
||||
swheight := gtx.Dimensions.Size.Y
|
||||
c2 := f.Rigid(gtx, func() {
|
||||
layout.Align(layout.Center).Layout(gtx, stopbtn)
|
||||
layout.Align(layout.Center).Layout(gtx, func() {
|
||||
gtx.Constraints.Width.Min = *swidth
|
||||
gtx.Constraints.Width.Max = *swidth
|
||||
stopbtn()
|
||||
})
|
||||
})
|
||||
if gtx.Constraints.Height.Max < 775 {
|
||||
gtx.Constraints.Height.Max += swheight
|
||||
f.Layout(gtx,
|
||||
f.Rigid(gtx, appname),
|
||||
f.Rigid(gtx, appstate),
|
||||
f.Rigid(gtx, periphname),
|
||||
f.Flex(gtx, 1.0, func() {
|
||||
*swidth = hrcircle()
|
||||
}),
|
||||
c2,
|
||||
)
|
||||
} else {
|
||||
f.Layout(gtx,
|
||||
f.Rigid(gtx, appname),
|
||||
f.Rigid(gtx, appstate),
|
||||
|
@ -360,6 +378,7 @@ func eventloop() {
|
|||
c2,
|
||||
)
|
||||
}
|
||||
}
|
||||
if backBtn.Clicked(gtx) {
|
||||
ble.Disconnect(periph)
|
||||
periphs = periphs[:0]
|
||||
|
|
Loading…
Reference in New Issue
Block a user