Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions src/engraving/rendering/score/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ System* SystemLayout::collectSystem(LayoutContext& ctx)
}
}

updateBigTimeSigIfNeeded(system, ctx);
updateTimeSigAboveStavesXPos(system, ctx);

// Recompute spacing to account for the last changes (barlines, hidden staves, etc)
curSysWidth = HorizontalSpacing::computeSpacingForFullSystem(system);
Expand All @@ -420,6 +420,8 @@ System* SystemLayout::collectSystem(LayoutContext& ctx)
HorizontalSpacing::justifySystem(system, curSysWidth, targetSystemWidth);
}

clearBigTimeSigNotShown(system, ctx);

// LAYOUT MEASURES
bool createBrackets = false;
for (MeasureBase* mb : system->measures()) {
Expand Down Expand Up @@ -765,7 +767,7 @@ bool SystemLayout::canChangeSysStaffVisibility(const System* system, const staff
return true;
}

void SystemLayout::updateBigTimeSigIfNeeded(System* system, LayoutContext& ctx)
void SystemLayout::updateTimeSigAboveStavesXPos(System* system, LayoutContext& ctx)
{
if (ctx.conf().styleV(Sid::timeSigPlacement).value<TimeSigPlacement>() != TimeSigPlacement::ABOVE_STAVES) {
return;
Expand All @@ -774,7 +776,11 @@ void SystemLayout::updateBigTimeSigIfNeeded(System* system, LayoutContext& ctx)
staff_idx_t nstaves = ctx.dom().nstaves();
bool centerOnBarline = ctx.conf().styleB(Sid::timeSigCenterOnBarline);

for (Measure* measure = system->firstMeasure(); measure; measure = measure->nextMeasure()) {
for (MeasureBase* mb : system->measures()) {
if (!mb->isMeasure()) {
continue;
}
Measure* measure = toMeasure(mb);
for (Segment& seg : measure->segments()) {
if (!seg.isType(SegmentType::TimeSigType)) {
continue;
Expand Down Expand Up @@ -868,6 +874,33 @@ void SystemLayout::updateBigTimeSigIfNeeded(System* system, LayoutContext& ctx)
}
}

void SystemLayout::clearBigTimeSigNotShown(System* system, LayoutContext& ctx)
{
if (ctx.conf().styleV(Sid::timeSigPlacement).value<TimeSigPlacement>() == TimeSigPlacement::NORMAL) {
return;
}

for (MeasureBase* mb : system->measures()) {
if (!mb->isMeasure()) {
continue;
}
for (Segment& seg : toMeasure(mb)->segments()) {
if (!seg.isType(SegmentType::TimeSigType)) {
continue;
}
for (staff_idx_t staffIdx = 0; staffIdx < ctx.dom().nstaves(); ++staffIdx) {
TimeSig* ts = toTimeSig(seg.element(staff2track(staffIdx)));
if (!ts) {
continue;
}
if (!ts->showOnThisStaff() || ts->effectiveStaffIdx() == muse::nidx) {
ts->mutldata()->reset(); // Deletes shape
}
}
}
}
}

void SystemLayout::layoutSticking(const std::vector<Sticking*> stickings, System* system, LayoutContext& ctx)
{
if (stickings.empty()) {
Expand Down Expand Up @@ -3044,8 +3077,10 @@ void SystemLayout::centerBigTimeSigsAcrossStaves(const System* system)
TimeSig* nextTimeSig = toTimeSig(segment.element(staff2track(idx)));
if (nextTimeSig && nextTimeSig->showOnThisStaff()) {
staff_idx_t nextTimeSigStave = nextTimeSig->effectiveStaffIdx();
nextStaffIdx = system->prevVisibleStaff(nextTimeSigStave);
break;
if (nextTimeSigStave != muse::nidx) {
nextStaffIdx = system->prevVisibleStaff(nextTimeSigStave);
break;
}
}
if (idx == nstaves - 1) {
nextStaffIdx = system->prevVisibleStaff(nstaves);
Expand Down
3 changes: 2 additions & 1 deletion src/engraving/rendering/score/systemlayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class SystemLayout

static bool shouldBeJustified(System* system, double curSysWidth, double targetSystemWidth, LayoutContext& ctx);

static void updateBigTimeSigIfNeeded(System* system, LayoutContext& ctx);
static void updateTimeSigAboveStavesXPos(System* system, LayoutContext& ctx);
static void clearBigTimeSigNotShown(System* system, LayoutContext& ctx);

static void layoutSticking(const std::vector<Sticking*> stickings, System* system, LayoutContext& ctx);

Expand Down
51 changes: 31 additions & 20 deletions src/importexport/musicxml/internal/export/exportmusicxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class ExportMusicXml : public muse::Contextable
void dynamic(Dynamic const* const dyn, staff_idx_t staff);
void systemText(StaffTextBase const* const text, staff_idx_t staff);
void tempoText(TempoText const* const text, staff_idx_t staff);
void swingSound(StaffTextBase const* const text);
void tempoSound(TempoText const* const text);
void harmony(Harmony const* const, FretDiagram const* const fd, const Fraction& offset = Fraction(0, 1));
Score* score() const { return m_score; }
Expand Down Expand Up @@ -5027,6 +5028,27 @@ void ExportMusicXml::tempoSound(TempoText const* const text)
m_xml.tag("sound", { { "tempo", bpmRounded } });
}

void ExportMusicXml::swingSound(StaffTextBase const* const text)
{
m_xml.startElement("sound");
m_xml.startElement("swing");
if (!text->swingParameters().swingUnit) {
m_xml.tag("straight");
} else {
const int swingPercentage = text->swingParameters().swingRatio;
const int swingDivisor = std::gcd(text->swingParameters().swingRatio, 100);
m_xml.tag("first", 100 / swingDivisor);
m_xml.tag("second", swingPercentage / swingDivisor);
if (text->swingParameters().swingUnit == Constants::DIVISION / 2) {
m_xml.tag("swing-type", TConv::toXml(DurationType::V_EIGHTH));
} else {
m_xml.tag("swing-type", TConv::toXml(DurationType::V_16TH));
}
}
m_xml.endElement();
m_xml.endElement();
}

//---------------------------------------------------------
// playText
//---------------------------------------------------------
Expand Down Expand Up @@ -5114,23 +5136,7 @@ void ExportMusicXml::systemText(StaffTextBase const* const text, staff_idx_t sta
wordsMetronome(m_xml, m_score->style(), text, offset);

if (text->swing()) {
m_xml.startElement("sound");
m_xml.startElement("swing");
if (!text->swingParameters().swingUnit) {
m_xml.tag("straight");
} else {
const int swingPercentage = text->swingParameters().swingRatio;
const int swingDivisor = std::gcd(text->swingParameters().swingRatio, 100);
m_xml.tag("first", 100 / swingDivisor);
m_xml.tag("second", swingPercentage / swingDivisor);
if (text->swingParameters().swingUnit == Constants::DIVISION / 2) {
m_xml.tag("swing-type", TConv::toXml(DurationType::V_EIGHTH));
} else {
m_xml.tag("swing-type", TConv::toXml(DurationType::V_16TH));
}
}
m_xml.endElement();
m_xml.endElement();
swingSound(text);
}

directionETag(m_xml, staff);
Expand Down Expand Up @@ -6464,9 +6470,14 @@ static void measureStyle(XmlWriter& xml, Attributes& attr, const Measure* const
static bool commonAnnotations(ExportMusicXml* exp, const EngravingItem* e, staff_idx_t sstaff)
{
if (!exp->canWrite(e)) {
// write only tempo
// write only tempo and swing
if (e->isTempoText()) {
exp->tempoSound(toTempoText(e));
} else if (e->isSystemText()) {
const StaffTextBase* text = toStaffTextBase(e);
if (text->swing()) {
exp->swingSound(text);
}
}
return false;
}
Expand Down Expand Up @@ -7944,9 +7955,9 @@ static void writeStaffDetails(XmlWriter& xml, const Part* part, const std::vecto
if (needWriteLineDistance || needWriteMag) {
XmlWriter::Attributes scaleAttributes;
if (needWriteMag) {
attributes.emplace_back(std::make_pair("scale", mag));
scaleAttributes.emplace_back(std::make_pair("scaling", mag * 100));
}
xml.element("staff-size", scaleAttributes, lineDistance * 100);
xml.element("staff-size", scaleAttributes, mag * lineDistance * 100);
}

xml.endElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3201,9 +3201,9 @@ void MusicXmlParserPass2::staffDetails(const String& partId, Measure* measure)
} else if (m_e.name() == "staff-tuning") {
staffTuning(&stringData);
} else if (m_e.name() == "staff-size") {
const double scale = m_e.doubleAttribute("scale", 1.0);
const Spatium val(m_e.readDouble() / 100);
m_score->staff(staffIdx)->setProperty(Pid::MAG, scale);
const double scaling = m_e.doubleAttribute("scaling", 100.0);
const Spatium val(m_e.readDouble() / scaling);
m_score->staff(staffIdx)->setProperty(Pid::MAG, scaling / 100.0);
m_score->staff(staffIdx)->setProperty(Pid::LINE_DISTANCE, val);
} else {
skipLogCurrElem();
Expand Down
4 changes: 4 additions & 0 deletions src/importexport/musicxml/tests/data/testStaffSize.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<sign>G</sign>
<line>2</line>
</clef>
<staff-details>
<staff-lines>5</staff-lines>
<staff-size scaling="75">75</staff-size>
</staff-details>
</attributes>
<note>
<rest measure="yes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ AbstractElementPopup {
navigation.accessible.name: titleLabel.text + " " + currentText

model: [
{ text: qsTrc("notation", "Affects playback only") },
{ text: qsTrc("notation", "Affects staff notation only") },
{ text: qsTrc("notation", "Affects tablature fingering only") },
{ text: qsTrc("notation", "Notation/tab in open position") },
{ text: qsTrc("notation", "Notation shows sounding pitches") },
{ text: qsTrc("notation", "No transposition") },
]

currentIndex: capoModel.transposeMode
Expand Down
Loading