Fix Gio card and button layout
This commit is contained in:
@@ -970,18 +970,8 @@ func (u *ui) layoutButton(gtx layout.Context, btn *widget.Clickable, label strin
|
||||
|
||||
func (u *ui) buttonLike(gtx layout.Context, btn *widget.Clickable, label string, bg, fg color.NRGBA, hPad, vPad unit.Dp) layout.Dimensions {
|
||||
return btn.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
min := image.Pt(gtx.Dp(unit.Dp(96)), gtx.Dp(unit.Dp(40)))
|
||||
if gtx.Constraints.Min.X < min.X {
|
||||
gtx.Constraints.Min.X = min.X
|
||||
}
|
||||
if gtx.Constraints.Min.Y < min.Y {
|
||||
gtx.Constraints.Min.Y = min.Y
|
||||
}
|
||||
|
||||
rr := gtx.Dp(unit.Dp(14))
|
||||
defer clip.RRect{Rect: image.Rectangle{Max: gtx.Constraints.Min}, NW: rr, NE: rr, SW: rr, SE: rr}.Push(gtx.Ops).Pop()
|
||||
paint.Fill(gtx.Ops, bg)
|
||||
return layout.Inset{
|
||||
macro := op.Record(gtx.Ops)
|
||||
dims := layout.Inset{
|
||||
Top: vPad,
|
||||
Bottom: vPad,
|
||||
Left: hPad,
|
||||
@@ -994,20 +984,34 @@ func (u *ui) buttonLike(gtx layout.Context, btn *widget.Clickable, label string,
|
||||
return lbl.Layout(gtx)
|
||||
})
|
||||
})
|
||||
call := macro.Stop()
|
||||
|
||||
minSize := image.Pt(gtx.Dp(unit.Dp(96)), gtx.Dp(unit.Dp(40)))
|
||||
if dims.Size.X < minSize.X {
|
||||
dims.Size.X = minSize.X
|
||||
}
|
||||
if dims.Size.Y < minSize.Y {
|
||||
dims.Size.Y = minSize.Y
|
||||
}
|
||||
|
||||
rr := gtx.Dp(unit.Dp(14))
|
||||
defer clip.RRect{Rect: image.Rectangle{Max: dims.Size}, NW: rr, NE: rr, SW: rr, SE: rr}.Push(gtx.Ops).Pop()
|
||||
paint.Fill(gtx.Ops, bg)
|
||||
call.Add(gtx.Ops)
|
||||
return dims
|
||||
})
|
||||
}
|
||||
|
||||
func (u *ui) card(gtx layout.Context, bg color.NRGBA, content layout.Widget) layout.Dimensions {
|
||||
return layout.Stack{}.Layout(
|
||||
gtx,
|
||||
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
||||
rr := gtx.Dp(unit.Dp(20))
|
||||
defer clip.RRect{Rect: image.Rectangle{Max: gtx.Constraints.Max}, NW: rr, NE: rr, SW: rr, SE: rr}.Push(gtx.Ops).Pop()
|
||||
paint.Fill(gtx.Ops, bg)
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}),
|
||||
layout.Stacked(content),
|
||||
)
|
||||
macro := op.Record(gtx.Ops)
|
||||
dims := content(gtx)
|
||||
call := macro.Stop()
|
||||
|
||||
rr := gtx.Dp(unit.Dp(20))
|
||||
defer clip.RRect{Rect: image.Rectangle{Max: dims.Size}, NW: rr, NE: rr, SW: rr, SE: rr}.Push(gtx.Ops).Pop()
|
||||
paint.Fill(gtx.Ops, bg)
|
||||
call.Add(gtx.Ops)
|
||||
return dims
|
||||
}
|
||||
|
||||
func fill(gtx layout.Context, c color.NRGBA) {
|
||||
|
||||
Reference in New Issue
Block a user