Skip to content

Commit

Permalink
Merge pull request #6379 from Howard-C/rebased-PRs
Browse files Browse the repository at this point in the history
Commits rebased from 3.x
  • Loading branch information
igorkorsukov authored Jul 29, 2020
2 parents fd4c58a + 04f0db7 commit 0cac4ec
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 117 deletions.
16 changes: 8 additions & 8 deletions libmscore/ambitus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ void Ambitus::write(XmlWriter& xml) const
xml.tag(Pid::HEAD_GROUP, int(_noteHeadGroup), int(NOTEHEADGROUP_DEFAULT));
xml.tag(Pid::HEAD_TYPE, int(_noteHeadType), int(NOTEHEADTYPE_DEFAULT));
xml.tag(Pid::MIRROR_HEAD,int(_dir), int(DIR_DEFAULT));
xml.tag("hasLine", _hasLine, true);
xml.tag(Pid::LINE_WIDTH, _lineWidth, LINEWIDTH_DEFAULT);
xml.tag("hasLine", _hasLine, true);
xml.tag(Pid::LINE_WIDTH_SPATIUM, _lineWidth, LINEWIDTH_DEFAULT);
xml.tag("topPitch", _topPitch);
xml.tag("topTpc", _topTpc);
xml.tag("bottomPitch",_bottomPitch);
Expand Down Expand Up @@ -252,7 +252,7 @@ bool Ambitus::readProperties(XmlReader& e)
} else if (tag == "hasLine") {
setHasLine(e.readInt());
} else if (tag == "lineWidth") {
readProperty(e, Pid::LINE_WIDTH);
readProperty(e, Pid::LINE_WIDTH_SPATIUM);
} else if (tag == "topPitch") {
_topPitch = e.readInt();
} else if (tag == "bottomPitch") {
Expand Down Expand Up @@ -673,7 +673,7 @@ QVariant Ambitus::getProperty(Pid propertyId) const
return int(direction());
case Pid::GHOST: // recycled property = _hasLine
return hasLine();
case Pid::LINE_WIDTH:
case Pid::LINE_WIDTH_SPATIUM:
return lineWidth();
case Pid::TPC1:
return topTpc();
Expand Down Expand Up @@ -711,7 +711,7 @@ bool Ambitus::setProperty(Pid propertyId, const QVariant& v)
case Pid::GHOST: // recycled property = _hasLine
setHasLine(v.toBool());
break;
case Pid::LINE_WIDTH:
case Pid::LINE_WIDTH_SPATIUM:
setLineWidth(v.value<Spatium>());
break;
case Pid::TPC1:
Expand All @@ -727,10 +727,10 @@ bool Ambitus::setProperty(Pid propertyId, const QVariant& v)
setBottomPitch(v.toInt());
break;
case Pid::FBPARENTHESIS3: // recycled property = octave of _topPitch
setTopPitch(topPitch() % 12 + v.toInt() * 12);
setTopPitch(topPitch() % 12 + (v.toInt() + 1) * 12);
break;
case Pid::FBPARENTHESIS4: // recycled property = octave of _bottomPitch
setBottomPitch(bottomPitch() % 12 + v.toInt() * 12);
setBottomPitch(bottomPitch() % 12 + (v.toInt() + 1) * 12);
break;
default:
return Element::setProperty(propertyId, v);
Expand All @@ -754,7 +754,7 @@ QVariant Ambitus::propertyDefault(Pid id) const
return int(DIR_DEFAULT);
case Pid::GHOST:
return HASLINE_DEFAULT;
case Pid::LINE_WIDTH:
case Pid::LINE_WIDTH_SPATIUM:
return Spatium(LINEWIDTH_DEFAULT);
case Pid::TPC1:
return estimateRanges().topTpc;
Expand Down
18 changes: 11 additions & 7 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,33 +1513,37 @@ qreal Chord::minAbsStemLength() const
return 0.0;
}

const qreal sw = score()->styleS(Sid::tremoloStrokeWidth).val();
const qreal td = score()->styleS(Sid::tremoloDistance).val();
const qreal sw = score()->styleS(Sid::tremoloStrokeWidth).val() * mag();
const qreal td = score()->styleS(Sid::tremoloDistance).val() * mag();
int beamLvl = beams();
const qreal beamDist = beam() ? beam()->beamDist() : (sw * spatium());

