Skip to content

Commit

Permalink
Merge pull request #23648 from Jojo-Schmitz/Mu1-import
Browse files Browse the repository at this point in the history
Improve Mu1 import
  • Loading branch information
cbjeukendrup authored Jul 24, 2024
2 parents 2da3b89 + 2996148 commit 4d52ee8
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 183 deletions.
20 changes: 15 additions & 5 deletions src/engraving/rw/read114/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2232,13 +2232,11 @@ static bool readBoxProperties(XmlReader& e, ReadContext& ctx, Box* b)

static void readBox(XmlReader& e, ReadContext& ctx, Box* b)
{
b->setLeftMargin(0.0);
b->setRightMargin(0.0);
b->setTopMargin(0.0);
b->setBottomMargin(0.0);
b->setAutoSizeEnabled(false); // didn't exist in Mu1

b->setBoxHeight(Spatium(0)); // override default set in constructor
b->setBoxWidth(Spatium(0));
b->setAutoSizeEnabled(false);
bool keepMargins = false; // whether original margins have to be kept when reading old file
System* bSystem = b->system() ? b->system() : ctx.dummy()->system();

while (e.readNextStartElement()) {
Expand All @@ -2247,14 +2245,26 @@ static void readBox(XmlReader& e, ReadContext& ctx, Box* b)
HBox* hb = Factory::createHBox(bSystem);
readBox(e, ctx, hb);
b->add(hb);
keepMargins = true; // in old file, box nesting used outer box margins
} else if (tag == "VBox") {
VBox* vb = Factory::createVBox(bSystem);
readBox(e, ctx, vb);
b->add(vb);
keepMargins = true; // in old file, box nesting used outer box margins
} else if (!readBoxProperties(e, ctx, b)) {
e.unknown();
}
}

// with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box:
// for backward compatibility set them to 0.0 in all other cases, the Mu1 defaults of 5.0 just look horrible in Mu3 and Mu4

if (ctx.mscVersion() <= 114 && (b->isHBox() || b->isVBox()) && !keepMargins) {
b->setLeftMargin(0.0);
b->setRightMargin(0.0);
b->setTopMargin(0.0); // 2.0 would look closest to Mu1 and Mu2, but 0.0 is the default since Mu2
b->setBottomMargin(0.0); // 1.0 would look closest to Mu1 and Mu2, but 0.0 is the default since Mu2
}
}

//---------------------------------------------------------
Expand Down
23 changes: 1 addition & 22 deletions src/engraving/rw/read206/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3022,32 +3022,21 @@ static void readMeasure206(Measure* m, int staffIdx, XmlReader& e, ReadContext&

static void readBox(Box* b, XmlReader& e, ReadContext& ctx)
{
b->setLeftMargin(0.0);
b->setRightMargin(0.0);
b->setTopMargin(0.0);
b->setBottomMargin(0.0);
b->setTopGap(Millimetre(0.0));
b->setBottomGap(Millimetre(0.0));
b->setAutoSizeEnabled(false);
b->setPropertyFlags(Pid::TOP_GAP, PropertyFlags::UNSTYLED);
b->setPropertyFlags(Pid::BOTTOM_GAP, PropertyFlags::UNSTYLED);
b->setAutoSizeEnabled(false); // didn't exist in Mu2

b->setBoxHeight(Spatium(0)); // override default set in constructor
b->setBoxWidth(Spatium(0));
bool keepMargins = false; // whether original margins have to be kept when reading old file

while (e.readNextStartElement()) {
const AsciiStringView tag(e.name());
if (tag == "HBox") {
HBox* hb = Factory::createHBox(b->score()->dummy()->system());
read400::TRead::read(hb, e, ctx);
b->add(hb);
keepMargins = true; // in old file, box nesting used outer box margins
} else if (tag == "VBox") {
VBox* vb = Factory::createVBox(b->score()->dummy()->system());
read400::TRead::read(vb, e, ctx);
b->add(vb);
keepMargins = true; // in old file, box nesting used outer box margins
} else if (tag == "Text") {
Text* t;
if (b->isTBox()) {
Expand All @@ -3066,16 +3055,6 @@ static void readBox(Box* b, XmlReader& e, ReadContext& ctx)
e.unknown();
}
}

// with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box:
// for backward compatibility set them to 0 in all other cases

if (ctx.mscVersion() <= 114 && (b->isHBox() || b->isVBox()) && !keepMargins) {
b->setLeftMargin(0.0);
b->setRightMargin(0.0);
b->setTopMargin(0.0);
b->setBottomMargin(0.0);
}
}

//---------------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/clefs-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/fingering-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/hairpin-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@
<Staff id="1">
<HBox>
<width>5</width>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
</HBox>
<Measure>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/keysig-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/notes-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/textstyles-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
<Staff id="1">
<VBox>
<height>6.36254</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/title-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/tuplets-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/tuplets_1-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/tests/compat114_data/tuplets_2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
Expand Down
2 changes: 0 additions & 2 deletions src/engraving/tests/compat206_data/frame_text2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
<Staff id="1">
<VBox>
<height>25.5926</height>
<bottomGap>0</bottomGap>
<topMargin>3</topMargin>
<boxAutoSize>0</boxAutoSize>
<Text>
Expand All @@ -205,7 +204,6 @@
<VBox>
<height>47.762</height>
<topGap>10</topGap>
<bottomGap>0</bottomGap>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>frame</style>
Expand Down
Loading

0 comments on commit 4d52ee8

Please sign in to comment.