ui: Fix background color of exit node status. (#75)

Prior to https://github.com/tailscale/tailscale-android/pull/73/,
the exit node status pane was set to a background color using:
    paint.Fill(gtx.Ops, bg)

paint.Fill() is documented to fill the entire clipped area.
It assumes that one has already applied a clip area... but
no clip area had been set in this code path.

As far as I can tell, that this worked prior to pull #73
was a bug, something had a side-effect of setting a clipping
rectangle.

We updated to the head of the Gio repo, which apparently fixed
that bug. After pull #73, the paint.Fill() painted the entire
app window.

Fix this using a stacked layout. A color filled widget is the
lower layer, and will expand to the size of the widget sitting
atop of it.

Fixes https://github.com/tailscale/tailscale/issues/6873

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
sonos
Denton Gentry 2 years ago committed by GitHub
parent a0f2c883b4
commit 365b0ce6b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -668,9 +668,20 @@ func (ui *UI) layoutExitStatus(gtx layout.Context, state *BackendState) layout.D
text = "Using exit node" text = "Using exit node"
bg = rgb(0x338b51) bg = rgb(0x338b51)
} }
paint.Fill(gtx.Ops, bg)
return material.Clickable(gtx, &ui.openExitDialog, func(gtx C) D { return material.Clickable(gtx, &ui.openExitDialog, func(gtx C) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X gtx.Constraints.Min.X = gtx.Constraints.Max.X
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
sz := image.Point{
X: gtx.Constraints.Min.X,
Y: gtx.Constraints.Min.Y,
}
defer clip.Rect(image.Rectangle{Max: sz}).Push(gtx.Ops).Pop()
paint.ColorOp{Color: bg}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
return layout.Dimensions{Size: sz}
}),
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
return layout.Inset{ return layout.Inset{
Top: unit.Dp(12), Top: unit.Dp(12),
Bottom: unit.Dp(12), Bottom: unit.Dp(12),
@ -697,6 +708,8 @@ func (ui *UI) layoutExitStatus(gtx layout.Context, state *BackendState) layout.D
}), }),
) )
}) })
}),
)
}) })
} }

Loading…
Cancel
Save