fix: subtract renderBeatOffset from mouse beat for correct positioning
- handleGridMouseDown/move: beat = x/pixelsPerBeat - renderBeatOffset so hit-testing and note creation use item-relative coordinates - CC mouse handlers: same offset subtraction - Ruler click: clickTime subtracts renderBeatOffset so st.currentTime remains item-relative
This commit is contained in:
@@ -5076,7 +5076,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
const x = e.clientX - rect.left;
|
const x = e.clientX - rect.left;
|
||||||
const y = e.clientY - rect.top;
|
const y = e.clientY - rect.top;
|
||||||
|
|
||||||
const beat = x / pixelsPerBeat;
|
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||||
const pitch = 127 - Math.floor(y / NoteHeight);
|
const pitch = 127 - Math.floor(y / NoteHeight);
|
||||||
|
|
||||||
if (scaleMenuPos) setScaleMenuPos(null);
|
if (scaleMenuPos) setScaleMenuPos(null);
|
||||||
@@ -5261,7 +5261,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
const x = e.clientX - rect.left;
|
const x = e.clientX - rect.left;
|
||||||
const y = e.clientY - rect.top;
|
const y = e.clientY - rect.top;
|
||||||
|
|
||||||
const beat = x / pixelsPerBeat;
|
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||||
const pitch = 127 - Math.floor(y / NoteHeight);
|
const pitch = 127 - Math.floor(y / NoteHeight);
|
||||||
|
|
||||||
if (selectionMarquee) {
|
if (selectionMarquee) {
|
||||||
@@ -5536,7 +5536,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
const x = e.clientX - rect.left;
|
const x = e.clientX - rect.left;
|
||||||
const y = e.clientY - rect.top;
|
const y = e.clientY - rect.top;
|
||||||
const h = rect.height;
|
const h = rect.height;
|
||||||
const beat = x / pixelsPerBeat;
|
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||||
|
|
||||||
const noteIdx = findCCNoteIndex(beat, y, h);
|
const noteIdx = findCCNoteIndex(beat, y, h);
|
||||||
const val = Math.max(0, Math.min(1, (h - y) / h));
|
const val = Math.max(0, Math.min(1, (h - y) / h));
|
||||||
@@ -5588,7 +5588,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
const x = e.clientX - rect.left;
|
const x = e.clientX - rect.left;
|
||||||
const y = e.clientY - rect.top;
|
const y = e.clientY - rect.top;
|
||||||
const h = rect.height;
|
const h = rect.height;
|
||||||
const beat = x / pixelsPerBeat;
|
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||||
const val = Math.max(0, Math.min(1, (h - y) / h));
|
const val = Math.max(0, Math.min(1, (h - y) / h));
|
||||||
|
|
||||||
const drag = ccDragRef.current;
|
const drag = ccDragRef.current;
|
||||||
@@ -6009,7 +6009,7 @@ const beatSec = 60.0 / (parseInt(bpm) || 120);
|
|||||||
const rect = e.currentTarget.getBoundingClientRect();
|
const rect = e.currentTarget.getBoundingClientRect();
|
||||||
const x = e.clientX - rect.left + e.currentTarget.scrollLeft;
|
const x = e.clientX - rect.left + e.currentTarget.scrollLeft;
|
||||||
const clickBeat = x / pixelsPerBeat;
|
const clickBeat = x / pixelsPerBeat;
|
||||||
const clickTime = clickBeat * beatSec;
|
const clickTime = (clickBeat - renderBeatOffset) * beatSec;
|
||||||
const clickInRange = loopStartBeat !== null && loopEndBeat !== null && clickBeat >= loopStartBeat && clickBeat <= loopEndBeat;
|
const clickInRange = loopStartBeat !== null && loopEndBeat !== null && clickBeat >= loopStartBeat && clickBeat <= loopEndBeat;
|
||||||
if (e.ctrlKey || e.metaKey) {
|
if (e.ctrlKey || e.metaKey) {
|
||||||
setLoopStartBeat(null);
|
setLoopStartBeat(null);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user