mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Reorganize property access
This commit is contained in:
parent
80fbc00f56
commit
5615dee186
|
@ -28,8 +28,7 @@ VLSystemLayout::VLSystemLayout(const VLProperties & prop, float width)
|
||||||
VLLayout::VLLayout(const VLSong & song, float width)
|
VLLayout::VLLayout(const VLSong & song, float width)
|
||||||
{
|
{
|
||||||
for (size_t meas = 0; meas<song.fMeasures.size(); ) {
|
for (size_t meas = 0; meas<song.fMeasures.size(); ) {
|
||||||
const VLProperties & prop = song.fProperties[song.fMeasures[meas].fPropIdx];
|
push_back(VLSystemLayout(song.Properties(meas), width));
|
||||||
push_back(VLSystemLayout(prop, width));
|
|
||||||
meas += back().NumMeasures();
|
meas += back().NumMeasures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,7 @@ VLSong::VLSong(bool initialize)
|
||||||
|
|
||||||
void VLSong::AddMeasure()
|
void VLSong::AddMeasure()
|
||||||
{
|
{
|
||||||
VLFraction dur = fProperties.front().fTime;
|
VLFraction dur = fProperties.back().fTime;
|
||||||
dur.Normalize();
|
dur.Normalize();
|
||||||
VLLyricsNote rest(dur);
|
VLLyricsNote rest(dur);
|
||||||
VLChord rchord(dur);
|
VLChord rchord(dur);
|
||||||
|
@ -1914,8 +1914,8 @@ void VLSong::PasteMeasures(size_t beginMeasure, const VLSong & measures, int mod
|
||||||
void VLSong::DeleteMeasures(size_t beginMeasure, size_t endMeasure, int mode)
|
void VLSong::DeleteMeasures(size_t beginMeasure, size_t endMeasure, int mode)
|
||||||
{
|
{
|
||||||
if (mode == kOverwriteMelody) {
|
if (mode == kOverwriteMelody) {
|
||||||
VLLyricsNote rest(fProperties.front().fTime);
|
|
||||||
for (size_t m=beginMeasure; m<endMeasure; ++m) {
|
for (size_t m=beginMeasure; m<endMeasure; ++m) {
|
||||||
|
VLLyricsNote rest(Properties(m).fTime);
|
||||||
fMeasures[m].fMelody.clear();
|
fMeasures[m].fMelody.clear();
|
||||||
fMeasures[m].fMelody.push_back(rest);
|
fMeasures[m].fMelody.push_back(rest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,6 +362,12 @@ public:
|
||||||
size_t CountTopLedgers() const;
|
size_t CountTopLedgers() const;
|
||||||
size_t CountBotLedgers() const;
|
size_t CountBotLedgers() const;
|
||||||
VLFract TiedDuration(size_t measure);
|
VLFract TiedDuration(size_t measure);
|
||||||
|
VLProperties & Properties(size_t measure) {
|
||||||
|
return fProperties[fMeasures[measure].fPropIdx];
|
||||||
|
}
|
||||||
|
const VLProperties & Properties(size_t measure) const {
|
||||||
|
return fProperties[fMeasures[measure].fPropIdx];
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void AddMeasure();
|
void AddMeasure();
|
||||||
};
|
};
|
||||||
|
|
|
@ -295,8 +295,7 @@ VLMusicElement sSemi2Accidental[12][12] = {
|
||||||
|
|
||||||
const VLSystemLayout & kLayout = (*fLayout)[system];
|
const VLSystemLayout & kLayout = (*fLayout)[system];
|
||||||
const VLSong * song = [self song];
|
const VLSong * song = [self song];
|
||||||
const VLProperties & kProp =
|
const VLProperties & kProp = song->Properties(fLayout->FirstMeasure(system));
|
||||||
song->fProperties[song->fMeasures[fLayout->FirstMeasure(system)].fPropIdx];
|
|
||||||
|
|
||||||
const float kSystemY = [self systemY:system];
|
const float kSystemY = [self systemY:system];
|
||||||
const float kLineW = (*fLayout)[system].SystemWidth();
|
const float kLineW = (*fLayout)[system].SystemWidth();
|
||||||
|
@ -722,14 +721,15 @@ static int8_t sSharpAcc[] = {
|
||||||
{
|
{
|
||||||
fCursorPitch = VLNote::kNoPitch;
|
fCursorPitch = VLNote::kNoPitch;
|
||||||
|
|
||||||
const VLProperties & prop = [self song]->fProperties.front();
|
|
||||||
NSPoint loc = [event locationInWindow];
|
NSPoint loc = [event locationInWindow];
|
||||||
loc = [self convertPoint:loc fromView:nil];
|
loc = [self convertPoint:loc fromView:nil];
|
||||||
|
|
||||||
if (loc.y < 0.0f || loc.y >= fLayout->NumSystems()*kSystemH)
|
if (loc.y < 0.0f || loc.y >= fLayout->NumSystems()*kSystemH)
|
||||||
return fCursorRegion = kRegionNowhere;
|
return fCursorRegion = kRegionNowhere;
|
||||||
|
|
||||||
int system = fLayout->NumSystems() - static_cast<int>(loc.y / kSystemH) - 1;
|
const VLSong * song = [self song];
|
||||||
|
int system =
|
||||||
|
fLayout->NumSystems() - static_cast<int>(loc.y / kSystemH) - 1;
|
||||||
const VLSystemLayout & kLayout = (*fLayout)[system];
|
const VLSystemLayout & kLayout = (*fLayout)[system];
|
||||||
const float kMeasureW = kLayout.MeasureWidth();
|
const float kMeasureW = kLayout.MeasureWidth();
|
||||||
loc.y = fmodf(loc.y, kSystemH);
|
loc.y = fmodf(loc.y, kSystemH);
|
||||||
|
@ -760,12 +760,12 @@ static int8_t sSharpAcc[] = {
|
||||||
loc.x -= group*(kLayout.DivPerGroup()+1)*kNoteW;
|
loc.x -= group*(kLayout.DivPerGroup()+1)*kNoteW;
|
||||||
int div = static_cast<int>(roundf(loc.x / kNoteW))-1;
|
int div = static_cast<int>(roundf(loc.x / kNoteW))-1;
|
||||||
div = std::min(std::max(div, 0), kLayout.DivPerGroup()-1);
|
div = std::min(std::max(div, 0), kLayout.DivPerGroup()-1);
|
||||||
fCursorAt = VLFraction(div+group*kLayout.DivPerGroup(), 4*prop.fDivisions);
|
|
||||||
fCursorMeasure = measure+fLayout->FirstMeasure(system);
|
fCursorMeasure = measure+fLayout->FirstMeasure(system);
|
||||||
|
|
||||||
if (fCursorMeasure > [self song]->fMeasures.size())
|
if (fCursorMeasure > [self song]->fMeasures.size())
|
||||||
return fCursorRegion = kRegionNowhere;
|
return fCursorRegion = kRegionNowhere;
|
||||||
|
|
||||||
|
fCursorAt = VLFraction(div+group*kLayout.DivPerGroup(), 4*song->Properties(fCursorMeasure).fDivisions);
|
||||||
|
|
||||||
if (loc.y >= kSystemBaseline+kChordY) {
|
if (loc.y >= kSystemBaseline+kChordY) {
|
||||||
//
|
//
|
||||||
// Chord, round to quarters
|
// Chord, round to quarters
|
||||||
|
|
|
@ -103,7 +103,7 @@ std::string NormalizeName(NSString* rawName)
|
||||||
//
|
//
|
||||||
VLSoundOut::Instance()->PlayChord(*chord);
|
VLSoundOut::Instance()->PlayChord(*chord);
|
||||||
|
|
||||||
const VLProperties & prop = fSong->fProperties.front();
|
const VLProperties & prop = fSong->Properties(fMeasure);
|
||||||
std::string name, ext, root;
|
std::string name, ext, root;
|
||||||
chord->Name(name, ext, root, prop.fKey > 0);
|
chord->Name(name, ext, root, prop.fKey > 0);
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
VLFraction at = fAt;
|
VLFraction at = fAt;
|
||||||
if (!fSong->PrevWord(fStanza, fMeasure, at)) {
|
if (!fSong->PrevWord(fStanza, fMeasure, at)) {
|
||||||
fMeasure = fSong->CountMeasures()-1;
|
fMeasure = fSong->CountMeasures()-1;
|
||||||
at = fSong->fProperties.front().fTime;
|
at = fSong->Properties(fMeasure).fTime;
|
||||||
fSong->PrevWord(fStanza, fMeasure, at);
|
fSong->PrevWord(fStanza, fMeasure, at);
|
||||||
}
|
}
|
||||||
fAt = at;
|
fAt = at;
|
||||||
|
|
|
@ -279,8 +279,7 @@
|
||||||
{
|
{
|
||||||
const int kFirstMeas = fLayout->FirstMeasure(system);
|
const int kFirstMeas = fLayout->FirstMeasure(system);
|
||||||
const VLSong * song = [self song];
|
const VLSong * song = [self song];
|
||||||
const VLProperties & kProp =
|
const VLProperties & kProp = song->Properties(kFirstMeas);
|
||||||
song->fProperties[song->fMeasures[kFirstMeas].fPropIdx];
|
|
||||||
const VLSystemLayout & kLayout = (*fLayout)[system];
|
const VLSystemLayout & kLayout = (*fLayout)[system];
|
||||||
|
|
||||||
float kSystemY = [self systemY:system];
|
float kSystemY = [self systemY:system];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user