change Selection object to be more clear about the status of MidiRegionViews and notes
1) Notes are only present in a Selection object if it is being used as a cut buffer. They are never stored there as part of "normal selection" - that is delegated/left to MidiRegionViews that own the notes. 2) MidiRegionViews are stored in the Selection as "just" RegionViews, so provide a convenience method to access them. This doesn't actually change much, since even the old MidiRegions object was actually just a RegionSelection i.e. RegionViews.
This commit is contained in:
parent
abe275c3e0
commit
ba424352a2
|
@ -104,8 +104,7 @@ operator== (const Selection& a, const Selection& b)
|
|||
a.time == b.time &&
|
||||
a.lines == b.lines &&
|
||||
a.playlists == b.playlists &&
|
||||
a.midi_notes == b.midi_notes &&
|
||||
a.midi_regions == b.midi_regions;
|
||||
a.midi_notes == b.midi_notes;
|
||||
}
|
||||
|
||||
/** Clear everything from the Selection */
|
||||
|
@ -119,7 +118,6 @@ Selection::clear ()
|
|||
clear_time ();
|
||||
clear_playlists ();
|
||||
clear_midi_notes ();
|
||||
clear_midi_regions ();
|
||||
clear_markers ();
|
||||
pending_midi_note_selection.clear();
|
||||
}
|
||||
|
@ -132,7 +130,6 @@ Selection::clear_objects (bool with_signal)
|
|||
clear_lines(with_signal);
|
||||
clear_playlists (with_signal);
|
||||
clear_midi_notes (with_signal);
|
||||
clear_midi_regions (with_signal);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -168,6 +165,10 @@ Selection::clear_regions (bool with_signal)
|
|||
void
|
||||
Selection::clear_midi_notes (bool with_signal)
|
||||
{
|
||||
/* Remmeber: MIDI notes are only stored here if we're using a Selection
|
||||
object as a cut buffer.
|
||||
*/
|
||||
|
||||
if (!midi_notes.empty()) {
|
||||
for (MidiNoteSelection::iterator x = midi_notes.begin(); x != midi_notes.end(); ++x) {
|
||||
delete *x;
|
||||
|
@ -177,30 +178,6 @@ Selection::clear_midi_notes (bool with_signal)
|
|||
MidiNotesChanged ();
|
||||
}
|
||||
}
|
||||
|
||||
// clear note selections for MRV's that have note selections
|
||||
// this will cause the MRV to be removed from the list
|
||||
for (MidiRegionSelection::iterator i = midi_regions.begin();
|
||||
i != midi_regions.end();) {
|
||||
MidiRegionSelection::iterator tmp = i;
|
||||
++tmp;
|
||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
|
||||
if (mrv) {
|
||||
mrv->clear_selection();
|
||||
}
|
||||
i = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Selection::clear_midi_regions (bool with_signal)
|
||||
{
|
||||
if (!midi_regions.empty()) {
|
||||
midi_regions.clear ();
|
||||
if (with_signal) {
|
||||
MidiRegionsChanged ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -307,23 +284,6 @@ Selection::toggle (RegionView* r)
|
|||
RegionsChanged ();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::toggle (MidiRegionView* mrv)
|
||||
{
|
||||
clear_time(); // enforce object/range exclusivity
|
||||
clear_tracks(); // enforce object/track exclusivity
|
||||
|
||||
MidiRegionSelection::iterator i;
|
||||
|
||||
if ((i = find (midi_regions.begin(), midi_regions.end(), mrv)) == midi_regions.end()) {
|
||||
add (mrv);
|
||||
} else {
|
||||
midi_regions.erase (i);
|
||||
}
|
||||
|
||||
MidiRegionsChanged ();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::toggle (vector<RegionView*>& r)
|
||||
{
|
||||
|
@ -474,21 +434,6 @@ Selection::add (RegionView* r)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Selection::add (MidiRegionView* mrv)
|
||||
{
|
||||
DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::add MRV %1\n", mrv));
|
||||
|
||||
clear_time(); // enforce object/range exclusivity
|
||||
clear_tracks(); // enforce object/track exclusivity
|
||||
|
||||
if (find (midi_regions.begin(), midi_regions.end(), mrv) == midi_regions.end()) {
|
||||
midi_regions.push_back (mrv);
|
||||
/* XXX should we do this? */
|
||||
MidiRegionsChanged ();
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
Selection::add (samplepos_t start, samplepos_t end)
|
||||
{
|
||||
|
@ -648,19 +593,6 @@ Selection::remove (RegionView* r)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Selection::remove (MidiRegionView* mrv)
|
||||
{
|
||||
DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::remove MRV %1\n", mrv));
|
||||
|
||||
MidiRegionSelection::iterator x;
|
||||
|
||||
if ((x = find (midi_regions.begin(), midi_regions.end(), mrv)) != midi_regions.end()) {
|
||||
midi_regions.erase (x);
|
||||
MidiRegionsChanged ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Selection::remove (uint32_t selection_id)
|
||||
{
|
||||
|
@ -737,17 +669,6 @@ Selection::set (const RegionSelection& rs)
|
|||
RegionsChanged(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
void
|
||||
Selection::set (MidiRegionView* mrv)
|
||||
{
|
||||
if (mrv) {
|
||||
clear_time(); // enforce region/object exclusivity
|
||||
clear_tracks(); // enforce object/track exclusivity
|
||||
}
|
||||
clear_objects ();
|
||||
add (mrv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::set (RegionView* r, bool /*also_clear_tracks*/)
|
||||
{
|
||||
|
@ -872,8 +793,7 @@ Selection::empty (bool internal_selection)
|
|||
lines.empty () &&
|
||||
time.empty () &&
|
||||
playlists.empty () &&
|
||||
markers.empty() &&
|
||||
midi_regions.empty()
|
||||
markers.empty()
|
||||
;
|
||||
|
||||
if (!internal_selection) {
|
||||
|
@ -1702,3 +1622,18 @@ Selection::core_selection_changed (PropertyChange const & what_changed)
|
|||
|
||||
TracksChanged();
|
||||
}
|
||||
|
||||
MidiRegionSelection
|
||||
Selection::midi_regions ()
|
||||
{
|
||||
MidiRegionSelection ms;
|
||||
|
||||
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
|
||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
|
||||
if (mrv) {
|
||||
ms.add (mrv);
|
||||
}
|
||||
}
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
|
|
@ -90,11 +90,15 @@ public:
|
|||
PlaylistSelection playlists;
|
||||
PointSelection points;
|
||||
MarkerSelection markers;
|
||||
MidiRegionSelection midi_regions;
|
||||
|
||||
/** only used when this class is used as a cut buffer */
|
||||
MidiNoteSelection midi_notes;
|
||||
|
||||
/** we don't store MidiRegionViews in their own selection, we just pull
|
||||
* them from "regions" as a convenience for various operations.
|
||||
*/
|
||||
MidiRegionSelection midi_regions();
|
||||
|
||||
Selection (PublicEditor const * e, bool manage_libardour_selection);
|
||||
|
||||
// Selection& operator= (const Selection& other);
|
||||
|
@ -107,7 +111,6 @@ public:
|
|||
sigc::signal<void> PointsChanged;
|
||||
sigc::signal<void> MarkersChanged;
|
||||
sigc::signal<void> MidiNotesChanged;
|
||||
sigc::signal<void> MidiRegionsChanged;
|
||||
|
||||
void clear ();
|
||||
|
||||
|
@ -132,7 +135,6 @@ public:
|
|||
void set (const TrackViewList&);
|
||||
void set (const MidiNoteSelection&);
|
||||
void set (RegionView*, bool also_clear_tracks = true);
|
||||
void set (MidiRegionView*);
|
||||
void set (std::vector<RegionView*>&);
|
||||
long set (samplepos_t, samplepos_t);
|
||||
void set_preserving_all_ranges (samplepos_t, samplepos_t);
|
||||
|
@ -147,7 +149,6 @@ public:
|
|||
void toggle (const TrackViewList&);
|
||||
void toggle (const MidiNoteSelection&);
|
||||
void toggle (RegionView*);
|
||||
void toggle (MidiRegionView*);
|
||||
void toggle (MidiCutBuffer*);
|
||||
void toggle (std::vector<RegionView*>&);
|
||||
long toggle (samplepos_t, samplepos_t);
|
||||
|
@ -162,7 +163,6 @@ public:
|
|||
void add (const TrackViewList&);
|
||||
void add (const MidiNoteSelection&);
|
||||
void add (RegionView*);
|
||||
void add (MidiRegionView*);
|
||||
void add (MidiCutBuffer*);
|
||||
void add (std::vector<RegionView*>&);
|
||||
long add (samplepos_t, samplepos_t);
|
||||
|
@ -179,7 +179,6 @@ public:
|
|||
void remove (const TrackViewList&);
|
||||
void remove (const MidiNoteSelection&);
|
||||
void remove (RegionView*);
|
||||
void remove (MidiRegionView*);
|
||||
void remove (MidiCutBuffer*);
|
||||
void remove (uint32_t selection_id);
|
||||
void remove (samplepos_t, samplepos_t);
|
||||
|
@ -219,7 +218,6 @@ public:
|
|||
void clear_points (bool with_signal = true);
|
||||
void clear_markers (bool with_signal = true);
|
||||
void clear_midi_notes (bool with_signal = true);
|
||||
void clear_midi_regions (bool with_signal = true);
|
||||
|
||||
void foreach_region (void (ARDOUR::Region::*method)(void));
|
||||
void foreach_regionview (void (RegionView::*method)(void));
|
||||
|
|
Loading…
Reference in New Issue
Block a user