Skip to content

Fix text field capacity aborts, TabPanel hidden-strip tab loss, StickyHeaderList click-through and DividerContainer gaps - #729

Merged
matt-edmondson merged 5 commits into
mainfrom
claude/project-thread-p6t7fo
Oct 26, 2026
Merged

matt-edmondson merged 5 commits into
mainfrom
claude/project-thread-p6t7fo

Conversation

@matt-edmondson

@matt-edmondson matt-edmondson commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Certified Turtle · project thread

Four bug fixes, one commit each. A fifth commit reworks the #553 helper so it has no pointer code, for SonarCloud's security rating.

Text fields no longer abort the process on long values

Fixes #553

  • Cause: Hexa's InputText(label, ref string, maxLength) allocates room for the larger of the string and maxLength, plus the terminator. It then tells ImGui the buffer is only maxLength bytes. When a field was activated with a value at or past a fixed maxLength, ImGui's assertion failed and the process aborted.

  • Fix: a new internal helper, ResizableInputText (ImGui.Widgets/ResizableInputText.cs), in managed code only, with no unsafe or pointers. It calls Hexa's managed overloads with a capacity worked out every frame from the value's UTF-8 length:

    • the value
    • its terminator
    • headroom of 1024 bytes or the value's own length, whichever is larger

    The value always fits, so no value is too long to activate.

  • Trade-off: Dear ImGui fixes a field's capacity when the field is activated, and doesn't take a larger one while it stays active. I measured this: a second 1000-character paste into a field that started empty stopped at 1025 characters. So one edit can add at most the headroom. Text beyond that is cut, not an abort, and the next edit gets headroom again. Lifting this limit would need a CallbackResize native buffer, which is pointer code. The first version of this PR used one, and SonarCloud's security rating failed it.

  • Where it's used: every fixed-capacity string field in the libraries now goes through the helper. No InputText/InputTextWithHint call with a fixed length is left.

    • DataTableEditors. Its existing caret callback is kept.
    • PropertyGrid text, path and list rows
    • SearchBox
    • ValueSlider's editor
    • TimecodeField
    • PinInput
    • The node editor's string pin editor and comment rename box
    • InputString
    • SearchableList
    • FilesystemBrowser's path box, search box and file name box
  • ImGui.Popups doesn't reference ImGui.Widgets, so it links the helper's source file. It needs no AllowUnsafeBlocks.

  • Follow-on fix: the old 256-byte name box stopped anyone typing a file name too long for the system. Such a name now reaches the browser, and the browser used to throw out of the frame when building the path. TryGetFullPath now refuses it with an "Invalid File Name" message.

  • Tests:

    • DataTable, and PropertyGrid's text, path and list rows: a 1500-character ASCII value, a 400-character CJK value, and a value exactly at the old capacity, each extended by typing.
    • SearchBox: the same three cases. Also, a 5000-character paste is cut to the 1024-byte headroom, and three successive 1000-character edits each have room.
    • ValueSlider: a 100-character unit.
    • Node editor: a 600-character string pin and a 400-character comment title.
    • InputString: 1500 ASCII characters, 400 CJK characters, and 99 characters.
    • SearchableList: a 400-character search.
    • FilesystemBrowser: a path over 1024 bytes entered in one edit, a 304-byte CJK file name, a 300-character search, and a too-long name refused without throwing.

TabPanel keeps its tab when ShowTabStrip is off

Fixes #711

  • While the strip is hidden, the panel keeps requesting the active tab. The first frame the strip is visible again selects that tab, so it doesn't revert.
  • RemoveTab keeps the same tab active when an earlier tab is removed. When the active tab itself is removed, it moves to its neighbour. Either way it tells a visible strip too.
  • Every change of active tab is now reported once through one helper, keyed by tab id. That covers a click, ActiveTabIndex and RemoveTab. A hidden strip now reports picks, and a tab that only moved index reports nothing.
  • Behaviour change: setting ActiveTabIndex while the strip is shown now raises TabChanged once, when the tab is drawn. It previously raised nothing.
  • Tests: six new UI tests in TabPanelTests: the issue's three scenarios, a pick under a hidden strip, removing the active tab, and removing an earlier tab with the strip shown.

StickyHeaderList's pinned header blocks clicks to the rows under it

Fixes #712

  • The list remembers last frame's pinned rectangle. Before any row is submitted, it places an InvisibleButton there for the left, right and middle mouse buttons, then restores the cursor.
  • The header is still painted in Dispose.
  • Tests: clicking the pinned header over full-width buttons clicks none of them, and a row below the header still takes clicks.

DividerContainer gaps are uniform

