Skip to content

Commit

Permalink
Fix flip then undo on drum staff
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Feb 19, 2025
1 parent dec1cc5 commit 06ad4b5
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 16 deletions.
29 changes: 19 additions & 10 deletions src/engraving/rendering/score/beamlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "containers.h"

#include "dom/beam.h"
#include "dom/drumset.h"
#include "dom/part.h"
#include "dom/tremolotwochord.h"
#include "dom/tremolosinglechord.h"
#include "dom/chord.h"
Expand Down Expand Up @@ -154,7 +156,7 @@ void BeamLayout::layout1(Beam* item, LayoutContext& ctx)
return;
}

if (item->staff()->isDrumStaff(Fraction(0, 1))) {
if (item->staff()->isDrumStaff(item->tick())) {
if (item->direction() != DirectionV::AUTO) {
item->setUp(item->direction() == DirectionV::UP);
} else if (item->isGrace()) {
Expand All @@ -165,15 +167,22 @@ void BeamLayout::layout1(Beam* item, LayoutContext& ctx)
bool firstUp = false;
bool firstChord = true;
for (ChordRest* cr : item->elements()) {
if (cr->isChord()) {
DirectionV crDirection = toChord(cr)->stemDirection();
if (crDirection != DirectionV::AUTO) {
item->setUp(crDirection == DirectionV::UP);
break;
} else if (firstChord) {
firstUp = cr->up();
firstChord = false;
}
if (!cr->isChord()) {
item->setUp(firstUp);
continue;
}
Chord* chord = toChord(cr);
DirectionV crDirection = toChord(cr)->stemDirection();
if (crDirection != DirectionV::AUTO) {
item->setUp(crDirection == DirectionV::UP);
break;
}
if (firstChord) {
const Staff* staff = item->staff();
const Part* part = staff ? staff->part() : nullptr;
const Drumset* ds = part ? part->instrument(item->tick())->drumset() : nullptr;
firstUp = ds ? ds->stemDirection(chord->upNote()->pitch()) == DirectionV::UP : chord->up();
firstChord = false;
}
item->setUp(firstUp);
}
Expand Down
Loading

0 comments on commit 06ad4b5

Please sign in to comment.