// single-note tremolo
if (!_tremolo->twoNotes()) {
_tremolo->layout(); // guarantee right "height value"

qreal height;
// distance between tremolo stroke(s) and chord
// choose the furthest/nearest note to calculate for unbeamed/beamed chords
// this is due to special layout mechanisms regarding beamed chords
// may be changed if beam layout code is improved/rewritten
qreal height = 0.0;
if (up()) {
height = upPos() - _tremolo->pos().y();
height = (beam() ? upPos() : downPos()) - _tremolo->pos().y();
} else {
height = _tremolo->pos().y() + _tremolo->height() - downPos();
height = _tremolo->pos().y() + _tremolo->minHeight() * spatium() - (beam() ? downPos() : upPos());
}
const bool hasHook = beamLvl && !beam();
if (hasHook) {
beamLvl += (up() ? 4 : 2); // reserve more space for stem with both hook and tremolo
}
const qreal additionalHeight = beamLvl ? 0 : sw* spatium();
const qreal additionalHeight = beamLvl ? 0 : (sw * spatium());

return height + beamLvl * beamDist + additionalHeight;
}
// two-note tremolo
else {
if (_tremolo->chord1()->up() == _tremolo->chord2()->up()) {
const qreal tremoloMinHeight = ((_tremolo->lines() - 1) * td + sw) * spatium();
const qreal tremoloMinHeight = _tremolo->minHeight() * spatium();
return tremoloMinHeight + beamLvl * beamDist + 2 * td * spatium();
}
return 0.0;
Expand Down
72 changes: 39 additions & 33 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,37 +812,57 @@ void Score::cmdAddTimeSig(Measure* fm, int staffIdx, TimeSig* ts, bool local)
return;
}

auto getStaffIdxRange
= [this, local, staffIdx](const Score* score) -> std::pair<int /*start*/, int /*end*/> {
int startStaffIdx, endStaffIdx;
if (local) {
if (score == this) {
startStaffIdx = staffIdx;
endStaffIdx = startStaffIdx + 1;
} else {
// TODO: get index for this score
qDebug("cmdAddTimeSig: unable to write local time signature change to linked score");
startStaffIdx = 0;
endStaffIdx = 0;
}
} else {
startStaffIdx = 0;
endStaffIdx = score->nstaves();
}
return std::make_pair(startStaffIdx, endStaffIdx);
};

