github.com/gop9/olt@v0.0.0-20200202132135-d956aad50b08/gio/widget/material/radiobutton.go (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 package material 4 5 import ( 6 "github.com/gop9/olt/gio/layout" 7 "github.com/gop9/olt/gio/text" 8 "github.com/gop9/olt/gio/unit" 9 "github.com/gop9/olt/gio/widget" 10 ) 11 12 type RadioButton struct { 13 checkable 14 Key string 15 } 16 17 // RadioButton returns a RadioButton with a label. The key specifies 18 // the value for the Enum. 19 func (t *Theme) RadioButton(key, label string) RadioButton { 20 return RadioButton{ 21 checkable: checkable{ 22 Label: label, 23 24 Color: t.Color.Text, 25 IconColor: t.Color.Primary, 26 Font: text.Font{ 27 Size: t.TextSize.Scale(14.0 / 16.0), 28 }, 29 Size: unit.Dp(26), 30 shaper: t.Shaper, 31 checkedStateIcon: t.radioCheckedIcon, 32 uncheckedStateIcon: t.radioUncheckedIcon, 33 }, 34 Key: key, 35 } 36 } 37 38 func (r RadioButton) Layout(gtx *layout.Context, enum *widget.Enum) { 39 r.layout(gtx, enum.Value(gtx) == r.Key) 40 enum.Layout(gtx, r.Key) 41 }