From 7ed928e9991e1bd5b5e916373093442666bb2a2e Mon Sep 17 00:00:00 2001 From: David Bauer Date: Mon, 28 Oct 2024 23:48:01 +0100 Subject: [PATCH] Consider beam staff for artic cross staff --- include/vrv/calcarticfunctor.h | 2 ++ src/adjustarticfunctor.cpp | 6 +++--- src/calcarticfunctor.cpp | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/vrv/calcarticfunctor.h b/include/vrv/calcarticfunctor.h index 8b1884e6653..bca9579df01 100644 --- a/include/vrv/calcarticfunctor.h +++ b/include/vrv/calcarticfunctor.h @@ -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: // diff --git a/src/adjustarticfunctor.cpp b/src/adjustarticfunctor.cpp index 7bfe283e428..9257b65fba3 100644 --- a/src/adjustarticfunctor.cpp +++ b/src/adjustarticfunctor.cpp @@ -34,11 +34,11 @@ FunctorCode AdjustArticFunctor::VisitArtic(Artic *artic) int yIn, yOut, yRel; Staff *staff = artic->GetAncestorStaff(RESOLVE_CROSS_STAFF); - Beam *beam = vrv_cast(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(m_parent->FindDescendantByType(STEM)); - Flag *flag = vrv_cast(m_parent->FindDescendantByType(FLAG)); + const Stem *stem = vrv_cast(m_parent->FindDescendantByType(STEM)); + const Flag *flag = vrv_cast(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(); diff --git a/src/calcarticfunctor.cpp b/src/calcarticfunctor.cpp index 6464dbac848..92f54c3d01a 100644 --- a/src/calcarticfunctor.cpp +++ b/src/calcarticfunctor.cpp @@ -134,6 +134,8 @@ FunctorCode CalcArticFunctor::VisitChord(Chord *chord) } } + this->IncludeBeamStaff(chord); + return FUNCTOR_CONTINUE; } @@ -164,6 +166,8 @@ FunctorCode CalcArticFunctor::VisitNote(Note *note) m_crossStaffBelow = true; } + this->IncludeBeamStaff(note); + return FUNCTOR_CONTINUE; } @@ -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