mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-08 02:45:38 +00:00
widget/material: use constraint minimums for background fills
This commit is contained in:
@@ -94,8 +94,8 @@ func (b Button) Layout(gtx *layout.Context, button *widget.Button) {
|
|||||||
bg := st.Expand(gtx, func() {
|
bg := st.Expand(gtx, func() {
|
||||||
rr := float32(gtx.Px(unit.Dp(4)))
|
rr := float32(gtx.Px(unit.Dp(4)))
|
||||||
rrect(gtx.Ops,
|
rrect(gtx.Ops,
|
||||||
float32(gtx.Constraints.Width.Max),
|
float32(gtx.Constraints.Width.Min),
|
||||||
float32(gtx.Constraints.Height.Max),
|
float32(gtx.Constraints.Height.Min),
|
||||||
rr, rr, rr, rr,
|
rr, rr, rr, rr,
|
||||||
)
|
)
|
||||||
fill(gtx, bgcol)
|
fill(gtx, bgcol)
|
||||||
@@ -130,7 +130,7 @@ func (b IconButton) Layout(gtx *layout.Context, button *widget.Button) {
|
|||||||
bgcol.A = 0xaa
|
bgcol.A = 0xaa
|
||||||
}
|
}
|
||||||
bg := st.Expand(gtx, func() {
|
bg := st.Expand(gtx, func() {
|
||||||
size := float32(gtx.Constraints.Width.Max)
|
size := float32(gtx.Constraints.Width.Min)
|
||||||
rr := float32(size) * .5
|
rr := float32(size) * .5
|
||||||
rrect(gtx.Ops,
|
rrect(gtx.Ops,
|
||||||
size,
|
size,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func argb(c uint32) color.RGBA {
|
|||||||
|
|
||||||
func fill(gtx *layout.Context, col color.RGBA) {
|
func fill(gtx *layout.Context, col color.RGBA) {
|
||||||
cs := gtx.Constraints
|
cs := gtx.Constraints
|
||||||
d := image.Point{X: cs.Width.Max, Y: cs.Height.Max}
|
d := image.Point{X: cs.Width.Min, Y: cs.Height.Min}
|
||||||
dr := f32.Rectangle{
|
dr := f32.Rectangle{
|
||||||
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user