diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-06 22:45:34 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-06 22:45:34 +0100 |
| commit | 64145080cddbc0fe9fec7159e9ffdedca48ae9be (patch) | |
| tree | 58459b5cc81fd923c466a53e1665f3c87fd7ec3d /src/platform.h | |
| parent | 6906b9d75e21b904b3f54f4a4c5b591dd459dc69 (diff) | |
feat(timeline): Add Ctrl+wheel zoom centered on mouse cursor
FEATURE:
Implemented zoom-with-mousewheel for timeline editor, centered on cursor position.
IMPLEMENTATION:
- Detect Ctrl/Cmd + wheel event
- Calculate time position under cursor BEFORE zoom:
time_under_cursor = (scrollLeft + mouseX) / oldPixelsPerSecond
- Adjust pixelsPerSecond (±10 per wheel notch, clamped to 10-500)
- Re-render waveform and timeline at new zoom level
- Adjust scroll position AFTER zoom to keep same time under cursor:
new_scrollLeft = time_under_cursor * newPixelsPerSecond - mouseX
CONTROLS:
- Ctrl/Cmd + wheel up: Zoom in (+10 px/sec)
- Ctrl/Cmd + wheel down: Zoom out (-10 px/sec)
- Wheel without Ctrl: Diagonal scroll (existing behavior)
TRICKY PARTS:
- Mouse position must be relative to timeline container (not page)
- Scroll position adjustment ensures zoom feels "anchored" to cursor
- Zoom range clamped to 10-500 px/sec to prevent extreme values
TESTING:
- Open tools/timeline_editor/index.html
- Load a demo.seq file
- Hold Ctrl/Cmd and scroll wheel to zoom
- Verify that the timeline zooms in/out centered on cursor position
This addresses the "tricky to get right" concern by properly handling
the coordinate space transform between old and new zoom levels.
Diffstat (limited to 'src/platform.h')
0 files changed, 0 insertions, 0 deletions
