Skip to content

Slider: a typed range wider than the track's (part of #328, based on #403) - #407

Merged
samitbasu merged 5 commits into
mainfrom
typed-range-328
Nov 19, 2026
Merged

samitbasu merged 5 commits into
mainfrom
typed-range-328

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Part of #328: PR 2 of 3, typed_range. Based on #403: this PR targets #403's branch and moves to main when #403 merges.

API (rustdoc TODO(prose))

impl SliderChain {
    pub fn typed_range(self, typed: impl Into<ValueRange>) -> Self;
}

Behaviour, as the user accepted it on #328

  • What it reaches: a value typed in the editable readout reaches the typed range (e.g. ±380 behind a −60..=0 track), clamped to it.
  • The step lattice stays the track's: typed values snap on steps counted from the track's start, not the typed range's. A new crate-internal Step::snap_from(origin, value, range) does this, and Step::snap now calls it with the range's own start, so its behaviour is unchanged. It also prefers either end of the range when that's nearer, which only matters when the start is off the lattice.
  • Outside the track: the thumb pins at its end (the fill fraction was already clamped). The arrow keys step from where the value is, within the typed range (300 → 299, not a jump to 0); inside the track they're bound by the track as before. Home and End go to the track's ends.
  • Accessibility: AccessKit's min and max are the track's, widened to hold the value, so the value is never outside them.
  • A typed range that doesn't hold the track's is widened to the union of the two and reported as BadRange. No panic.
  • Without typed_range: nothing changes; the typed range is the track's.

The stepper doesn't take it, because it has one range.

Tests (tests/it/typed_range.rs, through the real readout, keys and AccessKit)

  • typing reaches the typed range and is clamped to it (300, then 500 → 380); without one, it clamps to the track (300 → 0);
  • the thumb pins at the track's right end at 300;
  • the lattice is anchored at the track's start: step 7, track 1..=50, typed −100..=100, typing 0 gives 1 (a lattice from −100 would give −2);
  • arrows from 300 step to 299, then to 301, and End goes to the track's end, 0;
  • the accessible range at 300 is −60..=300;
  • a typed −10..=10 behind a −60..=0 track is reported, and still reaches −50 and stops at 10.

Mutations, each caught:

  • accept clamping to the track;
  • the lattice from the typed start;
  • arrows bound by the track outside it;
  • the accessible range not widened;
  • no report;
  • no union.

The existing slider, stepper and step tests (85) pass unchanged.

Prose for you

TODO(prose) on SliderChain::typed_range.

git diff numberfield-328 HEAD --stat (this PR alone)

 src/owned/number.rs     |  46 +++++++++++--
 src/owned/slider.rs     |  67 +++++++++++++++++--
 tests/it/main.rs        |   1 +
 tests/it/typed_range.rs | 172 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 275 insertions(+), 11 deletions(-)

cargo xtask ci exits 0 on 6833d6c (on #403's 6ad9d8d).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP

`SliderChain::typed_range(range)`: a value typed in the editable readout
reaches `range` (e.g. ±380 dB behind a 60 dB track), as the user decided
on #328.

- A typed value is clamped to the typed range and snapped on the track's
  step lattice (a new crate-internal `Step::snap_from`, which `snap` now
  calls with the range's own start).
- Outside the track the thumb pins at its end; the arrow keys step from
  where the value is, within the typed range; Home and End go to the
  track's ends.
- AccessKit's min and max are the track's, widened to hold the value.
- A typed range that does not hold the track's is widened to it and
  reported as `BadRange`; no panic.
- Without a typed range, nothing changes.

Based on #403.

Part of #328.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP
@samitbasu
samitbasu changed the base branch from numberfield-328 to main November 19, 2026 17:46
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user after the number-field trial (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit 0bba5f2 into main Nov 19, 2026
4 checks passed
samitbasu added a commit that referenced this pull request Nov 20, 2026
b.number: the slider's editable readout without the track (#328, PR 3; based on #407)
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.

1 participant