Skip to content

Add StepGrid step-sequencer widget - #540

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-g9k1ol-step-grid
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-g9k1ol-step-grid

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: ktsu.ImGui.Widgets has no step sequencer. A drum pattern or a gate sequence means drawing a grid of cells and writing your own click and drag handling.

After: ImGuiWidgets.StepGrid(label, steps, rows, stepCount, playingStep, stepsPerBeat, cellSize, rowLabels) draws a rows × steps grid over a caller-owned Span<bool>. Pressing a cell toggles it, and dragging from there paints the same value across every cell the pointer crosses. It shades beat groups, highlights the playing column, and draws optional row labels. The method returns true on any frame the pattern changed. Each cell is probe-addressable as {label}/r{row}s{step}.

How: geometry, hit testing and the toggle-then-paint gesture live in StepGridLayout and StepGridState, which are internal and nested in ImGuiWidgets the same way HandleTrackState is. They need no ImGui context, and tests/ImGui.Widgets.Tests/StepGridStateTests.cs covers them (21 tests). The only item the widget submits is one InvisibleButton over the cells. It does not reuse Grid, as decided on the issue. tests/ImGui.Widgets.UITests/StepGridTests.cs (11 tests) drives the widget in isolation.

Also in this PR:

  • A 4 × 16 drum-pattern demo with its own play clock, in examples/ImGuiWidgetsDemo/StepGridDemo.cs. For now it's registered with one line each in SignalDemos; that moves to DemoSections.cs once Split the widgets demo into one class per section #534 lands.
  • A demo UI test that clicks a cell.
  • A gallery tile.
  • README and CLAUDE.md entries.

Deviations from the issue text worth checking:

  • The drag segment is clipped to the grid before it is sampled. ImGui reports an unavailable mouse at -FLT_MAX, and sampling that unclipped segment would never finish. There are tests for leaving the grid and coming back, and for a -FLT_MAX or NaN pointer.
  • The row-label tooltip uses BeginTooltip/TextUnformatted, not SetTooltip, so a label containing % isn't read as a format string.
  • An empty grid (rows or stepCount ≤ 0) returns false before the span-length check, so it never throws.

Not included: the rendered tile image docs/gallery/widgets/stepgrid.png. This environment can't upload Git LFS objects, so it needs a local dotnet run -c Release --project tools/WidgetGallery -- --only StepGrid. The composite gallery sheets were not regenerated either.

Checks run locally in Release:

  • Unit 21/21, widget UI 11/11, demo UI 5/5, WidgetGallery --check clean, gallery UI tests 5/5.
  • 0 warnings across the demo and test projects.
  • EverySection_CanBeExpandedWithoutError passes only once ktsu.png has been pulled from LFS. With a pointer checkout it fails at "Mobile - Decorators" on main too.

This branch appends to the same shared lists as the other widget PRs (#539 and the two to come): SignalDemos, WidgetDemoSections, InputAndControls.cs, and the CLAUDE.md and README feature lists. Any conflicts between them are adjacent additions, so resolve them by keeping both sides.

Closes #526

🤖 Generated with Claude Code

https://claude.ai/code/session_01PndoA4WHoRsyywzECYDNX3


Generated by Claude Code

@matt-edmondson matt-edmondson self-assigned this Sep 29, 2026
Comment thread examples/ImGuiWidgetsDemo/StepGridDemo.cs Fixed
Comment thread tests/ImGui.Widgets.Tests/StepGridStateTests.cs Fixed
Also folds in:
- Count StepGrid demo and test steps with LINQ

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/project-thread-g9k1ol-step-grid branch from 7239741 to f6762c2 Compare September 30, 2026 10:44
@matt-edmondson
matt-edmondson changed the base branch from main to claude/project-thread-g9k1ol-piano-keyboard 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 3: add StepGrid (step sequencer / drum grid with a playing column)

2 participants