cmd/tailscale: replace manual border widget with gioui.org/widget.Border

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/3/head
Elias Naur 4 years ago
parent 878e6e75df
commit 3f469f3f8a

@ -494,9 +494,8 @@ func (ui *UI) layoutMenu(gtx layout.Context, sysIns system.Insets, expiry time.T
Right: unit.Add(gtx.Metric, sysIns.Right, unit.Dp(2)), Right: unit.Add(gtx.Metric, sysIns.Right, unit.Dp(2)),
}.Layout(gtx, func(gtx C) D { }.Layout(gtx, func(gtx C) D {
return layout.NE.Layout(gtx, func(gtx C) D { return layout.NE.Layout(gtx, func(gtx C) D {
return Background{Color: argb(0x33000000), CornerRadius: unit.Dp(2)}.Layout(gtx, func(gtx C) D { return widget.Border{Color: argb(0x33000000), CornerRadius: unit.Dp(2), Width: unit.Px(1)}.Layout(gtx, func(gtx C) D {
return layout.UniformInset(unit.Px(1)).Layout(gtx, func(gtx C) D { return Background{Color: rgb(0xfafafa), CornerRadius: unit.Dp(2)}.Layout(gtx, func(gtx C) D {
return Background{Color: rgb(0xfafafa), CornerRadius: unit.Px(4)}.Layout(gtx, func(gtx C) D {
menu := &ui.menu menu := &ui.menu
items := []struct { items := []struct {
btn *widget.Clickable btn *widget.Clickable
@ -567,7 +566,6 @@ func (ui *UI) layoutMenu(gtx layout.Context, sysIns system.Insets, expiry time.T
}) })
}) })
}) })
})
} }
func (ui *UI) layoutMessage(gtx layout.Context, sysIns system.Insets) layout.Dimensions { func (ui *UI) layoutMessage(gtx layout.Context, sysIns system.Insets) layout.Dimensions {
@ -855,7 +853,6 @@ func drawDisc(ops *op.Ops, radius float32, col color.RGBA) {
type Background struct { type Background struct {
Color color.RGBA Color color.RGBA
CornerRadius unit.Value CornerRadius unit.Value
CornerRadius2 float32
} }
func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions { func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
@ -874,16 +871,6 @@ func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimension
NE: rr, NW: rr, SE: rr, SW: rr, NE: rr, NW: rr, SE: rr, SW: rr,
}.Add(gtx.Ops) }.Add(gtx.Ops)
} }
if r := b.CornerRadius2; r > 0 {
rr := float32(r)
clip.RRect{
Rect: f32.Rectangle{Max: f32.Point{
X: float32(sz.X),
Y: float32(sz.Y),
}},
NE: rr, NW: rr, SE: rr, SW: rr,
}.Add(gtx.Ops)
}
fill{b.Color}.Layout(gtx, sz) fill{b.Color}.Layout(gtx, sz)
call.Add(gtx.Ops) call.Add(gtx.Ops)
return dims return dims

Loading…
Cancel
Save