widget,widget/material: remove disabled drawing modes

Determining the enabled state of a widget from whether its Clicked method has
been called only works for button-like widgets. For example, it's not clear a
Clicked method is appropriate for a CheckBox.

Remove the feature for now, and let's find a better design in the future.

As a nice side effect, we can now process events in Layout methods, so that
buttons react to user input even when Clicked is not called.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-02 12:27:56 +01:00
parent 06aa0da2a2
commit 4107485902
4 changed files with 60 additions and 61 deletions
-7
View File
@@ -78,10 +78,6 @@ func (t *Theme) IconButton(icon *Icon) IconButton {
func (b Button) Layout(gtx *layout.Context, button *widget.Button) {
col := b.Color
bgcol := b.Background
if !button.Active() {
col = rgb(0x888888)
bgcol = rgb(0xcccccc)
}
st := layout.Stack{Alignment: layout.Center}
hmin := gtx.Constraints.Width.Min
vmin := gtx.Constraints.Height.Min
@@ -128,9 +124,6 @@ func (b IconButton) Layout(gtx *layout.Context, button *widget.Button) {
button.Layout(gtx)
})
bgcol := b.Background
if !button.Active() {
bgcol = rgb(0xcccccc)
}
bg := st.Expand(gtx, func() {
size := float32(gtx.Constraints.Width.Min)
rr := float32(size) * .5