Skip to content

Commit

Permalink
Fix GH#9779 beam stem direction flip
Browse files Browse the repository at this point in the history
Update chord's set stem direction method to set the beam's direction
to Direction::AUTO if applicable.

Update the beam's set direction method to update its notes' stem
direction.

When a beam's direction is set with the "x" keyboard key, the
"_direction" member of the beam class is no longer equal to
"Direction::AUTO". So, in the beam's layout code the final beam
direction is not taken from the first note in the note group
(of the beam) but from the "_direction" member.

The problem is that if the user tries to set the beam's direction
with a note stem direction (in the property panel), it will be
ignored in the beam's layout code.

Backport of musescore#9800, resp. duplicate of musescore#9851
  • Loading branch information
LovCAPONE authored and Jojo-Schmitz committed Nov 28, 2021
1 parent 86b5461 commit baa3d94
Show file tree
Hide file tree
Showing 7 changed files with 1,359 additions and 4 deletions.
8 changes: 7 additions & 1 deletion libmscore/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2228,8 +2228,14 @@ std::vector<QPointF> Beam::gripsPositions(const EditData& ed) const
void Beam::setBeamDirection(Direction d)
{
_direction = d;
if (d != Direction::AUTO)
if (d != Direction::AUTO) {
_up = d == Direction::UP;
if (!_elements.empty()) {
Chord* c = toChord(_elements.first());
if (c)
c->setStemDirection(d, d);
}
}
}

//---------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ qreal Chord::dotPosX() const
// setStemDirection
//---------------------------------------------------------

void Chord::setStemDirection(Direction d)
void Chord::setStemDirection(Direction d, Direction beamDir)
{
_stemDirection = d;
if (beam()) {
Expand All @@ -2771,6 +2771,8 @@ void Chord::setStemDirection(Direction d)
if (c)
c->_stemDirection = d;
}
if (beamDir == Direction::AUTO)
beam()->setBeamDirection(beamDir);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/chord.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Chord final : public ChordRest {
bool readProperties(XmlReader&) override;
Element* drop(EditData&) override;

void setStemDirection(Direction d);
void setStemDirection(Direction d, Direction beamDir = Direction::AUTO);
Direction stemDirection() const { return _stemDirection; }

LedgerLine* ledgerLines() { return _ledgerLines; }
Expand Down
Loading

0 comments on commit baa3d94

Please sign in to comment.