widget/material: add hover to Button

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2021-01-17 17:51:57 +02:00
committed by Elias Naur
parent 93ebd51531
commit 468bd6f53a
2 changed files with 19 additions and 2 deletions
+8 -2
View File
@@ -128,8 +128,11 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di
Y: float32(gtx.Constraints.Min.Y),
}}, rr).Add(gtx.Ops)
background := b.Background
if gtx.Queue == nil {
switch {
case gtx.Queue == nil:
background = f32color.Disabled(b.Background)
case b.Button.Hovered():
background = f32color.Hovered(b.Background)
}
paint.Fill(gtx.Ops, background)
for _, c := range b.Button.History() {
@@ -155,8 +158,11 @@ func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
Max: f32.Point{X: sizexf, Y: sizeyf},
}, rr).Add(gtx.Ops)
background := b.Background
if gtx.Queue == nil {
switch {
case gtx.Queue == nil:
background = f32color.Disabled(b.Background)
case b.Button.Hovered():
background = f32color.Hovered(b.Background)
}
paint.Fill(gtx.Ops, background)
for _, c := range b.Button.History() {