Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/engraving/dom/barline.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class BarLine final : public EngravingItem
Segment* segment() const { return toSegment(explicitParent()); }
Measure* measure() const { return explicitParent() ? toMeasure(explicitParent()->explicitParent()) : nullptr; }

void setSpanStaff(int val) { m_spanStaff = val; }
void setSpanStaff(const bool val) { m_spanStaff = val; }
void setSpanFrom(int val) { m_spanFrom = val; }
void setSpanTo(int val) { m_spanTo = val; }
void setShowTips(bool val);
int spanStaff() const { return m_spanStaff; }
bool spanStaff() const { return m_spanStaff; }
int spanFrom() const { return m_spanFrom; }
int spanTo() const { return m_spanTo; }
bool showTips() const;
Expand Down Expand Up @@ -176,7 +176,7 @@ class BarLine final : public EngravingItem
BarLine(Segment* parent);
BarLine(const BarLine&);

int m_spanStaff = 0; // span barline to next staff if true, values > 1 are used for importing from 2.x
bool m_spanStaff = false; // span barline to next staff if true
int m_spanFrom = 0; // line number on start and end staves
int m_spanTo = 0;
BarLineType m_barLineType = BarLineType::NORMAL;
Expand Down
43 changes: 1 addition & 42 deletions src/engraving/dom/excerpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include "excerpt.h"

#include <list>

#include "containers.h"

#include "dom/partialtie.h"
Expand All @@ -36,7 +34,6 @@
#include "factory.h"
#include "guitarbend.h"
#include "harmony.h"
#include "laissezvib.h"
#include "layoutbreak.h"
#include "linkedobjects.h"
#include "lyrics.h"
Expand All @@ -49,7 +46,6 @@
#include "rest.h"
#include "score.h"
#include "segment.h"
#include "sig.h"
#include "staff.h"
#include "stafftype.h"
#include "system.h"
Expand Down Expand Up @@ -991,38 +987,6 @@ static MeasureBase* cloneMeasure(MeasureBase* mb, Score* score, const Score* osc
}

EngravingItem* oe = oseg->element(srcTrack);
int adjustedBarlineSpan = 0;
if (srcTrack % VOICES == 0 && oseg->segmentType() == SegmentType::BarLine) {
// mid-measure barline segment
// may need to clone barline from a previous staff and/or adjust span
int oIdx = static_cast<int>(srcTrack / VOICES);
if (!oe) {
// no barline on this staff in original score,
// but check previous staves
for (int i = oIdx - 1; i >= 0; --i) {
oe = oseg->element(i * VOICES);
if (oe) {
break;
}
}
}
if (oe) {
// barline found, now check span
BarLine* bl = toBarLine(oe);
int oSpan1 = static_cast<int>(bl->staff()->idx());
int oSpan2 = static_cast<int>(oSpan1 + bl->spanStaff());
if (oSpan1 <= oIdx && oIdx <= oSpan2) {
// this staff is within span
// calculate adjusted span for excerpt
int oSpan = oSpan2 - oIdx;
adjustedBarlineSpan = std::min(oSpan, static_cast<int>(score->nstaves()));
} else {
// this staff is not within span
oe = nullptr;
}
}
}

bool clone = oe && !oe->generated() && !oe->excludeFromOtherParts();

