Skip to content

Commit

Permalink
Distinguish cue and grace when setting stem direction in beam. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 16, 2023
1 parent eb7505f commit ff1a7e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
8 changes: 7 additions & 1 deletion include/vrv/drawinginterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/calcstemfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
15 changes: 14 additions & 1 deletion src/drawinginterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ff1a7e6

Please sign in to comment.