public ElementPitchedNote( ViewManager manager, Project.TrackPitchedNotes projectTrackPitchedNode, Project.PitchedNote pitchedNote) : base(manager) { this.projectTrackPitchedNode = projectTrackPitchedNode; this.projectPitchedNote = pitchedNote; this.interactableRegions = new List <InteractableRegion>(); this.segments = new List <Segment>(); this.timeRange = this.projectPitchedNote.timeRange; this.pitch = this.projectPitchedNote.pitch; this.assignedTrack = -1; for (var i = 0; i < this.manager.rows[0].trackSegments.Count; i++) { var trackPitchedNote = (this.manager.rows[0].trackSegments[i] as TrackSegmentPitchedNotes); if (trackPitchedNote != null && trackPitchedNote.projectTracks.Contains(this.projectTrackPitchedNode)) { this.assignedTrack = i; break; } } }
public override void Drag() { this.timeRange = this.projectPitchedNote.timeRange.OffsetBy(this.manager.DragTimeOffsetClampedToRow); this.pitch = this.projectPitchedNote.pitch.OffsetMidiPitchBy(this.manager.DragMidiPitchOffset); }
public override void EndModify() { this.projectPitchedNote.timeRange = this.timeRange; this.projectPitchedNote.pitch = this.pitch; this.manager.project.InsertPitchedNote( this.manager.project.GetTrackIndex(this.projectTrackPitchedNode), this.projectPitchedNote); }
public static RelativePitch MakeFromPitch(Util.Pitch pitch) { var midiPitch = ((pitch.MidiPitch % 12f) + 12) % 12f; if (midiPitch % 1f != 0) { return(RelativePitch.None); } return((RelativePitch)(int)midiPitch); }
public void OnMouseDown(bool scroll, float x, float y, bool ctrlKey, bool shiftKey) { this.mouseIsDown = true; this.mouseDragOriginX = x + scrollX; this.mouseDragOriginY = y + scrollY; this.noteInsertionMode = false; if (scroll) { this.mouseAction = MouseAction.Scrolling; } else { this.mouseAction = MouseAction.Selection; this.cursorVisible = false; if ((!ctrlKey && (this.currentHoverElement == null || !this.currentHoverElement.selected)) || this.currentHoverRegion != null && this.currentHoverRegion.isolated) { UnselectAll(); } if (this.currentHoverElement != null) { this.currentHoverElement.selected = true; } this.timeDragOrigin = this.GetTimeAtPosition(this.mouseDragOriginX, this.mouseDragOriginY, true); this.trackDragOrigin = this.GetTrackIndexAtPosition(this.mouseDragOriginX, this.mouseDragOriginY); var timeSnapped = (float)(System.Math.Round(this.timeDragOrigin / TimeSnap) * TimeSnap); this.pitchDragOrigin = this.GetTrackSegmentAtPosition(this.mouseDragOriginX, this.mouseDragOriginY). GetPitchAtPosition(this.mouseDragOriginY); if (this.currentHoverRegion != null && this.currentHoverRegion.isolated) { this.currentDraggingIsolatedRegion = this.currentHoverRegion; this.currentDraggingIsolatedRegion.dragStartFunc?.Invoke(this.currentDraggingIsolatedRegion); } else if (!ctrlKey && !shiftKey && this.currentHoverRegion == null) { this.mouseAction = MouseAction.Cursor; this.SetCursorTimeRange(timeSnapped, timeSnapped); this.SetCursorTrackIndices(this.trackDragOrigin, this.trackDragOrigin); this.cursorVisible = true; } } }
public override void RefreshLayout(float x, float y) { this.minPitch = Util.Pitch.FromMidiPitch(60); this.maxPitch = Util.Pitch.FromMidiPitch(71); // Find minimum and maximum note pitches in the segment's time range. foreach (var track in this.projectTracks) { foreach (var note in track.notes.EnumerateOverlappingRange(this.row.timeRange)) { var noteOctave = (int)(note.pitch.MidiPitch / 12); if (12 * noteOctave < this.minPitch.MidiPitch) { this.minPitch.MidiPitch = 12 * noteOctave; } if (12 * noteOctave + 11 > this.maxPitch.MidiPitch) { this.maxPitch.MidiPitch = 12 * noteOctave + 11; } } } var pitchRange = (this.maxPitch.MidiPitch - this.minPitch.MidiPitch + 1); this.layoutRect = new Util.Rect( x, y, x + this.row.timeRange.Duration * this.manager.TimeToPixelsMultiplier, y + LAYOUT_MARGIN * 2 + pitchRange * this.manager.PitchedNoteHeight); this.contentRect = new Util.Rect( x, y + LAYOUT_MARGIN, x + this.row.timeRange.Duration * this.manager.TimeToPixelsMultiplier, y + LAYOUT_MARGIN + pitchRange * this.manager.PitchedNoteHeight); }
public override void OnPressDown(bool ctrlKey, bool shiftKey) { this.pitch = this.pitch.OffsetMidiPitchBy(shiftKey ? -12 : -1); }