Skip to content

Commit

Permalink
Set up cross measure durations earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Sep 17, 2024
1 parent 83f5577 commit 56d2034
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/engraving/rendering/score/beamlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,6 @@ void BeamLayout::beamGraceNotes(LayoutContext& ctx, Chord* mainNote, bool after)

void BeamLayout::createBeams(LayoutContext& ctx, Measure* measure)
{
bool crossMeasure = ctx.conf().styleB(Sid::crossMeasureValues);

for (track_idx_t track = 0; track < ctx.dom().ntracks(); ++track) {
const Staff* stf = ctx.dom().staff(track2staff(track));

Expand Down Expand Up @@ -738,17 +736,12 @@ void BeamLayout::createBeams(LayoutContext& ctx, Measure* measure)
cr->removeDeleteBeam(false);
}

// handle grace notes and cross-measure beaming
// handle grace notes
// (tied chords?)
if (cr->isChord()) {
Chord* chord = toChord(cr);
beamGraceNotes(ctx, chord, false); // grace before
beamGraceNotes(ctx, chord, true); // grace after
// set up for cross-measure values as soon as possible
// to have all computations (stems, hooks, ...) consistent with it
if (!chord->isGrace()) {
ChordLayout::crossMeasureSetup(chord, crossMeasure, ctx);
}
}

if (cr->isRest() && cr->beamMode() == BeamMode::AUTO) {
Expand Down
1 change: 1 addition & 0 deletions src/engraving/rendering/score/measurelayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ void MeasureLayout::layoutMeasure(MeasureBase* currentMB, LayoutContext& ctx)
checkStaffMoveValidity(measure, ctx);

// ---- Modify DOM ----
ModifyDom::setCrossMeasure(measure, ctx);
ModifyDom::connectTremolo(measure);
ModifyDom::cmdUpdateNotes(measure, ctx.dom());
ModifyDom::createStems(measure, ctx);
Expand Down
35 changes: 35 additions & 0 deletions src/engraving/rendering/score/modifydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,44 @@
#include "dom/keysig.h"
#include "dom/hook.h"
#include "dom/part.h"
#include "rendering/score/chordlayout.h"

using namespace mu::engraving::rendering::score;

void ModifyDom::setCrossMeasure(const Measure* measure, LayoutContext& ctx)
{
bool crossMeasure = ctx.conf().styleB(Sid::crossMeasureValues);
const DomAccessor& dom = ctx.dom();
for (staff_idx_t staffIdx = 0; staffIdx < dom.nstaves(); ++staffIdx) {
const Staff* staff = dom.staff(staffIdx);
if (!staff->show()) {
continue;
}

track_idx_t startTrack = staffIdx * VOICES;
track_idx_t endTrack = startTrack + VOICES;

for (const Segment& segment : measure->segments()) {
if (!segment.isJustType(SegmentType::ChordRest)) {
continue;
}

for (track_idx_t t = startTrack; t < endTrack; ++t) {
ChordRest* cr = segment.cr(t);
if (!cr) {
continue;
}
if (cr->isChord()) {
Chord* chord = toChord(cr);
if (!chord->isGrace()) {
ChordLayout::crossMeasureSetup(chord, crossMeasure, ctx);
}
}
}
}
}
}

void ModifyDom::connectTremolo(Measure* m)
{
m->connectTremolo();
Expand Down
1 change: 1 addition & 0 deletions src/engraving/rendering/score/modifydom.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ModifyDom
{
public:

static void setCrossMeasure(const Measure* measure, LayoutContext& ctx);
static void connectTremolo(Measure* m);
static void cmdUpdateNotes(const Measure* measure, const DomAccessor& dom);
static void createStems(const Measure* measure, LayoutContext& ctx);
Expand Down
Binary file added vtest/scores/cross-measure-1.mscz
Binary file not shown.

0 comments on commit 56d2034

Please sign in to comment.