Skip to content

Commit

Permalink
Fix frame reading and writing
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Aug 9, 2024
1 parent 3f70187 commit 119fb95
Show file tree
Hide file tree
Showing 130 changed files with 167 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/engraving/rw/read114/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2217,8 +2217,6 @@ static bool readBoxProperties(XmlReader& e, ReadContext& ctx, Box* b)
VBox* vb = Factory::createVBox(b->system());
readBox(e, ctx, vb);
b->add(vb);
// If nested inside title frame, don't scale with spatium
vb->setSizeIsSpatiumDependent(!b->isTitleFrame());
}
// else if (MeasureBase::readProperties(e))
// ;
Expand Down Expand Up @@ -2253,8 +2251,6 @@ static void readBox(XmlReader& e, ReadContext& ctx, Box* b)
readBox(e, ctx, vb);
b->add(vb);
keepMargins = true; // in old file, box nesting used outer box margins
// If nested inside title frame, don't scale with spatium
vb->setSizeIsSpatiumDependent(!b->isTitleFrame());
} else if (!readBoxProperties(e, ctx, b)) {
e.unknown();
}
Expand Down Expand Up @@ -2338,7 +2334,6 @@ static void readStaffContent(Score* score, XmlReader& e, ReadContext& ctx)
readBox(e, ctx, mb);
mb->setTick(ctx.tick());
score->measures()->add(mb);
mb->setSizeIsSpatiumDependent(!mb->isTitleFrame());
} else if (tag == "tick") {
ctx.setTick(Fraction::fromTicks(score->fileDivision(e.readInt())));
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/engraving/rw/read206/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3037,8 +3037,6 @@ static void readBox(Box* b, XmlReader& e, ReadContext& ctx)
VBox* vb = Factory::createVBox(b->score()->dummy()->system());
read400::TRead::read(vb, e, ctx);
b->add(vb);
// If nested inside title frame, don't scale with spatium
vb->setSizeIsSpatiumDependent(!b->isTitleFrame());
} else if (tag == "Text") {
Text* t;
if (b->isTBox()) {
Expand Down Expand Up @@ -3124,7 +3122,6 @@ static void readStaffContent206(Score* score, XmlReader& e, ReadContext& ctx)
if (!readMeasureLast && !lastReadBox) {
b->setTopGap(b->propertyDefault(Pid::TOP_GAP).value<Spatium>());
b->setPropertyFlags(Pid::TOP_GAP, PropertyFlags::STYLED);
b->setSizeIsSpatiumDependent(false);
} else if (readMeasureLast) {
b->setTopGap(b->topGap() + b->propertyDefault(Pid::TOP_GAP).value<Spatium>());
}
Expand Down
8 changes: 6 additions & 2 deletions src/engraving/rw/read400/staffrw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ void StaffRead::readStaff(Score* score, XmlReader& e, ReadContext& ctx)
}
} else if (tag == "HBox" || tag == "VBox" || tag == "TBox" || tag == "FBox") {
MeasureBase* mb = toMeasureBase(Factory::createItemByName(tag, ctx.dummy()));
TRead::readItem(mb, e, ctx);
mb->setTick(ctx.tick());
score->measures()->add(mb);
mb->setSizeIsSpatiumDependent(!toBox(mb)->isTitleFrame());
// This default value needs initialising after being added to the score, as it depends on whether this is the title frame
if (mb->score()->mscVersion() >= 440) {
mb->setSizeIsSpatiumDependent(mb->propertyDefault(Pid::SIZE_SPATIUM_DEPENDENT).toBool());
}

TRead::readItem(mb, e, ctx);
} else if (tag == "tick") {
ctx.setTick(Fraction::fromTicks(ctx.fileDivision(e.readInt())));
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/engraving/rw/read400/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,9 @@ void TRead::read(Box* b, XmlReader& e, ReadContext& ctx)
if (b->score()->mscVersion() < 302) {
b->setAutoSizeEnabled(false); // disable auto-size for older scores by default.
}
if (b->score()->mscVersion() < 440) {
b->setSizeIsSpatiumDependent(true);
}
}

void TRead::read(HBox* b, XmlReader& e, ReadContext& ctx)
Expand All @@ -2005,6 +2008,9 @@ void TRead::read(HBox* b, XmlReader& e, ReadContext& ctx)
if (b->score()->mscVersion() < 302) {
b->setAutoSizeEnabled(false); // disable auto-size for older scores by default.
}
if (b->score()->mscVersion() < 440) {
b->setSizeIsSpatiumDependent(true);
}
}

