// // File: VLLayout.cpp - Dimensions for lead sheet layout // // Author(s): // // (MN) Matthias Neeracher // // Copyright © 2007 Matthias Neeracher // #include "VLLayout.h" #include "VLSheetViewInternal.h" #include #include #include VLSystemLayout::VLSystemLayout(const VLProperties & prop, float width, int maxMeas) { fDivisions = prop.fDivisions; fNumGroups = prop.fTime.fNum / std::max(prop.fTime.fDenom / 4, 1); fDivPerGroup = fDivisions * prop.fTime.fNum * 4 / (prop.fTime.fDenom * fNumGroups); fClefKeyWidth = kClefX+kClefW+(std::labs(prop.fKey)+1)*kKeyW; fMeasureWidth = fNumGroups*(fDivPerGroup+1)*kNoteW; fNumMeasures = std::min(maxMeas, std::max(1, std::floor((width-fClefKeyWidth) / fMeasureWidth))); } static size_t NextBreak(const VLSong & song, size_t after=0) { size_t propIdx = song.fMeasures[after].fPropIdx; while (++after < song.fMeasures.size()) if (song.fMeasures[after].fBreak || song.fMeasures[after].fPropIdx != propIdx) return after; return song.fMeasures.size(); } VLLayout::VLLayout(const VLSong & song, float width) { size_t nextBreak = NextBreak(song); for (size_t meas = 0; meas= nextBreak) nextBreak = NextBreak(song, nextBreak); } } int VLLayout::FirstMeasure(int system) const { int meas = 0; for (int sys=0; sys