Commit graph

146 commits

Author SHA1 Message Date
Paul Davis
28e0082868 use std::unique_ptr for a couple of EditingContext members 2025-08-08 12:12:09 -06:00
Paul Davis
1d4e3940d1 large-scale refactoring of Pianoroll, CueEditor and AudioClipEditor
Enables code-sharing between "clip editors"
2025-07-29 18:16:35 -06:00
Paul Davis
f2eea8b7ce reduce jumping note range in MIDI displays when adding notes 2025-07-12 10:28:49 -06:00
Paul Davis
ff988eec37 fix one of 3 editing context refactoring warnings 2025-07-11 13:27:55 -06:00
Paul Davis
a902f99172 midiview: expose API for _on_timeline 2025-07-10 18:17:33 -06:00
Paul Davis
4bbd1afc98 MidiView: add _on_timeline to help clarify semantics of _show_source
This also fixes where the ghost note in draw mode shows up
2025-07-09 16:02:31 -06:00
Paul Davis
5767c8f62e better handling of MidiView::apply_note_range()
In particular, keep the MidiViewBackground's sense of the data range intact,
use MidiModel::{highest,lowest}_note(), center ranges that don't fit
on the data range
2025-07-01 17:31:42 -06:00
Paul Davis
1fbd7c7124 when selecting a due to note selection, do not keep changing the selection
the code was first clearing the entire Editor selection before adding
the region, causing every note selection to trigger the RegionsChanged
pathway. This is crazy expensive for some reason (more than 8.12) and that
should be investigated, but the logic is also wrong. Selecting a region that is
alrready the sole selected region should not cause any action at all.
2025-06-24 18:11:13 -06:00
Paul Davis
b5f5aeafe7 use C++11 style iterator 2025-06-16 23:01:10 -06:00
Paul Davis
9342886e48 fix thinko in MidiView::pick_visible_channel() ... no data, channel is 0, not 16 2025-06-16 10:47:25 -06:00
Paul Davis
796497b355 remove debug output 2025-06-13 17:20:09 -06:00
Paul Davis
15079176ac get note display working in pianoroll PRH (needs set_visible_channel()) 2025-06-11 11:54:33 -06:00
Paul Davis
eefe584070 another round of fixing for note-to-y and y-to-note and note line setup 2025-06-09 09:29:52 -06:00
Paul Davis
1ed9876446 Change various positions and dimensions to integer from double
This includes note heights, note positions, contents height
for streamviews, positions of tracks. It makes zero sense to think of these as
having potentially fractional positions.

In addition, fractional note heights and positions lead to numerous
errors drawing MIDI stuff at the pixel level.
2025-06-02 19:28:10 -06:00
Paul Davis
6918a8a267 some rationalization to how Editor & CueEditor (Pianoroll) handle ZoomLevel and TimeOrigin changes 2025-05-19 14:57:19 -06:00
Paul Davis
711b12035e using C++17 auto map iterator syntax when iterating over MidiView::_events
Also, call NoteBase::show() and NoteBase::hide() rather than item()->show() or item()->hide()
2025-05-16 16:43:12 -06:00
Paul Davis
0ddb9fa8e2 fix erroneous deletion of notes after MIDI clip recording
If an idle data captured callback executed AFTER the code trigger by capture
end, it would call ::begin_write() which would end up calling clear_events()
which would delete all notes in the correctly setup MidiView.

Now, the idle data capture callback no longer does anything of significance if
the TriggerBox is not actively recording. In addition, we do not call
begin_write() in the MidiView if it is not already set up for capture
display (this is triggered by changes in the TriggerBox's record enable state
and the first data captured callback from an RT thread. Further,
::begin_write(), if called, only deletes notes that were in
_active_notes (though this should probably never happen).
2025-05-16 16:43:12 -06:00
Paul Davis
18c4040b77 fix crash/memory mgmt during MIDI clip recording
the active notes that are extended by transport rolling are
owned by MidiView::_events, not MidiView::_active_notes, so do not
delete them when cleaning up _active_notes.
2025-05-13 12:16:11 -06:00
Paul Davis
57efff5a1f NO-OP: fix spelling in a comment 2025-05-13 12:16:11 -06:00
Paul Davis
d68472115f in MidiViews, primary-scroll is always left unhandled so that horizontal zoom works everywhere 2025-04-29 10:49:34 -06:00
Paul Davis
f28e13fcdb NO-OP: fix named class type in a comment 2025-04-28 16:59:12 -06:00
Paul Davis
a41699737f fix bug in lifetime of MidiView::_ghost_note
As noted in 8b389ee829, we now clear the _note_group container
before any other Note items might be deleted. But since this
may delete the _ghost_note, we have to be sure to reset
that to a null ptr to avoid a double-free later during
~MidiView
2025-04-24 12:07:19 -06:00
Paul Davis
9415dad9cc fix the visible channel in a pianoroll if the model has no channel data 2025-04-16 20:43:10 -06:00
Paul Davis
1f4ddcd53f fix inheritance design error in MidiRegionView/MidiView
trim_front_(starting|ending) must be in a class derived from RegionView,
which MidiView is not.

This ensures that Carl's original design for this (with these two methods
called at the start and end of a front-trim drag) is still operational, and we
do not end up with MIDI regions that have a negative start value.
2025-04-08 15:50:30 -06:00
Paul Davis
0c924c3933 pianoroll: dragging start handle before zero shifts MIDI later in time 2025-04-08 15:50:30 -06:00
Paul Davis
8b389ee829 amend 365e3ef8e2 to be "more right"
NoteBase-derived note objects must delete their children, because
often they are deleted long before the parent (group) is. However,
in MidiView::clear_events() we used to call _note_group->clear (true)
first, which would delete the canvas items owned by these objects,
without them knowing about it. This made it dangerous for them
to delete those same items in their destructors.

