diff --git a/include/vrv/drawinginterface.h b/include/vrv/drawinginterface.h index a7932dfc8cd..32d2e88e253 100644 --- a/include/vrv/drawinginterface.h +++ b/include/vrv/drawinginterface.h @@ -111,11 +111,17 @@ class BeamDrawingInterface : public ObjectListInterface { ///@} /** - * Initialize m_cueSize value based on the @cue attribute and presence of child elements with @cue/@grace + * Initialize m_cueSize value based on the @cue attribute and presence of child elements with @cue * attributes */ void InitCue(bool beamCue); + /** + * Initialize m_notesStemDir value based on the @graceGrp attribute and presence of child elements with @grace + * attributes + */ + void InitGraceStemDir(bool graceGrp); + bool IsHorizontal() const; bool IsRepeatedPattern() const; diff --git a/src/calcstemfunctor.cpp b/src/calcstemfunctor.cpp index 115a5d26bc9..ffc1d5dcee7 100644 --- a/src/calcstemfunctor.cpp +++ b/src/calcstemfunctor.cpp @@ -58,6 +58,7 @@ FunctorCode CalcStemFunctor::VisitBeam(Beam *beam) if (!beam->HasCoords()) { beam->InitCoords(beamChildren, staff, beam->GetPlace()); const bool isCue = ((beam->GetCue() == BOOLEAN_true) || beam->GetFirstAncestor(GRACEGRP)); + beam->InitGraceStemDir(beam->GetFirstAncestor(GRACEGRP)); beam->InitCue(isCue); } diff --git a/src/drawinginterface.cpp b/src/drawinginterface.cpp index 029b56a8477..cc4a339e0b7 100644 --- a/src/drawinginterface.cpp +++ b/src/drawinginterface.cpp @@ -261,8 +261,21 @@ void BeamDrawingInterface::InitCue(bool beamCue) }); } + return; +} + +void BeamDrawingInterface::InitGraceStemDir(bool graceGrp) +{ + if (!graceGrp) { + graceGrp = std::all_of(m_beamElementCoords.begin(), m_beamElementCoords.end(), [](BeamElementCoord *coord) { + if (!coord->m_element) return false; + if (coord->m_element->IsGraceNote()) return true; + return false; + }); + } + // Always set stem direction to up for grace note beam unless stem direction is provided - if (m_cueSize && (m_notesStemDir == STEMDIRECTION_NONE)) { + if (graceGrp && (m_notesStemDir == STEMDIRECTION_NONE)) { m_notesStemDir = STEMDIRECTION_up; } }