Skip to content

Add AssetBrowser: a virtualized thumbnail grid with multi-select and drag-out - #542

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/asset-browser-026l9x
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/asset-browser-026l9x

Conversation

@matt-edmondson

@matt-edmondson matt-edmondson commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Closes #509.

Top of the widget stack. This branch sits on #540 (StepGrid), so the diff here is the asset browser commit alone. It merges after the PRs below it.

Before: ktsu.ImGui.Widgets had no way to browse a large set of assets as thumbnails. Anyone who needed one wrote their own grid, their own selection rules and their own drag payload.

After: ImGuiWidgets.AssetBrowser(label, itemCount, getLabel, resolveThumbnail, state, options) draws a scrolling grid of thumbnail tiles, and only the visible rows are drawn:

  • Selection works like a file manager: click, Ctrl+click, Shift+click and Ctrl+Shift+click, plus the arrow keys, Home/End, Ctrl+A and Escape.
  • Double-click or Enter raises OnActivate, and Ctrl+wheel resizes the tiles.
  • Dragging carries the whole selection. A drop target reads it back with ImGuiWidgets.TryAcceptAssetPayload.
  • A thumbnail id of 0 draws as an empty frame.

The widget takes callbacks rather than a list, so it never asks for a label or texture it is not about to draw. The 50 000-item test caps those calls at a screenful.

How

  • AssetBrowserState holds the selection, focus, anchor and grid arithmetic, with no ImGui dependency, so it has 16 unit tests that need no context. The caller owns the state, so a selection survives the widget being hidden.
  • Drawing goes through ImGuiListClipper, one row of tiles per clipper item. The keyboard scrolls to keep the focus visible.
  • A press on an already-selected tile is resolved on release, not on press. Without that, the first frame of a drag would collapse a multi-selection to one tile before the drag could carry it.
  • Probe marks: each tile is marked {label}/[i] and the whole browser under its label, per Mark every widget for UI probes (ImGuiProbes.MarkItem in all ktsu.ImGui.Widgets entry points) #533.
  • Demo: AssetBrowserDemo shows 5 000 synthetic assets with a name filter, a tile-size slider and a drop target. It is registered in DemoSections, following the per-section layout from Split the widgets demo into one class per section #534.
  • Gallery: a tile in LayoutAndContainers. AssetBrowserState and TryAcceptAssetPayload are listed in NotWidgets.
  • Docs: README, ImGui.Widgets/README.md and CLAUDE.md are updated.

Local Release runs: ImGui.Widgets.Tests 410/410, ImGui.Widgets.UITests 427/427 (16 new), ImGuiWidgetsDemo.UITests 36/36, WidgetGallery.UITests 6/6, and gallery --check is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_011hneiVTJVPigNUERid5WsM


Generated by Claude Code

@matt-edmondson matt-edmondson self-assigned this Sep 29, 2026
Comment thread ImGui.Widgets/AssetBrowser.cs Fixed
Comment thread ImGui.Widgets/AssetBrowser.cs Fixed
Comment thread tests/ImGui.Widgets.UITests/AssetBrowserTests.cs Fixed
Comment thread examples/ImGuiWidgetsDemo/GridDemo.cs Fixed
Comment thread examples/ImGuiWidgetsDemo/SearchBoxDemo.cs Fixed
…ect and drag-out

Also folds in:
- Compare the asset browser's float values with a tolerance [patch]
- Justify the unsafe payload read in the asset browser [patch]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgjMCJ9MQRmUk6c8KABDYH
@matt-edmondson
matt-edmondson force-pushed the claude/asset-browser-026l9x branch from ef5ece9 to 9f7e5d1 Compare September 30, 2026 10:44
@matt-edmondson
matt-edmondson changed the base branch from main to claude/project-thread-g9k1ol-step-grid September 30, 2026 10:44
@sonarqubecloud

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.

Domain widgets Tier 2: add AssetBrowser (virtualized thumbnail grid with selection and drag-out)

2 participants