Skip to content

4.6 ports #29358

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 20, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 12 additions & 1 deletion src/engraving/dom/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,19 @@ void FretDiagram::applyAlignmentToHarmony()
m_harmony->resetProperty(Pid::OFFSET);
}

m_harmony->setProperty(Pid::ALIGN, Align(AlignH::HCENTER, AlignV::TOP));
m_harmony->setProperty(Pid::ALIGN, Align(AlignH::HCENTER, AlignV::BASELINE));
m_harmony->setPropertyFlags(Pid::ALIGN, PropertyFlags::UNSTYLED);
}

void FretDiagram::resetHarmonyAlignment()
{
if (m_harmony->propertyFlags(Pid::OFFSET) == PropertyFlags::STYLED) {
m_harmony->resetProperty(Pid::OFFSET);
}

m_harmony->resetProperty(Pid::ALIGN);
}

//---------------------------------------------------------
// clear
//---------------------------------------------------------
Expand Down Expand Up @@ -964,6 +973,8 @@ void FretDiagram::unlinkHarmony()
{
m_harmony->setTrack(track());

resetHarmonyAlignment();

segment()->add(m_harmony);

m_harmony = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class FretDiagram final : public EngravingItem
static void applyDiagramPattern(FretDiagram* diagram, const String& pattern);

void applyAlignmentToHarmony();
void resetHarmonyAlignment();

int m_strings = 0;
int m_frets = 0;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/parenthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Parenthesis : public EngravingItem
ld_field<double> height = { "[Parenthesis] height", 0.0 };
ld_field<double> midPointThickness = { "[Parenthesis] midPointThickness", 0.0 };
ld_field<double> endPointThickness = { "[Parenthesis] endPointThickness", PARENTHESIS_END_WIDTH };
ld_field<double> shoulderWidth = "[Parenthesis] endPointThickness";
ld_field<SymId> symId = { "[Parenthesis] symId", SymId::noSym };
};
DECLARE_LAYOUTDATA_METHODS(Parenthesis);
Expand Down
24 changes: 23 additions & 1 deletion src/engraving/dom/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2675,17 +2675,39 @@ void Segment::createShape(staff_idx_t staffIdx)

setVisible(true);

// Still include harmony attached to fret diagram
if (e->isFretDiagram() && !e->addToSkyline() && toFretDiagram(e)->harmony()) {
e = toHarmony(toFretDiagram(e)->harmony());
}

if (!e->addToSkyline()) {
continue;
}