This reverses the ordering so that NoteBase objects are deleted first
(along with their canvas items) and after that we clear _note_group
which will address any danging canvas items created there that are
not owned by a NoteBase-derived object
2025-03-25 14:49:49 -06:00
Paul Davis
65db08ac2b remove debug output 2025-03-25 11:17:05 -06:00
Paul Davis
ed0c55afb7 NOOP: whitespace/line removal 2025-03-24 11:43:33 -06:00
Paul Davis
dd1e1b16cc remove unused variable 2025-03-24 11:43:33 -06:00
Paul Davis
69174beb7b NOOP: add space before parens 2025-03-24 11:43:32 -06:00
Paul Davis
0a33701089 midiview: some more auto-fication 2025-03-24 11:43:32 -06:00
Paul Davis
e243f17eb1 pianoroll: hide trim handles when region is reset 2025-03-24 11:43:32 -06:00
Paul Davis
365e3ef8e2 midiview: correctly manage NoteBase lifetimes
MidiView::clear_events() deleted the canvas items corresponding to Notes/Hits,
but did not delete the owner NoteBase objects.
2025-03-24 11:43:32 -06:00
Paul Davis
51dbe70b44 no more trim cursor in drae mode in the pianoroll
For some reason, we allow users to trim notes on the timeline when in
draw mode. Not sure why. We don't allow this in pianorolls, so make
sure the cursors don't suggest otherwise
2025-03-20 14:14:08 -06:00
Paul Davis
05b8c6d2d3 some potential fixes for wierd note split/join behavior
the split_info for a MidiView would stick around across note selection
operations that really should act as a "boundary" or end of the
split op. This commit ends the split op any time selection is cleared
or notes are added to the selection (except when in the middle of a split
2025-03-19 17:34:33 -06:00
Paul Davis
e8d4f5e06d when a pianoroll shows an empty MIDI model, use the user prefs for the note range 2025-03-17 10:12:42 -06:00
Paul Davis
ef8f2579c1 if showing an empty model in a pianoroll, set the visible channel to 1 2025-03-17 10:00:44 -06:00
Paul Davis
c509de6814 work on fixing/improving MIDI region/track scrolling behavior 2025-03-14 13:24:49 -06:00
Paul Davis
53ffd61dd9 for pianoroll MidiViews, set _visible_channel to the lowest MIDI channel with notes present 2025-03-08 18:27:20 -07:00
Paul Davis
c0ed2fd9f5 fix vanishing notes during drag in a pianoroll 2025-03-08 12:14:17 -07:00
Paul Davis
8f4c10f855 subtle change in event handling for MidiViews
this needs more investigation but we need to return false from
scroll event handling in order for stuff to work. this should
not be the case and this will likely be reverted once the reason
it is required is uncovered
2025-03-06 18:12:40 -07:00
Paul Davis
a94bd4b7c6 rename MidiView::relative_position() to ::view_position_to_model_position() 2025-03-06 18:12:40 -07:00
Paul Davis
6d1c6bc239 slight rearrangement for MidiView::relative_position() 2025-03-06 18:12:40 -07:00
Paul Davis
2cadaafc4f NO-OP: follow style guide and use space in function call 2025-03-06 18:12:39 -07:00
Paul Davis
b9d69d3948 take _visible_channel into account for MidiView when drawing notes 2025-03-06 18:12:39 -07:00
Paul Davis
441cfe4e2d Make MidiView::relative_position() return correctly for _show_source case 2025-03-06 18:12:39 -07:00
Paul Davis
eb75064909 Modify comments and variable names in MidiView::create_note_at()
First argument is a source-relative position, not region-relative.
2025-03-06 18:12:39 -07:00
Paul Davis
67fa5282cb Remove Region::absolute_time_to_region_beats()
This method did not do what its name suggested. Replace it with
::absolute_time_to_source_beats() which already existed and
computed the same result.

Also in a NoteCreateDrag, correctly adjust note start
depending on whether we are viewing the whole source or
just the region. This part may be amended later.
2025-03-06 18:12:39 -07:00
Paul Davis
fcf086986a avoid logical op ambiguity 2025-03-04 14:57:50 -07:00
Paul Davis
b489d466cf commit crash caused by event-sensitive ghost note in MidiView 2025-03-04 12:18:29 -07:00