Skip to content

Commit

Permalink
Fix #201 - Allow selection rectangle to reach minimum note c-1 by adj…
Browse files Browse the repository at this point in the history
…usting some clamping code
  • Loading branch information
robertnhart committed May 22, 2024
1 parent 2c5c79f commit 1cf659a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/common/selection/Selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ export const regularizedSelection = (
tick: Math.max(0, Math.min(fromTick, toTick)),
noteNumber: Math.min(
MaxNoteNumber,
Math.max(0, Math.max(fromNoteNumber, toNoteNumber)),
Math.max(fromNoteNumber, toNoteNumber),
),
},
to: {
tick: Math.max(fromTick, toTick),
noteNumber: Math.min(
MaxNoteNumber,
Math.max(0, Math.min(fromNoteNumber, toNoteNumber)),
Math.min(fromNoteNumber, toNoteNumber),
),
},
})
Expand Down
8 changes: 6 additions & 2 deletions src/main/actions/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function eventsInSelection(events: TrackEvent[], selection: Selection) {
export const resizeSelection =
({ pianoRollStore }: RootStore) =>
(start: NotePoint, end: NotePoint) => {
const selection = regularizedSelection(
let selection = regularizedSelection(
start.tick,
start.noteNumber,
end.tick,
Expand All @@ -53,7 +53,11 @@ export const resizeSelection =
selection.from.noteNumber = Math.ceil(selection.from.noteNumber)
selection.to.noteNumber = Math.floor(selection.to.noteNumber)

pianoRollStore.selection = clampSelection(selection)
++selection.to.noteNumber;
selection = clampSelection(selection);
--selection.to.noteNumber;

pianoRollStore.selection = selection;
}

export const fixSelection =
Expand Down

0 comments on commit 1cf659a

Please sign in to comment.