From e788e61613b3f8fd65af47df107431468e7ded1e Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Fri, 20 Nov 2026 17:55:02 +0000 Subject: [PATCH] Nudge the server tag to between centred and the baseline Centred on the name's full height, the tag looked high beside a name that is mostly lower case; on the name's baseline, it looked low. It is now centred, then moved down 2dp, which balances it on the word: its top a little above the lower-case letters, its bottom a little below the baseline. Chosen from renders at 0 to 4dp. --- internal/ui/server.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/ui/server.go b/internal/ui/server.go index fdd7102..68dc3d0 100644 --- a/internal/ui/server.go +++ b/internal/ui/server.go @@ -16,6 +16,7 @@ import ( "gioui.org/layout" "gioui.org/op" "gioui.org/op/clip" + "gioui.org/unit" "gioui.org/widget" "100gex/internal/theme" @@ -97,6 +98,9 @@ func (u *UI) startedAt() (time.Time, bool) { return t, err == nil } +// chipTagNudge moves the server tag down from centred on the name. +var chipTagNudge unit.Dp = 2 + // layoutServerChip draws the server's name as the sidebar's heading, with // a tag saying where it is, or that it's offline. A click opens its card. func (u *UI) layoutServerChip(gtx layout.Context) layout.Dimensions { @@ -120,11 +124,12 @@ func (u *UI) layoutServerChip(gtx layout.Context) layout.Dimensions { gtx.Constraints.Min = image.Point{} return layout.Inset{Left: 16, Right: 16}.Layout(gtx, func(gtx layout.Context) layout.Dimensions { return u.server.click.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - // The tag's text sits on the name's baseline, as words on - // one line do. Centring the boxes instead puts the tag - // high, beside a name that is mostly lower case. + // The tag is centred on the name, then nudged down: centred + // on the name's full height it looks high beside a name + // that is mostly lower case, and on the name's baseline, + // low. m := op.Record(gtx.Ops) - dims := layout.Flex{Alignment: layout.Baseline}.Layout(gtx, + dims := layout.Flex{Alignment: layout.Middle}.Layout(gtx, layout.Rigid(func(gtx layout.Context) layout.Dimensions { // Leave room for the tag; a long name truncates. gtx.Constraints.Max.X -= gtx.Dp(70) @@ -132,6 +137,7 @@ func (u *UI) layoutServerChip(gtx layout.Context) layout.Dimensions { }), layout.Rigid(layout.Spacer{Width: 8}.Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { + defer op.Offset(image.Pt(0, gtx.Dp(chipTagNudge))).Push(gtx.Ops).Pop() return theme.Tag(gtx, u.theme, tag, tagFill, tagFg) }), ) -- knotmirror 0.0.1