From 7268b11e5d80bfacd5a9362c9580c72609333d08 Mon Sep 17 00:00:00 2001 From: administrator Date: Mon, 6 Apr 2026 09:08:42 +0700 Subject: [PATCH] Fix Gio card and button layout --- internal/gui/app.go | 48 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/internal/gui/app.go b/internal/gui/app.go index c58e531..e3583b3 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -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) {