Skip to content

#1998 Auto-size the macro-block command box to its content - #2001

Merged
TimothyLuke merged 2 commits into
TimothyLuke:masterfrom
LarryThiessen:fix-1998-macro-box-autofit
Aug 22, 2026
Merged

#1998 Auto-size the macro-block command box to its content#2001
TimothyLuke merged 2 commits into
TimothyLuke:masterfrom
LarryThiessen:fix-1998-macro-box-autofit

Conversation

@LarryThiessen

Copy link
Copy Markdown
Contributor

Fixes #1998

Change (1 file, Editor.lua)

The "Macro Name or Macro Commands" box was a fixed 5 rows. FitMacroEditBoxToContent now measures the rendered text height with a hidden FontString in the box's own font (wraps included — row×font-size estimates drifted by a row), clamps to 5..24 rows, ignores a stored trailing newline except while the author is typing on that last row (so Enter at the bottom still opens the new row), and dedupes on the resulting height. Runs once after the block body is assembled and on every text change.

The box sits under explicit-height containers (macrolayout, macroFields, macroBody — sized for the old 108px box), so the fit pushes the height delta up through every fixed-height ancestor before auto-height ones re-lay out; without that the box grew but overlapped the Repeat Interval row.

Verified

In-game: exact row count, no spare row, block grows/shrinks live, no overlap. luac -p clean.

🤖 Generated with Claude Code

LarryThiessen and others added 2 commits August 21, 2026 20:39
The "Macro Name or Macro Commands" box was a fixed 5 rows, so a 7-8 line
block always scrolled. FitMacroEditBoxToContent measures the rendered
text height with a hidden FontString in the box's own font (wraps
included; estimating rows x font size drifted by a row), clamps to 5..24
rows, ignores a stored trailing newline except while the author is
typing on that last row, and dedupes on the resulting height. It runs
once after the block body is assembled and on every text change.

Because the box sits under explicit-height containers (macrolayout,
macroFields, macroBody, sized for the old 108px box), the fit pushes the
height delta up through every fixed-height ancestor before auto-height
ones re-lay out -- otherwise the box grew but overlapped the Repeat
Interval row below it.

Fixes TimothyLuke#1998

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… spacing

Drop MACRO_BOX_MIN_LINES to 3 so a short block stops reserving five rows.

The minimum was doing double duty as the widget's build height, and that
height is load-bearing: NativeUI's SetNumLines(n) is n * 16 +
STYLE.frameContentTop (28), so five rows IS macrolayout's SetHeight(108),
and the fit pushes the DELTA from that baseline up through the
fixed-height ancestors.  Lowering the shared constant would have built the
box at 76 against a 108 container and left ~32px of dead space under every
block, so the build height is now its own MACRO_BOX_BASE_LINES = 5 with
the arithmetic written down at both sites.

Two font-size gaps the smaller minimum exposes:

- oneRow is measured from a single "X" and so carries no line spacing, but
  the row clamps multiplied it straight out.  Real N-row text is
  N * oneRow + (N - 1) * spacing, so with a nonzero GetSpacing() the min
  clamp fell short of a true N rows and clipped the bottom one.
- NativeUI clamps the inner editbox to 40px (updateEditBoxSize).  Five
  rows always cleared it; three rows at a small chat font do not, and the
  last row would render outside the visible scroll area.  The frame is
  never asked for less than that floor now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JaKGoo9zcWMDowDLy4cAbX
@TimothyLuke
TimothyLuke merged commit f18e6ce into TimothyLuke:master Aug 22, 2026
1 check passed
@LarryThiessen
LarryThiessen deleted the fix-1998-macro-box-autofit branch August 22, 2026 23:23
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.

[ENH] Macro block command box auto-sizes to its content instead of a fixed 5 rows

2 participants