widget,widget/material: remove Color field from Icon

Icons are meant to be shared among multiple widgets, but their Color
state may end up with unexpected values after use. Replace the state
with and explicit argument to Layout.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-07-28 14:19:39 +02:00
parent ea38195e2e
commit 6e9bb7b91c
4 changed files with 15 additions and 17 deletions
+3 -3
View File
@@ -19,14 +19,14 @@ func TestIcon_Alpha(t *testing.T) {
t.Fatal(err)
}
icon.Color = color.NRGBA{B: 0xff, A: 0x40}
col := color.NRGBA{B: 0xff, A: 0x40}
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
}
_ = icon.Layout(gtx)
_ = icon.Layout(gtx, col)
}
// TestWidgetConstraints tests that widgets returns dimensions within their constraints.
@@ -41,7 +41,7 @@ func TestWidgetConstraints(t *testing.T) {
label: "Icon",
widget: func(gtx layout.Context) layout.Dimensions {
ic, _ := NewIcon(icons.ToggleCheckBox)
return ic.Layout(gtx)
return ic.Layout(gtx, color.NRGBA{A: 0xff})
},
constraints: _cs(
layout.Constraints{