~eliasnaur/gio

bc6798c4ca15d9b0deb9dc8bdf9aa5ae8cbd5e6f — Egon Elbre 5 months ago 0b73699
widget/material: add hovered to RadioButton

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2 files changed, 9 insertions(+), 2 deletions(-)

M widget/enum.go
M widget/material/radiobutton.go
M widget/enum.go => widget/enum.go +8 -1
@@ 10,7 10,8 @@ import (
)

type Enum struct {
	Value string
	Value   string
	Hovered string

	changed bool



@@ 56,6 57,12 @@ func (e *Enum) Layout(gtx layout.Context, key string) layout.Dimensions {
				}
			}
		}
		if e.Hovered == key {
			e.Hovered = ""
		}
		if clk.Hovered() {
			e.Hovered = key
		}
		clk.Add(gtx.Ops)
	}


M widget/material/radiobutton.go => widget/material/radiobutton.go +1 -1
@@ 36,7 36,7 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt

// Layout updates enum and displays the radio button.
func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
	dims := r.layout(gtx, r.Group.Value == r.Key, false)
	dims := r.layout(gtx, r.Group.Value == r.Key, r.Group.Hovered == r.Key)
	gtx.Constraints.Min = dims.Size
	r.Group.Layout(gtx, r.Key)
	return dims