if (e->isHarmony() || e->isFretDiagram()) {
// TODO: eliminate once and for all this addHorizontalSpace hack [M.S.]
RectF bbox = e->ldata()->bbox().translated(e->pos());
PointF pos = e->pos();
// Harmony attached to invisible fret diagram
if (e->isHarmony() && e->parent()->isFretDiagram()) {
pos += e->parentItem()->pos();
}
RectF bbox = e->ldata()->bbox().translated(pos);
if (Parenthesis* p = e->leftParen()) {
bbox.unite(p->ldata()->bbox().translated(p->pos() + pos));
}
if (Parenthesis* p = e->rightParen()) {
bbox.unite(p->ldata()->bbox().translated(p->pos() + pos));
}
s.addHorizontalSpacing(e, bbox.left(), bbox.right());
if (e->isFretDiagram()) {
if (Harmony* harmony = toFretDiagram(e)->harmony()) {
RectF harmBbox = harmony->ldata()->bbox().translated(harmony->pos() + e->pos());
if (Parenthesis* p = harmony->leftParen()) {
harmBbox.unite(p->ldata()->bbox().translated(p->pos() + harmony->pos() + e->pos()));
}
if (Parenthesis* p = harmony->rightParen()) {
harmBbox.unite(p->ldata()->bbox().translated(p->pos() + harmony->pos() + e->pos()));
}
s.addHorizontalSpacing(harmony, harmBbox.left(), harmBbox.right());
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/dom/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,11 +1284,14 @@ void Staff::init(const InstrumentTemplate* t, const StaffType* staffType, int ci
void Staff::init(const Staff* s)
{
m_id = s->m_id;

setStaffType(Fraction(0, 1), s->m_staffTypeList.staffType(Fraction(0, 1)));
for (const auto& stPair : s->m_staffTypeList.staffTypeChanges()) {
const StaffType& st = stPair.second;
StaffType newStaffType(st);
setStaffType(Fraction::fromTicks(stPair.first), newStaffType);
}

setDefaultClefType(s->defaultClefType());
m_barLineFrom = s->m_barLineFrom;
m_barLineTo = s->m_barLineTo;
Expand Down
36 changes: 25 additions & 11 deletions src/engraving/rendering/score/harmonylayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
const FretDiagram* fd = (item->explicitParent() && item->explicitParent()->isFretDiagram())
? toFretDiagram(item->explicitParent())
: nullptr;
const bool alignToFretDiagram = fd && fd->visible();

const double cw = item->symWidth(SymId::noteheadBlack);

Expand All @@ -88,7 +89,7 @@
if (item->ldata()->renderItemList().empty()) {
TLayout::layoutBaseTextBase1(item, ldata);

if (fd) {
if (alignToFretDiagram) {
newPosY = ldata->pos().y();
} else {
newPosY = ypos - ((item->align() == AlignV::BOTTOM) ? -ldata->bbox().height() : 0.0);
Expand All @@ -97,17 +98,21 @@
layoutModifierParentheses(item);
RectF bb;
RectF hAlignBox;
double segBl = 0.0;
for (HarmonyRenderItem* renderItem : item->ldata()->renderItemList()) {
RectF tsBbox = renderItem->tightBoundingRect().translated(renderItem->x(), renderItem->y());
bb.unite(tsBbox);

if (renderItem->align()) {
hAlignBox.unite(tsBbox);
}
if (TextSegment* ts = dynamic_cast<TextSegment*>(renderItem)) {
segBl = ts->bboxBaseLine();
}
}

double xx = 0.0;
if (fd) {
if (alignToFretDiagram) {
switch (ctx.conf().styleV(Sid::chordAlignmentToFretboard).value<AlignH>()) {
case AlignH::LEFT:
xx = -hAlignBox.left();
Expand Down Expand Up @@ -142,7 +147,7 @@
yy = -bb.height() - bb.y();
}

if (fd) {
if (alignToFretDiagram) {
newPosY = ypos - yy - ctx.conf().styleMM(Sid::harmonyFretDist);
} else {
newPosY = ypos;
Expand All @@ -158,7 +163,7 @@
ldata->harmonyHeight = ldata->bbox().height();
}

if (fd) {
if (alignToFretDiagram) {
switch (ctx.conf().styleV(Sid::chordAlignmentToFretboard).value<AlignH>()) {
case AlignH::LEFT:
newPosX = 0.0;
Expand All @@ -184,6 +189,11 @@
}
}

if (fd && !fd->visible()) {
// Translate to base position around note
newPosX -= fd->pos().x();
}

return PointF(newPosX, newPosY);
}

Expand Down Expand Up @@ -270,10 +280,8 @@
for (size_t i = 0; i < itemList.size(); i++) {
HarmonyRenderItem* renderItem = itemList.at(i);
double padding = i != 0 ? computePadding(itemList.at(i - 1), renderItem) : 0.0;
LOGI() << "padding: " << padding;

if (ChordSymbolParen* paren = dynamic_cast<ChordSymbolParen*>(renderItem)) {
LOGI() << "PAREN";
if (paren->paren->direction() == DirectionH::LEFT) {
additionalSpace += paren->paren->width() + padding;
paren->movex(additionalSpace);
Expand All @@ -283,7 +291,6 @@
additionalSpace += paren->paren->width() + padding;
}
} else if (TextSegment* ts = dynamic_cast<TextSegment*>(renderItem)) {
LOGI() << ts->text();
additionalSpace += padding;
ts->movex(additionalSpace);
}
Expand Down Expand Up @@ -456,13 +463,14 @@

NoteSpellingType spelling = style.styleV(Sid::chordSymbolSpelling).value<NoteSpellingType>();

const ChordDescription* cd = info->getDescription();
const bool stackModifiers = style.styleB(Sid::verticallyStackModifiers) && !item->doNotStackModifiers();

if (item->harmonyType() == HarmonyType::STANDARD && tpcIsValid(info->rootTpc())) {
// render root
render(item, ldata, chordList->renderListRoot, harmonyCtx, ctx, info->rootTpc(), spelling, rootCase);
// render extension
const ChordDescription* cd = info->getDescription();
if (cd) {
const bool stackModifiers = style.styleB(Sid::verticallyStackModifiers) && !item->doNotStackModifiers();
render(item, ldata, stackModifiers ? cd->renderListStacked : cd->renderList, harmonyCtx, ctx, 0);
}
} else if (item->harmonyType() == HarmonyType::NASHVILLE && tpcIsValid(info->rootTpc())) {
Expand All @@ -471,9 +479,7 @@
double adjust = chordList->nominalAdjust();
harmonyCtx.movey(adjust * item->magS() * item->spatium() * .2);
// render extension
const ChordDescription* cd = info->getDescription();
if (cd) {
const bool stackModifiers = style.styleB(Sid::verticallyStackModifiers) && !item->doNotStackModifiers();
render(item, ldata, stackModifiers ? cd->renderListStacked : cd->renderList, harmonyCtx, ctx, 0);
}
} else {
Expand All @@ -484,6 +490,14 @@
if (tpcIsValid(info->bassTpc())) {
std::list<RenderActionPtr >& bassNoteChordList
= style.styleB(Sid::chordBassNoteStagger) ? chordList->renderListBassOffset : chordList->renderListBass;

static const std::wregex PATTERN_69 = std::wregex(L"6[,/]?9");
const bool is69 = info->textName().contains(PATTERN_69);
const bool hasModifierStack = stackModifiers && (info->parsedChord() ? info->parsedChord()->modifierList().size() > 1 : false);

if (hasModifierStack || is69) {
bassNoteChordList.emplace_front(new RenderActionMove(0.05, 0.0));
}
render(item, ldata, bassNoteChordList, harmonyCtx, ctx, info->bassTpc(), spelling, bassCase, item->bassScale());
}

Expand Down Expand Up @@ -516,9 +530,9 @@
render(item, ldata, chordList->renderListRoot, harmonyCtx, ctx, capoRootTpc, spelling, rootCase);

// render extension
const ChordDescription* cd = info->getDescription();

Check warning on line 533 in src/engraving/rendering/score/harmonylayout.cpp

View workflow job for this annotation

GitHub Actions / windows_x64

declaration of 'cd' hides previous local declaration
if (cd) {
const bool stackModifiers = style.styleB(Sid::verticallyStackModifiers) && !item->doNotStackModifiers();

Check warning on line 535 in src/engraving/rendering/score/harmonylayout.cpp

View workflow job for this annotation

GitHub Actions / windows_x64

declaration of 'stackModifiers' hides previous local declaration
render(item, ldata, stackModifiers ? cd->renderListStacked : cd->renderList, harmonyCtx, ctx, 0);
}

Expand Down
35 changes: 30 additions & 5 deletions src/engraving/rendering/score/parenthesislayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ double ParenthesisLayout::computeInternalParenthesisPadding(const EngravingItem*
case ElementType::CLEF:
padding = (parenFirst ? 0.2 : 0.25) * spatium;
break;
case ElementType::HARMONY:
padding = 0.2 * spatium;
break;
default:
padding = 0.1 * spatium;
break;
Expand All @@ -251,7 +254,7 @@ void ParenthesisLayout::createPathAndShape(Parenthesis* item, Parenthesis::Layou
const double shoulderYOffset = 0.2 * height;

// Control width of parentheses. We don't want tall parens to be too wide, nor do we want parens at a small scale to lose their curve too much
double shoulderX = 0.2 * std::pow(height, 0.95) * std::pow(mag, 0.1);
double shoulderX = ldata->shoulderWidth.has_value() ? ldata->shoulderWidth() : 0.2 * std::pow(height, 0.95) * std::pow(mag, 0.1);
const double minShoulderX = 0.25 * spatium;
shoulderX = std::max(shoulderX, minShoulderX);

Expand Down Expand Up @@ -403,12 +406,34 @@ void ParenthesisLayout::setHarmonyValues(Parenthesis* item, Parenthesis::LayoutD
Harmony* parent = toHarmony(item->parentItem());
RectF bbox = parent->ldata()->bbox();

double bottom = parent->baseLine();
double endPointThickness = 0.03;
double extension = 0.1 * spatium * (parent->size() / 10.0);
double bottom = parent->baseLine() + extension;

double topCapHeight = DBL_MAX;
const TextSegment* rootTextSeg = nullptr;
for (const HarmonyRenderItem* renderItem : parent->ldata()->renderItemList.value()) {
if (const TextSegment* ts = dynamic_cast<const TextSegment*>(renderItem)) {
topCapHeight = std::min(topCapHeight, ts->pos().y() - ts->capHeight());

rootTextSeg = !rootTextSeg ? ts : rootTextSeg;
}
}
double top = topCapHeight - extension;
double height = bottom - top;
double rootCapHeight = rootTextSeg->capHeight();
double scale = (height - 2 * extension) / rootCapHeight;

ldata->setMag(parent->mag());
ldata->startY = bbox.top() - 0.25 * spatium;
ldata->height = bottom - ldata->startY;
ldata->midPointThickness.set_value(ldata->height / 60 * ldata->mag()); // 0.1sp for a height of 6sp
ldata->startY = top;
ldata->height = height;
static constexpr double HEIGHT_TO_WIDTH_RATIO = 20;
ldata->midPointThickness.set_value(ldata->height / HEIGHT_TO_WIDTH_RATIO * ldata->mag() * 1 / std::sqrt(scale));
ldata->endPointThickness.set_value(endPointThickness);

double shoulder = 0.2 * ldata->height * std::pow(ldata->mag(), 0.1) * 1 / std::sqrt(scale);
ldata->shoulderWidth = shoulder;

const double PADDING = spatium * 0.2;
ldata->setPosX(item->direction() == DirectionH::RIGHT ? bbox.right() + PADDING : bbox.left() - PADDING);
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ void SystemLayout::layoutSystemElements(System* system, LayoutContext& ctx)
AlignmentLayout::alignItemsForSystem(fretItems, system);
}

layoutHarmonies(elementsToLayout.harmonies, system, false, ctx);
layoutHarmonies(elementsToLayout.harmonies, system, true, ctx);

for (FretDiagram* fretDiag : elementsToLayout.fretDiagrams) {
if (Harmony* harmony = fretDiag->harmony()) {
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/chordsymbol_data/no-system-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<eid>Y_Y</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
Expand Down Expand Up @@ -351,7 +351,7 @@
<eid>l_l</eid>
<linkedTo>D_D</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Alto Saxophone</trackName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<eid>D_D</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<defaultClef>G8vb</defaultClef>
</Staff>
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/parts_data/part-all-appendmeasures.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@
<eid>zC_zC</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Alto</trackName>
Expand Down Expand Up @@ -1886,7 +1886,7 @@
<eid>sE_sE</eid>
<linkedTo>D_D</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Tenor</trackName>
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/parts_data/part-all-insertmeasures.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@
<eid>3C_3C</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Alto</trackName>
Expand Down Expand Up @@ -1884,7 +1884,7 @@
<eid>wE_wE</eid>
<linkedTo>D_D</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Tenor</trackName>
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/parts_data/part-all-parts.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@
<eid>wC_wC</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Alto</trackName>
Expand Down Expand Up @@ -1856,7 +1856,7 @@
<eid>nE_nE</eid>
<linkedTo>D_D</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Tenor</trackName>
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/parts_data/part-all-uappendmeasures.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@
<eid>zC_zC</eid>
<linkedTo>C_C</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Alto</trackName>
Expand Down Expand Up @@ -1856,7 +1856,7 @@
<eid>sE_sE</eid>
<linkedTo>D_D</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Tenor</trackName>
Expand Down
Loading
Loading