Skip to content

Commit

Permalink
Consider beam staff for artic cross staff
Browse files Browse the repository at this point in the history
  • Loading branch information
brdvd committed Oct 29, 2024
1 parent d59a0bb commit 7ed928e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/vrv/calcarticfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class CalcArticFunctor : public DocFunctor {
private:
// Calculate shift for the articulation based on its type and presence of other articulations
int CalculateHorizontalShift(const Artic *artic, bool virtualStem) const;
// Include the parent beam staff in the calculation of the above and below staff
void IncludeBeamStaff(LayerElement *layerElement);

public:
//
Expand Down
6 changes: 3 additions & 3 deletions src/adjustarticfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ FunctorCode AdjustArticFunctor::VisitArtic(Artic *artic)
int yIn, yOut, yRel;

Staff *staff = artic->GetAncestorStaff(RESOLVE_CROSS_STAFF);
Beam *beam = vrv_cast<Beam *>(artic->GetFirstAncestor(BEAM));
const Beam *beam = artic->GetAncestorBeam();
const int staffHeight = m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * (staff->m_drawingLines - 1);

Stem *stem = vrv_cast<Stem *>(m_parent->FindDescendantByType(STEM));
Flag *flag = vrv_cast<Flag *>(m_parent->FindDescendantByType(FLAG));
const Stem *stem = vrv_cast<const Stem *>(m_parent->FindDescendantByType(STEM));
const Flag *flag = vrv_cast<const Flag *>(m_parent->FindDescendantByType(FLAG));
// Avoid artic to be in ledger lines
if (artic->GetDrawingPlace() == STAFFREL_above) {
int yAboveStem = m_parent->GetDrawingTop(m_doc, staff->m_drawingStaffSize, false) - staff->GetDrawingY();
Expand Down
16 changes: 16 additions & 0 deletions src/calcarticfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ FunctorCode CalcArticFunctor::VisitChord(Chord *chord)
}
}

this->IncludeBeamStaff(chord);

return FUNCTOR_CONTINUE;
}

Expand Down Expand Up @@ -164,6 +166,8 @@ FunctorCode CalcArticFunctor::VisitNote(Note *note)
m_crossStaffBelow = true;
}

this->IncludeBeamStaff(note);

return FUNCTOR_CONTINUE;
}

Expand Down Expand Up @@ -194,4 +198,16 @@ int CalcArticFunctor::CalculateHorizontalShift(const Artic *artic, bool virtualS
return shift;
}

void CalcArticFunctor::IncludeBeamStaff(LayerElement *layerElement)
{
if (Beam *beam = layerElement->GetAncestorBeam(); beam) {
if (m_crossStaffAbove && (beam->m_drawingPlace == BEAMPLACE_above)) {
m_staffAbove = beam->GetAncestorStaff(RESOLVE_CROSS_STAFF);
}
else if (m_crossStaffBelow && (beam->m_drawingPlace == BEAMPLACE_below)) {
m_staffBelow = beam->GetAncestorStaff(RESOLVE_CROSS_STAFF);
}
}
}

} // namespace vrv

0 comments on commit 7ed928e

Please sign in to comment.