bool TRead::readProperties(HBox* b, XmlReader& e, ReadContext& ctx)
Expand Down
8 changes: 6 additions & 2 deletions src/engraving/rw/read410/staffread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ void StaffRead::readStaff(Score* score, XmlReader& e, ReadContext& ctx)
}
} else if (tag == "HBox" || tag == "VBox" || tag == "TBox" || tag == "FBox") {
MeasureBase* mb = toMeasureBase(Factory::createItemByName(tag, ctx.dummy()));
TRead::readItem(mb, e, ctx);
mb->setTick(ctx.tick());
score->measures()->add(mb);
mb->setSizeIsSpatiumDependent(!toBox(mb)->isTitleFrame());
// This default value needs initialising after being added to the score, as it depends on whether this is the title frame
if (mb->score()->mscVersion() >= 440) {
mb->setSizeIsSpatiumDependent(mb->propertyDefault(Pid::SIZE_SPATIUM_DEPENDENT).toBool());
}

TRead::readItem(mb, e, ctx);
} else if (tag == "tick") {
ctx.setTick(Fraction::fromTicks(ctx.fileDivision(e.readInt())));
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/engraving/rw/read410/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,9 @@ void TRead::read(Box* b, XmlReader& e, ReadContext& ctx)
if (b->score()->mscVersion() < 302) {
b->setAutoSizeEnabled(false); // disable auto-size for older scores by default.
}
if (b->score()->mscVersion() < 440) {
b->setSizeIsSpatiumDependent(true);
}
}

void TRead::read(HBox* b, XmlReader& e, ReadContext& ctx)
Expand All @@ -2189,6 +2192,9 @@ void TRead::read(HBox* b, XmlReader& e, ReadContext& ctx)
if (b->score()->mscVersion() < 302) {
b->setAutoSizeEnabled(false); // disable auto-size for older scores by default.
}
if (b->score()->mscVersion() < 440) {
b->setSizeIsSpatiumDependent(true);
}
}

bool TRead::readProperties(HBox* b, XmlReader& e, ReadContext& ctx)
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/box_data/undoRemoveVBox2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>VBox</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/chordsymbol_data/add-part-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/chordsymbol_data/realize-jazz-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/tests/chordsymbol_data/transpose-part-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linkedMain/>
</VBox>
<Measure>
Expand Down Expand Up @@ -188,6 +189,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linked>
</linked>
<Text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/chordsymbol_data/transpose-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/clef_data/clef-2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Staff id="1">
<VBox>
<height>10</height>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>ClefTimeSig</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/clefs-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Clefs</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/fingering-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>fing</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/hairpin-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Hairpin</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/keysig-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>keysig</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/notes-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>notes</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/textstyles-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<VBox>
<height>6.36254</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Title</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/title-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>title</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/tuplets-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Tuplets</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/tuplets_1-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Tuplet 1.3 file</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat114_data/tuplets_2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Tuplet 1.3 file</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linkedMain/>
<Text>
<linkedMain/>
Expand Down Expand Up @@ -1855,6 +1856,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linked>
</linked>
<Text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/articulations-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Articulations</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/barlines-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>barlines</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/clefs-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>clefs</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/frame_text2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<height>25.5926</height>
<topMargin>3</topMargin>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>frame</style>
<text>îèéààéà</text>
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/tests/compat206_data/hairpin-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linkedMain/>
<Text>
<linkedMain/>
Expand Down Expand Up @@ -670,6 +671,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<linked>
</linked>
<Text>
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/tests/compat206_data/lidemptytext-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<height>8</height>
<bottomGap>13</bottomGap>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
</VBox>
<Measure>
<voice>
Expand Down Expand Up @@ -304,6 +305,7 @@
<height>8</height>
<bottomGap>13</bottomGap>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>instrument_excerpt</style>
<text>Bass</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/textstyles-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<height>7</height>
<bottomGap>8.33333</bottomGap>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Title</text>
Expand Down
1 change: 1 addition & 0 deletions src/engraving/tests/compat206_data/tuplets-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<VBox>
<height>10</height>
<boxAutoSize>0</boxAutoSize>
<sizeIsSpatiumDependent>1</sizeIsSpatiumDependent>
<Text>
<style>title</style>
<text>Tuplets</text>
Expand Down
Loading

0 comments on commit 119fb95

Please sign in to comment.