Skip to content

fix(widget): centre the Button label instead of on the bottom border - #3

Merged
tannevaled merged 1 commit into
mainfrom
button-center-label
Jul 9, 2026
Merged

fix(widget): centre the Button label instead of on the bottom border#3
tannevaled merged 1 commit into
mainfrom
button-center-label

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Button.Draw placed the label at Y+2, which is the bottom border row of a short (3/4-tall) cell button — it rendered as └─OK──┘, contradicting the type's own "centred label" doc. This surfaced in go-widgets/tui's tui-snapshot demo.

Draw the label at the middle row (Y+(H-1)/2) — the exact centre in cell mode and an acceptable vertical centre in pixel mode — keeping the backend-agnostic four-line-widget shape. Adds a cell-mode regression test asserting the label is on the centre row and the bottom border is left intact.

100% coverage; go vet clean; cross-compiles js/wasm + linux/arm64. No golden tests in the repo; the affected consumers (tui-demo, wui-demo, wui-wasm) get a more-centred label, matching the documented intent.

🤖 Generated with Claude Code

Button.Draw placed the label at Y+2, which is the bottom border row of a
short (3/4-tall) cell button — it rendered as "└─OK──┘" — contradicting
the type's own "centred label" doc. Draw at the middle row (Y+(H-1)/2):
the exact centre in cell mode and an acceptable vertical centre in pixel
mode, keeping the backend-agnostic four-line-widget shape. Adds a
cell-mode regression test asserting the label is on the centre row and
the bottom border is intact. 100% coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit fc60403 into main Jul 9, 2026
1 of 2 checks passed
@tannevaled
tannevaled deleted the button-center-label branch July 9, 2026 09:24
tannevaled added a commit to go-widgets/tui that referenced this pull request Jul 9, 2026
Picks up go-widgets/painter#3: painter.Button now draws its label on the
button's centre row instead of the bottom border. Visible in tui-snapshot
— the buttons now render '│ OK       │' with the border intact, not
'└─OK───────┘'.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant