Skip to content

Port stuff #29381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 21, 2025
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
4 changes: 4 additions & 0 deletions src/engraving/dom/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,10 @@ String ParsedChord::fromXml(const String& rawKind, const String& rawKindText, co
m_quality = u"major";
implied = true;
extension = 5;
} else if (kind == "pedal") {
// Ignore, assume major
m_quality = u"major";
implied = true;
} else {
m_quality = kind;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class FretDiagram final : public EngravingItem
double fretNumPadding = 0.0;
double gridHeight = 0.0;
std::vector<FingeringItem> fingeringItems;
PainterPath slurPath = PainterPath();
std::vector<PainterPath> slurPaths;
String fretText = String();
};
DECLARE_LAYOUTDATA_METHODS(FretDiagram)
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/ottava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ PointF Ottava::linePos(Grip grip, System** system) const
*system = seg->measure()->system();

// End 1sp after the right edge of the end chord, but don't overlap followig segments
Shape staffShape = seg->staffShape(endCr->staffIdx());
Shape staffShape = seg->staffShape(endCr->vStaffIdx());
staffShape.remove_if([](ShapeElement& el) { return el.height() == 0; });
double x = staffShape.right() + seg->x() + seg->measure()->x() + spatium();
Segment* followingCRseg = score()->tick2segment(endCr->tick() + endCr->actualTicks(), true, SegmentType::ChordRest);
Expand Down
3 changes: 0 additions & 3 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ Score::Score(const modularity::ContextPtr& iocCtx)
m_rootItem = new RootItem(this);
m_rootItem->init();

//! NOTE Looks like a bug, `minimumPaddingUnit` is set using the default style's spatium value
//! and does not change if the style or the spatium of this score is changed
m_paddingTable.setMinimumPaddingUnit(0.1 * style().spatium());
createPaddingTable();

m_shadowNote = new ShadowNote(this);
Expand Down
1 change: 1 addition & 0 deletions src/engraving/engravingproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Ret EngravingProject::doSetupMasterScore(bool forceMode)
for (Score* s : m_masterScore->scoreList()) {
s->setPlaylistDirty();
s->setLayoutAll();
s->createPaddingTable();
}

m_masterScore->updateChannel();
Expand Down
5 changes: 0 additions & 5 deletions src/engraving/infrastructure/shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,6 @@ double Shape::right() const
return dist;
}

/* NOTE: these top() and bottom() methods look very weird to me, as they
* seem to return the opposite of what they say. Or it seems like the
* rectangles are defined upside down, for some reason. Needs some
* more understanding. [M.S.] */

//---------------------------------------------------------
// top
//---------------------------------------------------------
Expand Down
23 changes: 11 additions & 12 deletions src/engraving/rendering/paddingtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

using namespace mu::engraving;

void PaddingTable::initPaddingTable()
void PaddingTable::initPaddingTable(double minPadUnit)
{
PaddingTable& table = *this;

double minPadUnit = minimumPaddingUnit();

for (size_t i=0; i < TOT_ELEMENT_TYPES; ++i) {
for (size_t j=0; j < TOT_ELEMENT_TYPES; ++j) {
table[i][j] = minPadUnit;
Expand All @@ -42,15 +40,15 @@ void PaddingTable::initPaddingTable()

void PaddingTable::createTable(const MStyle& style)
{
initPaddingTable();

PaddingTable& table = *this;

const double minPadUnit = minimumPaddingUnit();
const double spatium = style.spatium();
const double minPadUnit = 0.1 * spatium;
initPaddingTable(minPadUnit);

const double ledgerPad = 0.25 * spatium;
const double ledgerLength = style.styleMM(Sid::ledgerLineLength);

PaddingTable& table = *this;

// NOTE: we don't set note-note padding to minNoteDistance
// because there are cases when they should be allowed to get closer.
// minNoteDistance is applied during the padding calculations.
Expand Down Expand Up @@ -292,16 +290,17 @@ ParenPaddingTablePtr ParenPaddingTable::getPaddingTable(const EngravingItem* par
ASSERT_X("Not a valid parenthesised type")
}

table->setMinimumPaddingUnit(0.1 * parent->style().spatium());
const double spatium = parent->style().spatium();
const double minPadUnit = 0.1 * spatium;
table->initPaddingTable(minPadUnit);

table->createTable(parent->style());

return table;
}

void ParenPaddingTable::initPaddingTable()
void ParenPaddingTable::initPaddingTable(double minPadUnit)
{
const double minPadUnit = minimumPaddingUnit();

for (size_t i = 0; i < TOT_ELEMENT_TYPES; ++i) {
m_parenBefore[i] = minPadUnit;
m_parenAfter[i] = minPadUnit;
Expand Down
15 changes: 2 additions & 13 deletions src/engraving/rendering/paddingtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,26 @@ struct PaddingVector : std::array<T, TOT_ELEMENT_TYPES>
struct PaddingTable : public PaddingVector<PaddingVector<double> >
{
public:

void setMinimumPaddingUnit(double val) { m_minimumPaddingUnit = val; }
double minimumPaddingUnit() const { return m_minimumPaddingUnit; }

void createTable(const MStyle& style);

private:
void initPaddingTable();
double m_minimumPaddingUnit = 0.0;
void initPaddingTable(double minPadUnit);
};

struct ParenPaddingTable
{
public:
virtual ~ParenPaddingTable() = default;

void setMinimumPaddingUnit(double val) { m_minimumPaddingUnit = val; }
double minimumPaddingUnit() const { return m_minimumPaddingUnit; }

virtual void createTable(const MStyle& style) = 0;
double padding(ElementType type1, ElementType type2);

static ParenPaddingTablePtr getPaddingTable(const EngravingItem* parent);

protected:
void initPaddingTable();
void initPaddingTable(double minPadUnit);
PaddingVector<double> m_parenBefore;
PaddingVector<double> m_parenAfter;

private:
double m_minimumPaddingUnit = 0.0;
};

struct NoteParenPaddingTable : public ParenPaddingTable {
Expand Down
4 changes: 3 additions & 1 deletion src/engraving/rendering/score/tdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,9 @@ void TDraw::draw(const FretDiagram* item, Painter* painter)
pen.setJoinStyle(PenJoinStyle::RoundJoin);
painter->setPen(pen);
painter->setBrush(Brush(pen.color()));
painter->drawPath(ldata->slurPath);
for (const PainterPath& path : ldata->slurPaths) {
painter->drawPath(path);
}
} else {
pen.setWidthF(dotd * item->style().styleD(Sid::barreLineWidth));
pen.setCapStyle(PenCapStyle::RoundCap);
Expand Down
35 changes: 17 additions & 18 deletions src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ void TLayout::layoutArticulation(Articulation* item, Articulation::LayoutData* l
text->setXmlText(TConv::text(item->textType()));
text->setTrack(item->track());
text->setParent(item);
text->setSelected(item->selected());

layoutBaseTextBase(item->text(), item->text()->mutldata());
}
Expand Down Expand Up @@ -1512,7 +1513,6 @@ void TLayout::layoutFBox(const FBox* item, FBox::LayoutData* ldata, const Layout

Harmony* harmony = fretDiagram->harmony();
harmony->mutldata()->setMag(item->textScale());
layoutHarmony(harmony, harmony->mutldata(), ctx);

layoutItem(fretDiagram, const_cast<LayoutContext&>(ctx));

Expand Down Expand Up @@ -1543,13 +1543,12 @@ void TLayout::layoutFBox(const FBox* item, FBox::LayoutData* ldata, const Layout
RectF fretRect = fretDiagram->ldata()->bbox();

const Harmony::LayoutData* harmonyLdata = fretDiagram->harmony()->ldata();
RectF harmonyRect = harmonyLdata->bbox();
harmonyRect.moveTo(harmonyLdata->pos());
RectF harmonyRect = harmonyLdata->bbox().translated(harmonyLdata->pos());

double height = fretRect.united(harmonyRect).height();
maxRowHeight = std::max(maxRowHeight, height);
maxHarmonyHeight = std::max(maxHarmonyHeight, harmonyRect.height());
harmonyBaseline = std::max(harmonyBaseline, fretDiagram->harmony()->baseLine());
maxHarmonyHeight = std::max(maxHarmonyHeight, -harmonyRect.top());
harmonyBaseline = std::min(harmonyBaseline, harmonyLdata->pos().y());
}

rowHeights.push_back(maxRowHeight);
Expand All @@ -1575,8 +1574,6 @@ void TLayout::layoutFBox(const FBox* item, FBox::LayoutData* ldata, const Layout
: alignH == AlignH::RIGHT ? width - totalTableWidth : 0.0;
const double startY = topMargin;

const double shapeMarginAboveDiagram = ctx.conf().styleMM(Sid::harmonyFretDist).val() * 1.5;

double bottomY = 0.0;

for (size_t i = 0; i < totalDiagrams; ++i) {
Expand All @@ -1600,22 +1597,24 @@ void TLayout::layoutFBox(const FBox* item, FBox::LayoutData* ldata, const Layout
y += rowHeights[r] + rowGap;
}

std::vector<HarmonyRenderItem*> renderItemList = harmony->ldata()->renderItemList.value();
double baseline = renderItemList.empty() ? 0.0 : renderItemList.front()->bboxBaseLine() + renderItemList.front()->pos().y();

double baseLineAdjust = harmony->ldata()->bbox().bottom() - baseline;

harmony->mutldata()->moveY(-(harmonyBaselines[row]) + baseLineAdjust);
double commonBaseline = harmonyBaselines[row];
double thisBaseline = harmony->ldata()->pos().y();
double baselineOff = commonBaseline - thisBaseline;
harmony->mutldata()->moveY(baselineOff);

double fretDiagramX = x;
double fretDiagramY = y + harmonyHeights[row] + shapeMarginAboveDiagram;
double fretDiagramY = y + harmonyHeights[row];

fretDiagram->mutldata()->setPos(PointF(fretDiagramX, fretDiagramY));

bottomY = std::max(bottomY, fretDiagram->mutldata()->bbox().translated(fretDiagram->mutldata()->pos()).bottom());
}

double height = std::max(bottomY + bottomMargin, item->minHeight());
double height = bottomY + bottomMargin;
if (RealIsNull(height)) {
height = item->minHeight();
}

ldata->setBbox(0.0, 0.0, width, height);
}

Expand Down Expand Up @@ -2684,7 +2683,7 @@ void TLayout::layoutFretDiagram(const FretDiagram* item, FretDiagram::LayoutData

double shapeMarginAboveDiagram = ldata->fretDist * 1.5;
double w = ldata->stringDist * (item->strings() - 1) + ldata->markerSize;
double h = item->frets() * ldata->fretDist + ldata->stringExtendBottom + shapeMarginAboveDiagram;
double h = item->frets() * ldata->fretDist + ldata->stringExtendBottom + 0.5 * ldata->stringLineWidth + shapeMarginAboveDiagram;
double y = -shapeMarginAboveDiagram;
double x = -(ldata->markerSize * .5);

Expand Down Expand Up @@ -2790,6 +2789,7 @@ void TLayout::layoutFretDiagram(const FretDiagram* item, FretDiagram::LayoutData
}
}

ldata->slurPaths.clear();
for (auto i : item->barres()) {
FretItem::Barre barre = i.second;
if (!barre.exists()) {
Expand Down Expand Up @@ -2825,8 +2825,7 @@ void TLayout::layoutFretDiagram(const FretDiagram* item, FretDiagram::LayoutData
slurPath.moveTo(startX, startEndY);
slurPath.cubicTo(bezier1for, bezier2for, PointF(endX, startEndY));
slurPath.cubicTo(bezier2back, bezier1back, PointF(startX, startEndY));
ldata->slurPath = slurPath;
break;
ldata->slurPaths.push_back(slurPath);
}
}

Expand Down
35 changes: 34 additions & 1 deletion src/engraving/tests/utils/scorecomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ bool ScoreComp::saveCompareScore(Score* score, const String& saveName, const Str
if (!ScoreRW::saveScore(score, saveName)) {
return false;
}
bool val = compareFiles(ScoreRW::rootPath() + u"/" + compareWithLocalPath, saveName);

return compareFiles(ScoreRW::rootPath() + u"/" + compareWithLocalPath, saveName);
if (!val) {
copyFile(saveName, ScoreRW::rootPath() + u"/" + compareWithLocalPath);
return false;
}

return val;
}

bool ScoreComp::saveCompareMimeData(muse::ByteArray mimeData, const muse::String& saveName, const muse::String& compareWithLocalPath)
Expand All @@ -48,6 +54,33 @@ bool ScoreComp::saveCompareMimeData(muse::ByteArray mimeData, const muse::String
return compareFiles(ScoreRW::rootPath() + u"/" + compareWithLocalPath, saveName);
}

bool ScoreComp::copyFile(const String& fullPath1, const String& fullPath2)
{
QString cmd = "cp";
QStringList args;
args.append(fullPath1);
args.append(fullPath2);

QProcess p;
p.start(cmd, args);
if (!p.waitForFinished()) {
QTextStream outputText(stdout);
outputText << "copy failed finished";
return false;
}

int code = p.exitCode();
if (code) {
QByteArray ba = p.readAll();
QTextStream outputText(stdout);
outputText << String(ba);
outputText << String(" <cp %1 %2 failed, code: %3 \n").arg(fullPath1, fullPath2).arg(code);
return false;
}
LOGD() << "Copy succeeded: " << String(" <cp %1 %2>\n").arg(fullPath1, fullPath2).arg(code);
return true;
}

bool ScoreComp::compareFiles(const String& fullPath1, const String& fullPath2)
{
QString cmd = "diff";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7981,8 +7981,15 @@
}
}

if (!muse::RealIsEqual(mag, 1.0)) {
xml.tag("staff-size", mag * 100);
double lineDistance = st->lineDistance(Fraction(0, 1));
bool needWriteLineDistance = !muse::RealIsEqual(lineDistance, 1.0);
bool needWriteMag = !muse::RealIsEqual(mag, 1.0);
if (needWriteLineDistance || needWriteMag) {
XmlWriter::Attributes attributes;

Check warning on line 7988 in src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp

View workflow job for this annotation

GitHub Actions / windows_x64

declaration of 'attributes' hides previous local declaration
if (needWriteMag) {
attributes.emplace_back(std::make_pair("scale", mag));
}
xml.element("staff-size", attributes, lineDistance * 100);
}

xml.endElement();
Expand Down
Loading
Loading