Skip to content

Add TimecodeField and Timecode helpers - #538

Merged
matt-edmondson merged 3 commits into
mainfrom
claude/project-thread-ay8erv-525
Sep 30, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
claude/project-thread-ay8erv-525

Conversation

@matt-edmondson

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

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Closes #525.

Before: there was no widget for editing a frame position as HH:MM:SS:FF timecode.

After: ImGuiWidgets.TimecodeField edits a frame number shown as timecode.

  • Step buttons with hold-to-repeat.
  • Drag-to-scrub on the value.
  • Click to type a new timecode.
  • Drop-frame support.

TimecodeRate has 11 presets. The static Timecode class formats, parses and converts between frames, seconds and timecode text, and is usable without ImGui.

How

  • Rates: a TimecodeRate is a rational (numerator/denominator) plus a drop-frame flag. Rates below 0.5 fps are refused, because they round to 0 nominal frames and every label would divide by zero. A default rate is refused by name.
  • Parsing and scrubbing: TryParse rejects hours that would overflow. Scrub steps saturate rather than wrap.
  • Clamping: an incoming value outside [min, max] is left as the caller passed it. Only user edits clamp. A reversed min/max is swapped.
  • Probes: the field marks itself under ScopedId(label) as label/dec, label/value, label/inc and label/edit.
  • Tooltip: uses TextUnformatted, so a % in the text is not read as a format string.
  • Reuse: Stepper's RepeatButton goes from private to internal so the step buttons can use it. That is the only change to Stepper.
  • Tests:
    • Unit tests for Timecode and the field's arithmetic.
    • The 11 isolation UI tests from the issue.
    • A demo UI test.
  • Demo and gallery: a demo section and a gallery tile. The demo is registered through SectionDemos.cs, because ImGuiWidgetsDemo is at the class-coupling limit (CA1506). It will move to a DemoSections.cs registration once Split the widgets demo into one class per section #534 lands.
  • Gallery images: the published gallery PNGs were not regenerated, because Git LFS was unavailable where this was built. --check and the full gallery render test both pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01To1cbNshRJb5qvkjnGtLhH

TimecodeField edits a frame count shown as SMPTE timecode, laid out as
[-] HH:MM:SS:FF [+] with drop-frame labels (;FF) at 29.97 and 59.94. The
buttons step a frame, or a second with Shift, and repeat while held.
Dragging across the value scrubs a frame per pixel (ten with Shift), and
a click that never became a drag opens it for typing. Up and Down step
while the pointer rests on the value.

TimecodeRate is a rational rate (30000/1001 rather than 29.97) with the
usual presets, and the static Timecode class formats, parses and
converts frames to and from seconds with no ImGui context. Drop-frame
drops n/15 labels per minute except every tenth, so the same arithmetic
covers 29.97 DF and 59.94 DF.

StepperImpl.RepeatButton is now internal so both widgets share one
hold-to-repeat button. The widget marks dec, value, inc and edit under
its label's scope, and ships with unit tests, an isolation suite, a
gallery tile and a demo section.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01To1cbNshRJb5qvkjnGtLhH
@matt-edmondson matt-edmondson self-assigned this Sep 29, 2026
Comment thread examples/ImGuiWidgetsDemo/TimecodeFieldDemo.cs
Registers the TimecodeField demo through SectionDemos rather than the main
demo class, which main's new sections had already brought to the CA1506
class-coupling limit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01To1cbNshRJb5qvkjnGtLhH
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01To1cbNshRJb5qvkjnGtLhH
@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 TimecodeField (HH:MM:SS:FF field with drag-to-scrub and drop-frame)

2 participants