Skip to content

Add "zoom to fit" shortcut (Z) #27

Description

@superzero11

What

Add a zoom to fit shortcut (Z) that sets the zoom level so the
whole arrangement fits the visible timeline width.

Zoom in, zoom out and reset (⌘0) all exist; fit is the one that is
missing, and it is the one you want after working on bar 60 of a 64-bar track.

Where

  • lib/shortcuts/index.ts — add the registry entry (this is what makes it
    rebindable and puts it in the / reference panel automatically)
  • app/[locale]/compose/page.tsx — bind it with useShortcut
  • lib/store/ui.ts — the zoom action

Suggested approach

projectEndBar() in lib/audio/scheduler.ts gives the arrangement length in
bars. Divide the container width by that, clamp to the store's MIN_ZOOM /
MAX_ZOOM, and scroll back to bar 0.

hooks/useVisibleClips.ts has useViewportWidth, which gives you the container
width and keeps it correct when panels open and close.

Done when

  • Z fits the whole arrangement on screen
  • It appears in the shortcuts panel and can be rebound (both come free from the
    registry entry)
  • An empty project doesn't produce a divide-by-zero

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions