Skip to content

Add ReorderableTree, a drag-reorderable tree of caller-drawn rows - #588

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/m5b-layers-qb4i3s
Oct 7, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/m5b-layers-qb4i3s

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: ktsu.ImGui.Widgets had no tree whose rows can be dragged. Tree draws connector lines around content and has no rows, and IconTreeNode is a Hexa adapter that probes cannot see.

After: ImGuiWidgets.ReorderableTree(label, rows, drawRow) lays out rows the caller draws, shows an insertion line or a container highlight while a row is dragged, and on release returns a ReorderableTreeMove (row, new parent row, insertion index). It never applies the move, so the caller's own model and undo history do.

This is the widget ImageGui's M5 layers spec asks for in M5b, so the layers panel can reorder and re-parent by drag.

How: ReorderableTreeState resolves the drop with no ImGui dependency, following the HandleTrack/CurveTrack pattern. The top and bottom quarters of a container drop beside it and the middle half inside. A leaf splits at the middle. Below the last row of a subtree, the pointer's x picks how far out the drop lands. A drop into the dragged row's own subtree, or one that would leave it where it was, is refused. Index counts the parent's children before the move, which the README and a test both pin. A press in a text field is left to the field, so selecting text in a rename box doesn't pick the row up. Every row is marked for probes as row{i} inside the tree's label.

Ships with 26 state tests, an 11-test isolation suite, a demo section with a demo UI test, a gallery tile, and the README and CLAUDE.md entries. Locally, ImGui.Widgets.Tests, ImGui.Widgets.UITests, ImGuiWidgetsDemo.UITests and WidgetGallery.UITests all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RU5HC3D44CgGTP97XE4WQz


Generated by Claude Code

…nor]

The caller flattens its tree into rows and draws each row's content; the
widget lays them out, shows where a drag would land, and reports the move
on release as a ReorderableTreeMove whose index counts the new parent's
children before the move. ReorderableTreeState resolves drops without
ImGui: the quarters of a container drop beside it and the middle half
inside, a leaf splits at the middle, the pointer's x picks how far out a
drop below the end of a subtree lands, and drops into the dragged row's
own subtree or back where it was are refused. A press in a text field is
left to the field.

Ships with state tests, an isolation suite, a demo section, a demo UI
test and a gallery tile. Asked for by ImageGui's layers panel (M5b).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RU5HC3D44CgGTP97XE4WQz
@matt-edmondson matt-edmondson self-assigned this Oct 6, 2026
Comment thread tests/ImGui.Widgets.Tests/ReorderableTreeStateTests.cs Fixed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RU5HC3D44CgGTP97XE4WQz
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

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.

2 participants