Fixes #724

  • Layout model: the ImGui-free DividerContainerLayout uses the uniform-gap model from the issue:
    • n zones cost n × gap.
    • A whole gap sits between zones, and half a gap at each end.
    • Every edge is rounded once, from its exact position.
    • Each divider sits in the middle of its gap.
    • Dragging uses the inverse calculation, so the divider follows the pointer.
  • The gap is the window padding along the container's axis.
  • The container no longer scrolls or shows a scrollbar.
  • A single zone still fills the container.
  • Tests:
    • New unit tests in DividerContainerLayoutTests.
    • New UI tests in DividerContainerTests, each run in both Columns and Rows: 3 zones, 2 even zones and 5 zones, checking equal gaps, equal outer margins and centred dividers. These fail on the old code.
    • A test that drags the second of three dividers.

CLAUDE.md has new Key Files entries for both new files.

Tests run

Built with dotnet build -c Release: 0 errors. Results are from each suite's built test executable, in Release, run after the managed rework:

Suite Result
ImGui.Widgets.UITests 1055/1055 passed
ImGui.Widgets.Tests 1340/1340 passed
ImGui.Popups.Tests 55 passed, 1 skipped (pre-existing), 0 failed
ImGui.NodeEditor.Tests 288/288 passed
ImGuiPopupsDemo.UITests 65/65 passed
ImGuiWidgetsDemo.UITests 74/74 passed
ImGuiAppDemo.UITests 35/35 passed
WidgetGallery.UITests (includes --check) 6/6 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ

A tab picked while ShowTabStrip is off is now asked of the strip's first visible frame, so showing the strip again no longer reverts to the tab Dear ImGui last had selected. RemoveTab keeps the same tab active when an earlier one goes and moves to the active tab's neighbour when it goes itself, telling a visible strip too. Every change of active tab is reported once through one helper, keyed by tab id, whether it came from a click, ActiveTabIndex or RemoveTab, so a hidden strip reports picks and a tab that only moved index reports nothing.

Fixes #711

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ
…eneath it

The pinned header is painted over the rows once they are all submitted, but Dear ImGui gives the pointer to the first item submitted under it, so the hidden row was hovered and clicked through the header. The list now remembers where its header was pinned last frame and submits an invisible button there before any row.

Fixes #712

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ
…t or layout

Zones now share what is left once n gaps are taken out: a whole gap between two zones and half of one at each end, every edge rounded once from its exact position, and each divider in the middle of its gap. The arithmetic lives in the ImGui-free DividerContainerLayout, which also gives a drag the fraction that puts the divider under the pointer. The gap follows the window padding along the container's axis, and the container no longer scrolls or shows a scrollbar for the cursor its positioned zones leave behind. A single zone still fills the container.

Fixes #724

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ
…ixed capacity

Hexa's InputText(label, ref string, maxLength) tells Dear ImGui the buffer is maxLength bytes whatever the string's length, so activating a field holding more failed a native assertion and aborted the process. ResizableInputText hands ImGui a native buffer sized from the value and grows it through CallbackResize, and every string field in the suite now goes through it: the data table's text editor, the property grid's text, path and list rows, SearchBox, ValueSlider's editor, TimecodeField, PinInput, the node editor's string pin editor and comment rename box, and the popups' InputString, SearchableList and filesystem browser (path box, search and file name). ImGui.Popups links the file, since it does not reference ImGui.Widgets.

The file name box used to be capped below the length a file name may have, so a name too long for the system now reaches the browser; it is refused with a message instead of throwing out of the frame.

Fixes #553

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ
@matt-edmondson matt-edmondson self-assigned this Oct 25, 2026
SonarCloud's security rating fails new pointer code even under an S6640 suppression, and the CallbackResize buffer in ResizableInputText was that: NativeMemory, a pointer as user data, and AllowUnsafeBlocks in ImGui.Popups. The helper now calls Hexa's managed InputText(label, ref string, maxLength) overloads with a capacity worked out every frame from the value's UTF-8 length: the value, its terminator, and headroom of 1024 bytes or the value's own length, whichever is larger. Hexa allocates the larger of the string and maxLength, plus the terminator, so the value always fits and activating a field can no longer fail ImGui's assertion. ImGui.Popups no longer allows unsafe code.

Trade-off: Dear ImGui fixes a field's capacity when it is activated and does not take a larger one while the field stays active (measured: a second 1000-character paste into an active field that started empty stopped at 1025 characters). So one edit can add at most the headroom, and text past it is cut rather than aborting the process. The next edit starts from the longer value with headroom again. The 5000-character paste test now asserts the cut to the headroom, a new test shows each new edit getting room to grow, and the long-path browser test uses a path that fits one edit.

Refs #553

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbrgmjhBm6arqvhHro2wgJ
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment