Allow nested repeats

This commit is contained in:
Matthias Neeracher 2007-01-12 08:59:44 +00:00
parent 11dab83982
commit 8a9e650e75

View File

@ -1436,22 +1436,35 @@ void VLSong::DelEnding(size_t beginMeasure, size_t endMeasure)
bool VLSong::CanBeRepeat(size_t beginMeasure, size_t endMeasure, int * times) bool VLSong::CanBeRepeat(size_t beginMeasure, size_t endMeasure, int * times)
{ {
for (size_t r=0; r<fRepeats.size(); ++r) { for (size_t r=0; r<fRepeats.size(); ++r) {
if (fRepeats[r].fEndings[0].fBegin == beginMeasure) { const VLRepeat & rep = fRepeats[r];
if (rep.fEndings[0].fBegin == beginMeasure) {
// //
// Look for exact match & return // Look for exact match & return
// //
if (times) if (times)
*times = fRepeats[r].fTimes; *times = fRepeats[r].fTimes;
if (fRepeats[r].fEndings[0].fEnd == endMeasure) if (rep.fEndings[0].fEnd == endMeasure)
return true; return true;
if (fRepeats[r].fEndings.size() > 1) { if (rep.fEndings.size() > 1) {
if (fRepeats[r].fEndings[1].fBegin == endMeasure) if (rep.fEndings[1].fBegin == endMeasure)
return true; return true;
if (fRepeats[r].fEndings[1].fEnd == endMeasure) if (rep.fEndings[1].fEnd == endMeasure)
return true; return true;
} }
} }
// //
// Inclusions and surroundings are OK. Beginnings may match, but
// endings must not.
//
if (rep.fEndings[0].fBegin >= beginMeasure
&& rep.fEndings[0].fEnd < endMeasure
)
continue;
if (rep.fEndings[0].fBegin <= beginMeasure
&& rep.fEndings[0].fEnd > endMeasure
)
continue;
//
// Look for overlap and reject // Look for overlap and reject
// //
if (fRepeats[r].fEndings[0].fBegin >= beginMeasure if (fRepeats[r].fEndings[0].fBegin >= beginMeasure