PerKeyArray <HashSet <int> > MoveNotes(double xOffset, int keyOffset, PerKeyArray <HashSet <int> > selectedNotes) { var pattern = PianoRollPattern.Pattern; var notesToMove = pattern.FetchSelectedNotes(selectedNotes); pattern.RemoveSelectedNotes(notesToMove); var shiftedNotes = notesToMove.Roll(keyOffset).MapParallel(k => { foreach (var n in k) { n.Start += xOffset; } return(k.AsEnumerable()); }); pattern.InjectNotes(shiftedNotes); var editedSelection = shiftedNotes.ToSelectedSNotes(); PianoRollPattern.DeselectAllNotes(); PianoRollPattern.SelectNoteRange(editedSelection); return(pattern.GetNoteLocations(shiftedNotes)); }
public override IPianoRollInteraction?DoInteraction() { base.DoInteraction(); var pos = GetMousePos(); PianoRollPattern.SetSelectionPosOffset(StartLocation, pos - StartLocation); if (!ImGui.IsMouseDown(ImGuiMouseButton.Left)) { PianoRollPattern.ApplySelectionPosOffset(); return(new MIDIPatternInteractionIdle(PianoRollPattern)); } return(null); }
public MIDIPatternInteractionMouseShiftDown(MIDIPatternConnect pianoRollPattern) : base(pianoRollPattern) { ClickLocation = GetMousePos(); ClickedNote = PianoRollPattern.GetNoteAtLocation(ClickLocation); if (ClickedNote != null) { var clickedNote = ClickedNote.Value; if (PianoRollPattern.IsNoteSelected(clickedNote)) { PianoRollPattern.DeselectNote(clickedNote); } else { PianoRollPattern.SelectNote(clickedNote); } } ContinueWith(null); }
public MIDIPatternInteractionMouseDown(MIDIPatternConnect pianoRollPattern) : base(pianoRollPattern) { if (ImGui.GetIO().KeyShift) { ContinueWith(new MIDIPatternInteractionMouseShiftDown(PianoRollPattern)); return; } ClickLocation = GetMousePos(); ClickedNote = PianoRollPattern.GetNoteAtLocation(ClickLocation); if (ClickedNote == null || !PianoRollPattern.IsNoteSelected(ClickedNote.Value)) { PianoRollPattern.DeselectAllNotes(); } if (ClickedNote != null) { PianoRollPattern.SelectNote(ClickedNote.Value); } }
public override IPianoRollInteraction?DoInteraction() { base.DoInteraction(); var pos = GetMousePos(); var rect = new Rectangle(StartLocation, pos); PianoRollPattern.SetSelectionRectangle(rect); if (!ImGui.IsMouseDown(ImGuiMouseButton.Left)) { PianoRollPattern.ClearSelectionRectangle(); foreach (var n in PianoRollPattern.GetNotesInRectangle(rect)) { PianoRollPattern.SelectNote(n); } return(new MIDIPatternInteractionIdle(PianoRollPattern)); } return(null); }