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