From cc5f8fcffe5e57c0f17b5475d5129ac5cd23572a Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Tue, 2 Jun 2020 16:23:48 -0400 Subject: [PATCH] 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 --- widget/material/button.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/widget/material/button.go b/widget/material/button.go index 0d28e537..f69d30fe 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -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) }