if (ots && ots->sig() == ns && ots->stretch() == ts->stretch()) {
//
// the measure duration does not change,
// so its ok to just update the time signatures
//
TimeSig* nts = staff(staffIdx)->nextTimeSig(tick + Fraction::fromTicks(1));
const Fraction lmTick = nts ? nts->segment()->tick() : Fraction(-1,1);
const Fraction lmTick = nts ? nts->segment()->tick() : Fraction(-1, 1);
for (Score* score : scoreList()) {
Measure* mf = score->tick2measure(tick);
Measure* lm = (lmTick != Fraction(-1,1)) ? score->tick2measure(lmTick) : nullptr;
Measure* lm = (lmTick != Fraction(-1, 1)) ? score->tick2measure(lmTick) : nullptr;
for (Measure* m = mf; m != lm; m = m->nextMeasure()) {
bool changeActual = m->ticks() == m->timesig();
m->undoChangeProperty(Pid::TIMESIG_NOMINAL, QVariant::fromValue(ns));
if (changeActual) {
m->undoChangeProperty(Pid::TIMESIG_ACTUAL, QVariant::fromValue(ns));
m->undoChangeProperty(Pid::TIMESIG_ACTUAL, QVariant::fromValue(ns));
}
std::pair<int, int> staffIdxRange = getStaffIdxRange(score);
for (int si = staffIdxRange.first; si < staffIdxRange.second; ++si) {
TimeSig* nsig = toTimeSig(seg->element(si * VOICES));
nsig->undoChangeProperty(Pid::SHOW_COURTESY, ts->showCourtesySig());
nsig->undoChangeProperty(Pid::TIMESIG, QVariant::fromValue(ts->sig()));
nsig->undoChangeProperty(Pid::TIMESIG_TYPE, int(ts->timeSigType()));
nsig->undoChangeProperty(Pid::NUMERATOR_STRING, ts->numeratorString());
nsig->undoChangeProperty(Pid::DENOMINATOR_STRING, ts->denominatorString());
nsig->undoChangeProperty(Pid::TIMESIG_STRETCH, QVariant::fromValue(ts->stretch()));
nsig->undoChangeProperty(Pid::GROUPS, QVariant::fromValue(ts->groups()));
nsig->setSelected(false);
nsig->setDropTarget(0);
}
}
}
int n = nstaves();
for (int si = 0; si < n; ++si) {
TimeSig* nsig = toTimeSig(seg->element(si * VOICES));
nsig->undoChangeProperty(Pid::SHOW_COURTESY, ts->showCourtesySig());
nsig->undoChangeProperty(Pid::TIMESIG, QVariant::fromValue(ts->sig()));
nsig->undoChangeProperty(Pid::TIMESIG_TYPE, int(ts->timeSigType()));
nsig->undoChangeProperty(Pid::NUMERATOR_STRING, ts->numeratorString());
nsig->undoChangeProperty(Pid::DENOMINATOR_STRING, ts->denominatorString());
nsig->undoChangeProperty(Pid::TIMESIG_STRETCH, QVariant::fromValue(ts->stretch()));
nsig->undoChangeProperty(Pid::GROUPS, QVariant::fromValue(ts->groups()));
nsig->setSelected(false);
nsig->setDropTarget(0);
}
} else {
Score* mScore = masterScore();
Measure* mf = mScore->tick2measure(tick);
Expand Down Expand Up @@ -885,23 +905,9 @@ void Score::cmdAddTimeSig(Measure* fm, int staffIdx, TimeSig* ts, bool local)
std::map<int, TimeSig*> masterTimeSigs;
for (Score* score : scoreList()) {
Measure* nfm = score->tick2measure(tick);
seg = nfm->undoGetSegment(SegmentType::TimeSig, nfm->tick());
int startStaffIdx, endStaffIdx;
if (local) {
if (score == this) {
startStaffIdx = staffIdx;
endStaffIdx = startStaffIdx + 1;
} else {
// TODO: get index for this score
qDebug("cmdAddTimeSig: unable to write local time signature change to linked score");
startStaffIdx = 0;
endStaffIdx = 0;
}
} else {
startStaffIdx = 0;
endStaffIdx = score->nstaves();
}
for (int si = startStaffIdx; si < endStaffIdx; ++si) {
seg = nfm->undoGetSegment(SegmentType::TimeSig, nfm->tick());
std::pair<int, int> staffIdxRange = getStaffIdxRange(score);
for (int si = staffIdxRange.first; si < staffIdxRange.second; ++si) {
TimeSig* nsig = toTimeSig(seg->element(si * VOICES));
if (nsig == 0) {
nsig = new TimeSig(*ts);
Expand Down
2 changes: 2 additions & 0 deletions libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ static constexpr PropertyMetaData propertyList[] = {
DUMMY_QT_TRANSLATE_NOOP("propertyName", "line style") },
{ Pid::LINE_WIDTH, false, "lineWidth", P_TYPE::SP_REAL,
DUMMY_QT_TRANSLATE_NOOP("propertyName", "line width") },
{ Pid::LINE_WIDTH_SPATIUM, false, "lineWidth", P_TYPE::SPATIUM,
DUMMY_QT_TRANSLATE_NOOP("propertyName", "line width (spatium)") },
{ Pid::LASSO_POS, false, 0, P_TYPE::POINT_MM,
DUMMY_QT_TRANSLATE_NOOP("propertyName", "lasso position") },
{ Pid::LASSO_SIZE, false, 0, P_TYPE::SIZE_MM,
Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ enum class Pid {
GROUPS,
LINE_STYLE,
LINE_WIDTH,
LINE_WIDTH_SPATIUM,
LASSO_POS,
LASSO_SIZE,
TIME_STRETCH,
Expand Down
Loading

1 comment on commit 0cac4ec

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an automatic message. This commit appears to change some of the visual tests.
Please carefully review the new visual test results in the uploaded artifact that can be found
here

Please sign in to comment.