if (clone) {
Expand All @@ -1036,12 +1000,7 @@ static MeasureBase* cloneMeasure(MeasureBase* mb, Score* score, const Score* osc
}

ne->setScore(score);
if (oe->isBarLine()) {
BarLine* nbl = toBarLine(ne);
if (adjustedBarlineSpan) {
nbl->setSpanStaff(adjustedBarlineSpan);
}
} else if (oe->isChordRest()) {
if (oe->isChordRest()) {
ChordRest* ocr = toChordRest(oe);
ChordRest* ncr = toChordRest(ne);

Expand Down
9 changes: 4 additions & 5 deletions src/engraving/dom/instrtemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ InstrumentTemplate::InstrumentTemplate()
smallStaff[i] = false;
bracket[i] = BracketType::NO_BRACKET;
bracketSpan[i] = 0;
barlineSpan[i] = false;
}
transpose.diatonic = 0;
transpose.chromatic = 0;
Expand Down Expand Up @@ -255,14 +254,14 @@ void InstrumentTemplate::init(const InstrumentTemplate& t)
trait = t.trait;
groupId = t.groupId;
glissandoStyle = t.glissandoStyle;
barlineSpan = t.barlineSpan;

for (int i = 0; i < MAX_STAVES; ++i) {
clefTypes[i] = t.clefTypes[i];
staffLines[i] = t.staffLines[i];
smallStaff[i] = t.smallStaff[i];
bracket[i] = t.bracket[i];
bracketSpan[i] = t.bracketSpan[i];
barlineSpan[i] = t.barlineSpan[i];
}
}

Expand Down Expand Up @@ -356,10 +355,10 @@ void InstrumentTemplate::write(XmlWriter& xml) const
}
}
if (barlineSpan[i]) {
if (i) {
xml.tag("barlineSpan", { { "staff", i + 1 } }, barlineSpan[i]);
if (i > 0) {
xml.tag("barlineSpan", { { "staff", i + 1 } }, int { barlineSpan[i] });
} else {
xml.tag("barlineSpan", barlineSpan[i]);
xml.tag("barlineSpan", int { barlineSpan[i] });
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/engraving/dom/instrtemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once

#ifndef MU_ENGRAVING_INSTRTEMPLATE_H
#define MU_ENGRAVING_INSTRTEMPLATE_H

#include <array>
#include <list>

#include "io/path.h"
Expand Down Expand Up @@ -119,7 +118,7 @@ class InstrumentTemplate
int staffLines[MAX_STAVES];
BracketType bracket[MAX_STAVES]; // bracket type (NO_BRACKET)
int bracketSpan[MAX_STAVES];
int barlineSpan[MAX_STAVES];
std::array<bool, MAX_STAVES> barlineSpan{};
bool smallStaff[MAX_STAVES];

bool extended = false; // belongs to extended instrument set if true
Expand Down Expand Up @@ -193,4 +192,3 @@ extern void addTemplateToGroup(const InstrumentTemplate* templ, const String& gr

extern ClefType defaultClef(int patch);
} // namespace mu::engraving
#endif
15 changes: 7 additions & 8 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4043,9 +4043,7 @@ void Score::updateBracesAndBarlines(Part* part, size_t newIndex)
auto updateBracketSpan = [this, part](size_t modIndex, size_t refIndex) {
Staff* modStaff = staff(part->staves()[modIndex]->idx());
Staff* refStaff = staff(part->staves()[refIndex]->idx());
if (modStaff->getProperty(Pid::STAFF_BARLINE_SPAN) != refStaff->getProperty(Pid::STAFF_BARLINE_SPAN)) {
modStaff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, refStaff->getProperty(Pid::STAFF_BARLINE_SPAN));
}
modStaff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, refStaff->getProperty(Pid::STAFF_BARLINE_SPAN));
};

if (newIndex >= 2) {
Expand All @@ -4055,8 +4053,9 @@ void Score::updateBracesAndBarlines(Part* part, size_t newIndex)
if (part->nstaves() == 2) {
const InstrumentTemplate* tp = searchTemplate(part->instrumentId());
if (tp) {
if (tp->barlineSpan[0] > 0) {
staff(part->staves()[0]->idx())->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, tp->barlineSpan[0]);
const bool firstStaffBarLineSpan = tp->barlineSpan[0];
if (firstStaffBarLineSpan) {
staff(part->staff(0)->idx())->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, firstStaffBarLineSpan);
}
if (noBracesFound && (tp->bracket[0] != BracketType::NO_BRACKET)) {
undoAddBracket(part->staves()[0], 0, tp->bracket[0], part->nstaves());
Expand Down Expand Up @@ -4145,8 +4144,8 @@ void Score::remapBracketsAndBarlines()
// Look in the masterScore for all the staves spanned by a common barline.
// If at least one of them is also in this score, then connect it through.
bool extendBarline = false;
int span = masterStaff->barLineSpan();
while (!extendBarline && span > 0 && masterStaff->idx() + 1 < master->nstaves()) {
bool span = masterStaff->barLineSpan();
while (!extendBarline && span && masterStaff->idx() + 1 < master->nstaves()) {
masterStaff = masterScore()->staff(masterStaff->idx() + 1);
span = masterStaff->barLineSpan();
if (masterStaff->findLinkedInScore(this)) {
Expand All @@ -4155,7 +4154,7 @@ void Score::remapBracketsAndBarlines()
}
}
if (extendBarline) {
staff->setBarLineSpan(1);
staff->setBarLineSpan(true);
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/engraving/dom/scoreorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void ScoreOrder::setBracketsAndBarlines(Score* score)
}
}
if (!braceSpan) {
staff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, 0);
staff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, false);
} else {
--braceSpan;
}
Expand Down Expand Up @@ -462,11 +462,8 @@ void ScoreOrder::setBracketsAndBarlines(Score* score)
thnBracketSpan += static_cast<int>(part->nstaves());
}
if (prvStaff) {
bool oldBarlineSpan = prvStaff->getProperty(Pid::STAFF_BARLINE_SPAN).toBool();
bool newBarlineSpan = prvBarLineSpan && (!prvSection.isEmpty() && (sg.section == prvSection));
if (oldBarlineSpan != newBarlineSpan) {
prvStaff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, newBarlineSpan);
}
const bool newBarlineSpan = prvBarLineSpan && (!prvSection.isEmpty() && (sg.section == prvSection));
prvStaff->undoChangeProperty(Pid::STAFF_BARLINE_SPAN, newBarlineSpan);
}
prvStaff = staff;
++staffIdx;
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ bool Staff::setProperty(Pid id, const PropertyValue& v)
setPlaybackVoice(3, v.toBool());
break;
case Pid::STAFF_BARLINE_SPAN: {
setBarLineSpan(v.toInt());
setBarLineSpan(v.toBool());
// update non-generated barlines
track_idx_t track = idx() * VOICES;
std::vector<EngravingItem*> blList;
Expand All @@ -1645,7 +1645,7 @@ bool Staff::setProperty(Pid id, const PropertyValue& v)
}
for (EngravingItem* e : blList) {
if (e && e->isBarLine() && !e->generated()) {
toBarLine(e)->setSpanStaff(v.toInt());
toBarLine(e)->setSpanStaff(barLineSpan());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/engraving/dom/staff.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ class Staff final : public EngravingItem
void setMergeMatchingRests(AutoOnOff val) { m_mergeMatchingRests = val; }
bool shouldMergeMatchingRests() const;

int barLineSpan() const { return m_barLineSpan; }
bool barLineSpan() const { return m_barLineSpan; }
int barLineFrom() const { return m_barLineFrom; }
int barLineTo() const { return m_barLineTo; }
void setBarLineSpan(int val) { m_barLineSpan = val; }
void setBarLineSpan(const bool val) { m_barLineSpan = val; }
void setBarLineFrom(int val) { m_barLineFrom = val; }
void setBarLineTo(int val) { m_barLineTo = val; }
double staffHeight() const;
Expand Down Expand Up @@ -293,7 +293,7 @@ class Staff final : public EngravingItem
std::map<int, TimeSig*> m_timesigs;

std::vector<BracketItem*> m_brackets;
int m_barLineSpan = false; // true - span barline to next staff
bool m_barLineSpan = false; // true - span barline to next staff
int m_barLineFrom = 0; // line of start staff to draw the barline from (0 = staff top line, ...)
int m_barLineTo = 0; // line of end staff to draw the bar line to (0= staff bottom line, ...)

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/dynamicslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void DynamicsLayout::manageBarlineCollisions(const Dynamic* item, TextBase::Layo
return;
}

if (item->score()->staff(barLineStaff)->barLineSpan() < 1) {
if (!item->score()->staff(barLineStaff)->barLineSpan()) {
return; // Barline doesn't extend through staves
}

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/horizontalspacing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ double HorizontalSpacing::spaceLyricsAgainstBarlines(Segment* firstSeg, Segment*
}

BarLine* barline = toBarLine(barlineSegment->element(staff2track(staffIdx)));
if (!barline || barline->spanStaff() == 0) {
if (!barline || !barline->spanStaff()) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/masklayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void MaskLayout::computeBarlineMasks(const Segment* barlineSement, const System*
continue;
}
BarLine* barline = toBarLine(barlineSement->element(staff2track(staffIdx)));
if (!barline || barline->spanStaff() == 0) {
if (!barline || !barline->spanStaff()) {
continue;
}
maskBarlineForText(barline, allSystemText);
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/measurenumberlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void MeasureNumberLayout::checkBarlineCollisions(const MeasureNumber* item, cons
}

const double minBarLineDistance = 0.25 * item->spatium();
if (!barlineSeg || (barlineSeg->segmentType() != SegmentType::BeginBarLine && item->score()->staff(barlineStaff)->barLineSpan() < 1)) {
if (!barlineSeg || (barlineSeg->segmentType() != SegmentType::BeginBarLine && !item->score()->staff(barlineStaff)->barLineSpan())) {
return;
}

Expand Down
Loading
Loading