mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Start introducing section support
This commit is contained in:
parent
ee87f6a76b
commit
efbc96a7f8
1944
English.lproj/MainMenu.nib/designable.nib
generated
1944
English.lproj/MainMenu.nib/designable.nib
generated
File diff suppressed because it is too large
Load Diff
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -29,8 +29,9 @@ VLSystemLayout::VLSystemLayout(const VLProperties & prop, float width, int maxMe
|
||||||
|
|
||||||
static size_t NextBreak(const VLSong & song, size_t after=0)
|
static size_t NextBreak(const VLSong & song, size_t after=0)
|
||||||
{
|
{
|
||||||
|
size_t propIdx = song.fMeasures[after].fPropIdx;
|
||||||
while (++after < song.fMeasures.size())
|
while (++after < song.fMeasures.size())
|
||||||
if (song.fMeasures[after].fBreak)
|
if (song.fMeasures[after].fBreak || song.fMeasures[after].fPropIdx != propIdx)
|
||||||
return after;
|
return after;
|
||||||
return song.fMeasures.size();
|
return song.fMeasures.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1985,6 +1985,36 @@ VLFract VLSong::TiedDuration(size_t measure)
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VLSong::DoesBeginSection(size_t measure)
|
||||||
|
{
|
||||||
|
return measure && measure < fMeasures.size()
|
||||||
|
&& fMeasures[measure-1].fPropIdx!=fMeasures[measure].fPropIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VLSong::AddSection(size_t measure)
|
||||||
|
{
|
||||||
|
int splitIdx = fMeasures[measure].fPropIdx;
|
||||||
|
|
||||||
|
VLProperties newProp = fProperties[splitIdx];
|
||||||
|
if (splitIdx < fProperties.size()-1)
|
||||||
|
fProperties.insert(fProperties.begin()+splitIdx, newProp);
|
||||||
|
else
|
||||||
|
fProperties.push_back(newProp);
|
||||||
|
while (measure < fMeasures.size())
|
||||||
|
++fMeasures[measure++].fPropIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VLSong::DelSection(size_t measure)
|
||||||
|
{
|
||||||
|
int delIdx = fMeasures[measure].fPropIdx;
|
||||||
|
|
||||||
|
fProperties.erase(fProperties.begin()+delIdx);
|
||||||
|
while (measure < fMeasures.size())
|
||||||
|
--fMeasures[measure++].fPropIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////// VLSongVisitor ////////////////////////////////
|
||||||
|
|
||||||
VLSongVisitor::~VLSongVisitor()
|
VLSongVisitor::~VLSongVisitor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,6 @@ public:
|
||||||
void PasteMeasures(size_t beginMeasure, const VLSong & measures,
|
void PasteMeasures(size_t beginMeasure, const VLSong & measures,
|
||||||
int mode = kInsert);
|
int mode = kInsert);
|
||||||
void DeleteMeasures(size_t beginMeasure, size_t endMeasure, int mode = kInsert);
|
void DeleteMeasures(size_t beginMeasure, size_t endMeasure, int mode = kInsert);
|
||||||
|
|
||||||
size_t CountMeasures() const { return fMeasures.size(); }
|
size_t CountMeasures() const { return fMeasures.size(); }
|
||||||
size_t EmptyEnding() const;
|
size_t EmptyEnding() const;
|
||||||
size_t CountStanzas() const;
|
size_t CountStanzas() const;
|
||||||
|
@ -373,6 +372,10 @@ public:
|
||||||
const VLProperties & Properties(size_t measure) const {
|
const VLProperties & Properties(size_t measure) const {
|
||||||
return fProperties[fMeasures[measure].fPropIdx];
|
return fProperties[fMeasures[measure].fPropIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DoesBeginSection(size_t measure);
|
||||||
|
void AddSection(size_t measure);
|
||||||
|
void DelSection(size_t measure);
|
||||||
private:
|
private:
|
||||||
void AddMeasure();
|
void AddMeasure();
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,9 +80,13 @@ static VLSong sPasteboard;
|
||||||
return NO;
|
return NO;
|
||||||
else if (action == @selector(insertBreak:))
|
else if (action == @selector(insertBreak:))
|
||||||
if (fSelStart == fSelEnd && fSelStart > 0) {
|
if (fSelStart == fSelEnd && fSelStart > 0) {
|
||||||
VLSong * song = [self song];
|
VLSong * song = [self song];
|
||||||
[item setState:fSelStart < song->fMeasures.size()
|
bool checked = fSelStart < song->fMeasures.size();
|
||||||
&& song->fMeasures[fSelStart].fBreak == [item tag]];
|
if ([item tag] == 256)
|
||||||
|
checked = checked && song->DoesBeginSection(fSelStart);
|
||||||
|
else
|
||||||
|
checked = checked && song->fMeasures[fSelStart].fBreak == [item tag];
|
||||||
|
[item setState:checked];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
} else
|
} else
|
||||||
|
@ -275,11 +279,18 @@ static VLSong sPasteboard;
|
||||||
{
|
{
|
||||||
[[self document] willChangeSong];
|
[[self document] willChangeSong];
|
||||||
VLSong * song = [self song];
|
VLSong * song = [self song];
|
||||||
VLMeasure & meas = song->fMeasures[fSelStart];
|
if ([sender tag] == 256) {
|
||||||
if (meas.fBreak == [sender tag])
|
if (song->DoesBeginSection(fSelStart))
|
||||||
meas.fBreak = 0;
|
song->DelSection(fSelStart);
|
||||||
else
|
else
|
||||||
meas.fBreak = [sender tag];
|
song->AddSection(fSelStart);
|
||||||
|
} else {
|
||||||
|
VLMeasure & meas = song->fMeasures[fSelStart];
|
||||||
|
if (meas.fBreak == [sender tag])
|
||||||
|
meas.fBreak = 0;
|
||||||
|
else
|
||||||
|
meas.fBreak = [sender tag];
|
||||||
|
}
|
||||||
fNeedsRecalc = kRecalc;
|
fNeedsRecalc = kRecalc;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
[[self document] didChangeSong];
|
[[self document] didChangeSong];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user