widget/material: add disabled state support to all widgets

This commit configures all remaining widgets to draw themselves in a disabled state
when their layout.Context is disabled. A description of the
strategy employed by each follows:

- Checkbox and RadioButton: Draws the icon component in a lighter color. Currently the label text is left
in its default color.
- ProgressBar: The "progress" color is lightened, but not as much as the background color. This makes the current progress value still readable.
- Editor: The cursor is no longer drawn and the text is lightened.
- Switch: The track is unchanged, but the circular "thumb" component is lightened.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2020-06-09 07:26:30 -04:00
committed by Elias Naur
parent feacd1e2df
commit 9f6e09317d
4 changed files with 27 additions and 7 deletions
+3
View File
@@ -41,6 +41,9 @@ func (c *checkable) layout(gtx layout.Context, checked bool) layout.Dimensions {
return layout.UniformInset(unit.Dp(2)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
size := gtx.Px(c.Size)
icon.Color = c.IconColor
if gtx.Queue == nil {
icon.Color = mulAlpha(icon.Color, 150)
}
icon.Layout(gtx, unit.Px(float32(size)))
return layout.Dimensions{
Size: image.Point{X: size, Y: size},