13
0

give Regions an access method for Cue Markers

This commit is contained in:
Paul Davis 2021-05-13 14:53:17 -06:00
parent 39b020a3f4
commit 7e7fbf6073
3 changed files with 24 additions and 0 deletions

View File

@ -373,6 +373,8 @@ public:
_changemap = changemap;
}
void get_cue_markers (CueMarkers&, bool abs = false) const;
protected:
virtual XMLNode& state ();

View File

@ -112,6 +112,8 @@ public:
XrunPositions const& captured_xruns () const { return _xruns; }
void set_captured_xruns (XrunPositions const& xruns) { _xruns = xruns; }
CueMarkers const & cue_markers() const { return _cue_markers; }
virtual samplepos_t natural_position() const { return _natural_position; }
virtual void set_natural_position (samplepos_t pos);
bool have_natural_position() const { return _have_natural_position; }

View File

@ -1922,6 +1922,26 @@ Region::captured_xruns (XrunPositions& xruns, bool abs) const
}
}
void
Region::get_cue_markers (CueMarkers& cues, bool abs) const
{
bool was_empty = cues.empty ();
for (SourceList::const_iterator i = _sources.begin (); i != _sources.end(); ++i) {
CueMarkers const& x = (*i)->cue_markers ();
for (CueMarkers::const_iterator p = x.begin (); p != x.end (); ++p) {
if (abs) {
cues.push_back (*p);
} else if (p->position() >= _start && p->position() < _start + _length) {
cues.push_back (CueMarker (p->text(), p->position() - _start));
}
}
}
if (_sources.size () > 1 || !was_empty) {
sort (cues.begin (), cues.end ());
cues.erase (unique (cues.begin (), cues.end ()), cues.end ());
}
}
void
Region::drop_sources ()
{