widget/material: add support for disabled buttons

This leverages the new semantics of a disabled layout.Context
to draw all of the button types in a disabled state.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2020-06-02 16:23:48 -04:00
committed by Elias Naur
parent 3a31045dc9
commit cc5f8fcffe
+10 -2
View File
@@ -129,7 +129,11 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di
}},
NE: rr, NW: rr, SE: rr, SW: rr,
}.Op(gtx.Ops).Add(gtx.Ops)
dims := fill(gtx, b.Background)
background := b.Background
if gtx.Queue == nil {
background = mulAlpha(b.Background, 150)
}
dims := fill(gtx, background)
for _, c := range b.Button.History() {
drawInk(gtx, c)
}
@@ -155,7 +159,11 @@ func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
Rect: f32.Rectangle{Max: f32.Point{X: sizef, Y: sizef}},
NE: rr, NW: rr, SE: rr, SW: rr,
}.Op(gtx.Ops).Add(gtx.Ops)
dims := fill(gtx, b.Background)
background := b.Background
if gtx.Queue == nil {
background = mulAlpha(b.Background, 150)
}
dims := fill(gtx, background)
for _, c := range b.Button.History() {
drawInk(gtx, c)
}