Automatic default line breaking

This commit is contained in:
Matthias Neeracher 2008-08-15 13:25:42 +00:00
parent 740da1f567
commit d4fc80020d
2 changed files with 20 additions and 4 deletions

View File

@ -23,6 +23,14 @@ void VLLilypondWriter::Visit(VLSong & song)
fSeenEnding = 0; fSeenEnding = 0;
fNumEndings = 0; fNumEndings = 0;
fLastProp = 0; fLastProp = 0;
fNumPickup = 0;
fAutomaticLayout = true;
for (int i=0; i<song.fMeasures.size(); ++i)
if (song.fMeasures[i].fBreak & VLMeasure::kNewSystem) {
fAutomaticLayout = false;
break;
}
VisitMeasures(song, false); VisitMeasures(song, false);
// //
@ -41,7 +49,8 @@ void VLLilypondWriter::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas
measNo[0] = 0; measNo[0] = 0;
fUseSharps = p.fKey > 0; fUseSharps = p.fKey > 0;
fInPickup = fInPickup && !m && meas.NoChords(); if (fInPickup = fInPickup && !m && meas.NoChords())
++fNumPickup;
// //
// Generate chords // Generate chords
@ -83,11 +92,16 @@ void VLLilypondWriter::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas
size_t volta; size_t volta;
bool repeat; bool repeat;
bool hasBarLine = false; bool hasBarLine = false;
if (meas.fBreak == VLMeasure::kNewPage) { if (fAutomaticLayout) {
if (m > fNumPickup && !((m-fNumPickup) % 4)) {
fAccum += fIndent+"\\break\n";
hasBarLine = true;
}
} else if (meas.fBreak & VLMeasure::kNewPage) {
fAccum += fIndent+"\\pageBreak\n"; fAccum += fIndent+"\\pageBreak\n";
hasBarLine = true; hasBarLine = true;
} else if (meas.fBreak == VLMeasure::kNewSystem) { } else if (meas.fBreak & VLMeasure::kNewSystem) {
fAccum += fIndent+"\\break\n"; fAccum += fIndent+"\\break\n";
hasBarLine = true; hasBarLine = true;
} }

View File

@ -30,6 +30,8 @@ private:
VLSong * fSong; VLSong * fSong;
bool fUseSharps; bool fUseSharps;
bool fInPickup; bool fInPickup;
bool fAutomaticLayout;
int fNumPickup;
size_t fSeenEnding; size_t fSeenEnding;
int fNumEndings; int fNumEndings;
VLNote fPrevNote; VLNote fPrevNote;