Skip to content

feat(ui): H / F keyboard fits for the plot data viewport - #73

Merged
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/plot-fit-shortcuts
Aug 29, 2026
Merged

feat(ui): H / F keyboard fits for the plot data viewport#73
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/plot-fit-shortcuts

Conversation

@Limdongcheng

Copy link
Copy Markdown
Contributor

Summary

H fits the y axis to the data visible in the current x window (the NMR vertical-fit convention — the window-scoped auto range, not full_y) and F fits both axes; both are single undoable viewport steps sharing the double-click reset path.

Plain F was already bound to ZoomToSelection (board-level frame fit), so the chord is context-split by a focused handler instead of the dispatch table: with the pointer on a plot's data area it runs the new FitPlotXY, anywhere else it keeps ZoomToSelection — neither behavior is dropped. H was unbound before. Invoked without a pointer target, both fits fall back to the active plot.

Validation

  • cargo pr-check passes (fmt, source sizes, dependency policy, default-frontends build, clippy -D warnings, reference-backend test suite).
  • Tests cover the window-scoped y fit, the context split for F, and command gating; shortcuts.rs tests moved to a sibling shortcuts_tests.rs to stay under the source-size limit.

UI display logic

  • New or changed actions go through the command catalog (CommandId + describe) and are searchable in the command palette. (FitPlotY / FitPlotXY registered, gated in describe on an active plot, listed in the View menu.)
  • Hiding happens only at Ribbon-group level (dataset kind or width budget); transient states disable with a disabled_reason that says how to unblock. (Commands stay visible and disable with a reason when no plot is active.)
  • No layout changes from background events; panels are never auto-closed. (Viewport-only changes.)
  • New panels or empty regions show an empty state with a next step. (No new panels.)
  • Docs updated in docs/ (English and zh-CN) for user-visible behavior. (Keyboard shortcut reference updated in both languages.)

`H` fits the y axis to the data visible in the current x window (the
NMR vertical-fit convention — reset_y's window-scoped auto range, not
full_y) and `F` fits both axes, both as single undoable viewport steps
sharing the double-click reset path.

Plain `F` was already bound to ZoomToSelection (board-level frame fit),
so the chord is now context-split by a focused handler instead of the
dispatch table: with the pointer on a plot's data area it runs the new
FitPlotXY, anywhere else it keeps ZoomToSelection. Both fits are
registered as CommandId (FitPlotY / FitPlotXY), gated in describe on an
active plot, searchable in the palette, and listed in the View menu;
invoked without a pointer target they fall back to the active plot.
`H` was unbound before.

The keyboard shortcut reference (English and Simplified Chinese) now
documents the new keys; shortcuts.rs tests moved to a sibling
shortcuts_tests.rs to stay under the source-size limit.
@nmrtist
nmrtist merged commit dd3a0a0 into nmrtist:main Aug 29, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants