mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 11:14:00 +00:00
Much more convenient lyrics editing
This commit is contained in:
parent
54ae06ae81
commit
7c5f28ede9
|
@ -1326,7 +1326,7 @@ std::string VLSong::GetWord(size_t stanza, size_t measure, VLFraction at)
|
|||
return word;
|
||||
}
|
||||
|
||||
void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string word)
|
||||
void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string word, size_t * nextMeas, VLFract * nextAt)
|
||||
{
|
||||
uint8_t kind = 0;
|
||||
bool cleanup = false;
|
||||
|
@ -1347,30 +1347,63 @@ void VLSong::SetWord(size_t stanza, size_t measure, VLFraction at, std::string w
|
|||
if (note->fLyrics.size() >= stanza)
|
||||
note->fLyrics[stanza-1].fKind &= ~VLSyllable::kHasPrev;
|
||||
|
||||
if (nextMeas)
|
||||
*nextMeas = measure;
|
||||
if (nextAt)
|
||||
*nextAt = now;
|
||||
|
||||
return;
|
||||
}
|
||||
if (note->fLyrics.size()<stanza)
|
||||
note->fLyrics.resize(stanza);
|
||||
size_t root = word.find('-');
|
||||
size_t sep = word.find_first_of(" \t-");
|
||||
size_t esp;
|
||||
std::string syll;
|
||||
if (root == std::string::npos) {
|
||||
syll = word;
|
||||
char type= 0;
|
||||
if (sep == std::string::npos) {
|
||||
esp = sep;
|
||||
syll= word;
|
||||
} else {
|
||||
esp = word.find_first_not_of(" \t-", sep);
|
||||
syll= word.substr(0, sep);
|
||||
if (esp != std::string::npos) {
|
||||
size_t tpos = word.substr(sep, esp-sep).find('-');
|
||||
type = (tpos != std::string::npos) ? '-' : ' ';
|
||||
word.erase(0, esp);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
default:
|
||||
//
|
||||
// Last syllable in text
|
||||
//
|
||||
kind &= ~VLSyllable::kHasNext;
|
||||
cleanup = true;
|
||||
} else {
|
||||
syll = word.substr(0, root);
|
||||
word.erase(0, root+1);
|
||||
break;
|
||||
case ' ':
|
||||
//
|
||||
// Last syllable in word
|
||||
//
|
||||
kind &= ~VLSyllable::kHasNext;
|
||||
break;
|
||||
case '-':
|
||||
kind |= VLSyllable::kHasNext;
|
||||
break;
|
||||
}
|
||||
note->fLyrics[stanza-1].fText = syll;
|
||||
note->fLyrics[stanza-1].fKind = kind;
|
||||
kind |= VLSyllable::kHasPrev;
|
||||
if (type == '-')
|
||||
kind |= VLSyllable::kHasPrev;
|
||||
}
|
||||
now += note->fDuration;
|
||||
++note;
|
||||
}
|
||||
at = 0;
|
||||
} while (++measure < fMeasures.size());
|
||||
if (nextMeas)
|
||||
*nextMeas = 0;
|
||||
if (nextAt)
|
||||
*nextAt = VLFraction(0);
|
||||
}
|
||||
|
||||
void VLSong::AddRepeat(size_t beginMeasure, size_t endMeasure, int times)
|
||||
|
|
|
@ -333,7 +333,8 @@ struct VLSong {
|
|||
bool PrevWord(size_t stanza, size_t & measure, VLFraction & at);
|
||||
bool NextWord(size_t stanza, size_t & measure, VLFraction & at);
|
||||
std::string GetWord(size_t stanza, size_t measure, VLFraction at);
|
||||
void SetWord(size_t stanza, size_t measure, VLFraction at, std::string word);
|
||||
void SetWord(size_t stanza, size_t measure, VLFraction at, std::string word,
|
||||
size_t * nextMeas=0, VLFract * nextAt=0);
|
||||
|
||||
enum {
|
||||
kInsert,
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
size_t fStanza;
|
||||
size_t fMeasure;
|
||||
VLFract fAt;
|
||||
size_t fNextMeas;
|
||||
VLFract fNextAt;
|
||||
}
|
||||
|
||||
- (VLLyricsEditable *)initWithView:(VLSheetView *)view
|
||||
|
|
|
@ -22,12 +22,14 @@
|
|||
measure:(int)measure
|
||||
at:(VLFract)at
|
||||
{
|
||||
self = [super init];
|
||||
fView = view;
|
||||
fSong = song;
|
||||
fStanza = stanza;
|
||||
fMeasure= measure;
|
||||
fAt = at;
|
||||
self = [super init];
|
||||
fView = view;
|
||||
fSong = song;
|
||||
fStanza = stanza;
|
||||
fMeasure = measure;
|
||||
fAt = at;
|
||||
fNextMeas = fMeasure;
|
||||
fNextAt = fAt;
|
||||
|
||||
VLFraction At = fAt;
|
||||
fSong->FindWord(fStanza, fMeasure, At);
|
||||
|
@ -47,7 +49,7 @@
|
|||
- (void) setStringValue:(NSString *)val
|
||||
{
|
||||
[[fView document] willChangeSong];
|
||||
fSong->SetWord(fStanza, fMeasure, fAt, [val UTF8String]);
|
||||
fSong->SetWord(fStanza, fMeasure, fAt, [val UTF8String], &fNextMeas, &fNextAt);
|
||||
[[fView document] didChangeSong];
|
||||
}
|
||||
|
||||
|
@ -58,13 +60,22 @@
|
|||
|
||||
- (void) moveToNext
|
||||
{
|
||||
VLFraction at = fAt;
|
||||
if (!fSong->NextWord(fStanza, fMeasure, at)) {
|
||||
fMeasure = 0;
|
||||
at = 0;
|
||||
if (fNextMeas != fMeasure || fNextAt != fAt) {
|
||||
fMeasure = fNextMeas;
|
||||
VLFraction at = fNextAt;
|
||||
fSong->FindWord(fStanza, fMeasure, at);
|
||||
fAt = at;
|
||||
} else {
|
||||
VLFraction at = fAt;
|
||||
if (!fSong->NextWord(fStanza, fMeasure, at)) {
|
||||
fMeasure = 0;
|
||||
at = 0;
|
||||
fSong->FindWord(fStanza, fMeasure, at);
|
||||
}
|
||||
fAt = at;
|
||||
}
|
||||
fAt = at;
|
||||
fNextMeas = fMeasure;
|
||||
fNextAt = fAt;
|
||||
}
|
||||
|
||||
- (void) moveToPrev
|
||||
|
@ -76,6 +87,8 @@
|
|||
fSong->PrevWord(fStanza, fMeasure, at);
|
||||
}
|
||||
fAt = at;
|
||||
fNextMeas = fMeasure;
|
||||
fNextAt = fAt;
|
||||
}
|
||||
|
||||
- (void) highlightCursor
|
||||
|
|
Loading…
Reference in New Issue
Block a user