mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
widget: [API] add content widget parameter to Enum.Layout
To make the semantic relation between the enum widget and its content, the content must be laid out inside the enum clip rect. This is an API change. Users of Enum.Layout must provide a content widget. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -3,10 +3,7 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
)
|
||||
@@ -40,9 +37,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 {
|
||||
hovered, hovering := r.Group.Hovered()
|
||||
dims := r.layout(gtx, r.Group.Value == r.Key, hovering && hovered == r.Key)
|
||||
defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
|
||||
gtx.Constraints.Min = dims.Size
|
||||
r.Group.Layout(gtx, r.Key)
|
||||
return dims
|
||||
return r.Group.Layout(gtx, r.Key, func(gtx layout.Context) layout.Dimensions {
|
||||
return r.layout(gtx, r.Group.Value == r.Key, hovering && hovered == r.Key)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user