Skip to content

Commit

Permalink
ported #6580, #6541, #7004, #7192, #7212
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov authored and vpereverzev committed Feb 8, 2021
1 parent 57057e6 commit 9fc9146
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 56 deletions.
1 change: 0 additions & 1 deletion src/libmscore/bracket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ void Bracket::draw(QPainter* painter) const
break;
case BracketType::LINE: {
qreal h = 2 * h2;
qreal _spatium = spatium();
qreal w = 0.67 * score()->styleP(Sid::bracketWidth);
QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap);
painter->setPen(pen);
Expand Down
7 changes: 3 additions & 4 deletions src/libmscore/changeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,9 @@ void ChangeMap::dump()
if (event.type == ChangeEventType::FIX) {
qDebug().nospace() << "===" << tick.ticks() << " : FIX " << event.value;
} else if (event.type == ChangeEventType::RAMP) {
qDebug().nospace() << "===" << tick.ticks() << " to " << (tick + event.length).ticks() << " : RAMP diff "
<< event.value << " " << ChangeMap::changeMethodToName(event.method) << " ("
<< event.cachedStartVal
<< ", " << event.cachedEndVal << ")";
qDebug().nospace() << "===" << tick.ticks() << " to " << (tick + event.length).ticks() << " : RAMP diff " << event.value
<< " " << ChangeMap::changeMethodToName(event.method) << " (" << event.cachedStartVal << ", "
<< event.cachedEndVal << ")";
} else if (event.type == ChangeEventType::INVALID) {
qDebug().nospace() << "===" << tick.ticks() << " : INVALID value" << event.value;
}
Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,8 +2270,7 @@ void Chord::layoutTablature()
// or duration longer than half (if halves have stems) or duration longer than crochet
// remove stems
if (tab->stemless() || _noStem || measure()->stemless(staffIdx()) || durationType().type()
< (tab->minimStyle()
!= TablatureMinimStyle::NONE ? TDuration::DurationType::V_HALF : TDuration::DurationType::V_QUARTER)) {
< (tab->minimStyle() != TablatureMinimStyle::NONE ? TDuration::DurationType::V_HALF : TDuration::DurationType::V_QUARTER)) {
if (_stem) {
score()->undo(new RemoveElement(_stem));
}
Expand Down
4 changes: 2 additions & 2 deletions src/libmscore/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,8 @@ bool ParsedChord::parse(const QString& s, const ChordList* cl, bool syntaxOnly,
// fromXml
//---------------------------------------------------------

QString ParsedChord::fromXml(const QString& rawKind, const QString& rawKindText, const QString& useSymbols,
const QString& useParens, const QList<HDegree>& dl, const ChordList* cl)
QString ParsedChord::fromXml(const QString& rawKind, const QString& rawKindText, const QString& useSymbols, const QString& useParens,
const QList<HDegree>& dl, const ChordList* cl)
{
QString kind = rawKind;
QString kindText = rawKindText;
Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,7 @@ bool ChordRest::isGraceBefore() const
bool ChordRest::isGraceAfter() const
{
return isChord()
&& (toChord(this)->noteType()
& (NoteType::GRACE8_AFTER | NoteType::GRACE16_AFTER | NoteType::GRACE32_AFTER));
&& (toChord(this)->noteType() & (NoteType::GRACE8_AFTER | NoteType::GRACE16_AFTER | NoteType::GRACE32_AFTER));
}

//---------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions src/libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,14 @@ Fraction Score::makeGap(Segment* segment, int track, const Fraction& _sd, Tuplet
accumulated = _sd;
Fraction rd = td - sd;
Fraction tick = cr->tick() + actualTicks(sd, tuplet, timeStretch);
std::vector<TDuration> dList = toRhythmicDurationList(rd, true, tick - measure->tick(), sigmap()->timesig(
tick).nominal(), measure, 0);

std::vector<TDuration> dList;
if (tuplet || staff(track / VOICES)->isLocalTimeSignature(tick)) {
dList = toDurationList(rd, false);
std::reverse(dList.begin(), dList.end());
} else {
dList = toRhythmicDurationList(rd, true, tick - measure->tick(), sigmap()->timesig(tick).nominal(), measure, 0);
}
if (dList.empty()) {
break;
}
Expand Down
54 changes: 30 additions & 24 deletions src/libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,14 @@ Rest* Score::setRest(const Fraction& _tick, int track, const Fraction& _l, bool
//
// compute list of durations which will fit l
//
std::vector<TDuration> dList = toRhythmicDurationList(f, true, tick - measure->tick(), sigmap()->timesig(
tick).nominal(), measure, useDots ? 1 : 0);
std::vector<TDuration> dList;
if (tuplet || staff->isLocalTimeSignature(tick)) {
dList = toDurationList(l, useDots);
std::reverse(dList.begin(), dList.end());
} else {
dList
= toRhythmicDurationList(f, true, tick - measure->tick(), sigmap()->timesig(tick).nominal(), measure, useDots ? 1 : 0);
}
if (dList.empty()) {
return 0;
}
Expand Down Expand Up @@ -876,9 +882,8 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns, int st
if (trem->chord2() == chord) {
continue;
}
auto newP = std::tuple<Fraction, Fraction, Tremolo*, int>(cr->tick(),
trem->chord2()->segment()->tick(), trem,
track);
auto newP
= std::tuple<Fraction, Fraction, Tremolo*, int>(cr->tick(), trem->chord2()->segment()->tick(), trem, track);
tremoloChordTicks.push_back(newP);
}
}
Expand Down Expand Up @@ -1228,22 +1233,22 @@ void Score::cmdAddTimeSig(Measure* fm, int staffIdx, TimeSig* ts, bool local)
if (changeActual) {
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));
if (!nsig) {
continue;
}
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);
}
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) {
continue;
}
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 {
Expand Down Expand Up @@ -1364,7 +1369,9 @@ void Score::cmdRemoveTimeSig(TimeSig* ts)
Score* rScore = masterScore();
Measure* rm = rScore->tick2measure(m->tick());
Segment* rs = rm->findSegment(SegmentType::TimeSig, s->tick());
rScore->undoRemoveElement(rs);
if (rs) {
rScore->undoRemoveElement(rs);
}

Measure* pm = m->prevMeasure();
Fraction ns(pm ? pm->timesig() : Fraction(4,4));
Expand Down Expand Up @@ -5364,7 +5371,7 @@ void Score::undoAddElement(Element* element)
if (ne->isFretDiagram()) {
FretDiagram* fd = toFretDiagram(ne);
Harmony* fdHarmony = fd->harmony();
if (fd) {
if (fdHarmony) {
fdHarmony->setScore(score);
fdHarmony->setSelected(false);
fdHarmony->setTrack(staffIdx * VOICES + element->voice());
Expand Down Expand Up @@ -5442,8 +5449,7 @@ void Score::undoAddElement(Element* element)
|| element->isFermata()
|| element->isHarmony()) {
Segment* segment
= element->parent()->isFretDiagram() ? toSegment(element->parent()->parent()) : toSegment(
element->parent());
= element->parent()->isFretDiagram() ? toSegment(element->parent()->parent()) : toSegment(element->parent());
Fraction tick = segment->tick();
Measure* m = score->tick2measure(tick);
if ((segment->segmentType() == SegmentType::EndBarLine) && (m->tick() == tick)) {
Expand Down
19 changes: 14 additions & 5 deletions src/libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace Ms {

void Element::spatiumChanged(qreal oldValue, qreal newValue)
{
if (sizeIsSpatiumDependent()) {
if (offsetIsSpatiumDependent()) {
_offset *= (newValue / oldValue);
}
}
Expand All @@ -126,7 +126,7 @@ void Element::spatiumChanged(qreal oldValue, qreal newValue)

void Element::localSpatiumChanged(qreal oldValue, qreal newValue)
{
if (sizeIsSpatiumDependent()) {
if (offsetIsSpatiumDependent()) {
_offset *= (newValue / oldValue);
}
}
Expand All @@ -145,6 +145,15 @@ qreal Element::spatium() const
}
}

//---------------------------------------------------------
// offsetIsSpatiumDependent
//---------------------------------------------------------

bool Element::offsetIsSpatiumDependent() const
{
return sizeIsSpatiumDependent() || (_flags & ElementFlag::ON_STAFF);
}

//---------------------------------------------------------
// magS
//---------------------------------------------------------
Expand Down Expand Up @@ -461,8 +470,8 @@ QPointF Element::pagePos() const
}

if (_flags & ElementFlag::ON_STAFF) {
System* system = 0;
Measure* measure = 0;
System* system = nullptr;
Measure* measure = nullptr;
if (parent()->isSegment()) {
measure = toSegment(parent())->measure();
} else if (parent()->isMeasure()) { // used in measure number
Expand Down Expand Up @@ -2286,7 +2295,7 @@ void Element::endEditDrag(EditData& ed)
ElementEditData* eed = ed.getData(this);
bool changed = false;
if (eed) {
for (PropertyData pd : eed->propertyData) {
for (const PropertyData& pd : qAsConst(eed->propertyData)) {
setPropertyFlags(pd.id, pd.f); // reset initial property flags state
if (score()->undoPropertyChanged(this, pd.id, pd.data)) {
changed = true;
Expand Down
1 change: 1 addition & 0 deletions src/libmscore/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class Element : public ScoreElement

virtual bool sizeIsSpatiumDependent() const override { return !flag(ElementFlag::SIZE_SPATIUM_DEPENDENT); }
void setSizeIsSpatiumDependent(bool v) { setFlag(ElementFlag::SIZE_SPATIUM_DEPENDENT, !v); }
virtual bool offsetIsSpatiumDependent() const override;

Placement placement() const { return Placement(!flag(ElementFlag::PLACE_ABOVE)); }
void setPlacement(Placement val) { setFlag(ElementFlag::PLACE_ABOVE, !bool(val)); }
Expand Down
3 changes: 1 addition & 2 deletions src/libmscore/figuredbass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ bool FiguredBassItem::parse(QString& str)
// prefix, digit, suffix and cont.line cannot be ALL empty
// suffix cannot combine with empty digit
if ((_prefix != Modifier::NONE && _suffix != Modifier::NONE)
|| (_prefix == Modifier::NONE && _digit == FBIDigitNone && _suffix == Modifier::NONE
&& _contLine == ContLine::NONE)
|| (_prefix == Modifier::NONE && _digit == FBIDigitNone && _suffix == Modifier::NONE && _contLine == ContLine::NONE)
|| ((_suffix == Modifier::CROSS || _suffix == Modifier::BACKSLASH || _suffix == Modifier::SLASH)
&& _digit == FBIDigitNone)) {
return false;
Expand Down
7 changes: 5 additions & 2 deletions src/libmscore/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,16 @@ void FretDiagram::setDot(int string, int fret, bool add /*= false*/, FretDotType
}

_dots[string].push_back(FretItem::Dot(fret, dtype));
setMarker(string, FretMarkerType::NONE);
if (!add) {
setMarker(string, FretMarkerType::NONE);
}
}
}

//---------------------------------------------------------
// setMarker
// Remove any dots and barres if the marker is being set to anything other than none.
// Removal of dots and barres if "Multiple dots" is inactive
// is handled in FretCanvas::mousePressEvent()
//---------------------------------------------------------

void FretDiagram::setMarker(int string, FretMarkerType mtype)
Expand Down
8 changes: 6 additions & 2 deletions src/libmscore/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,8 @@ const ChordDescription* Harmony::fromXml(const QString& kind)
// then generate chord description from that
//---------------------------------------------------------

const ChordDescription* Harmony::fromXml(const QString& kind, const QString& kindText, const QString& symbols,
const QString& parens, const QList<HDegree>& dl)
const ChordDescription* Harmony::fromXml(const QString& kind, const QString& kindText, const QString& symbols, const QString& parens,
const QList<HDegree>& dl)
{
ParsedChord* pc = new ParsedChord;
_textName = pc->fromXml(kind, kindText, symbols, parens, dl, score()->style().chordList());
Expand Down Expand Up @@ -1546,8 +1546,12 @@ void Harmony::draw(QPainter* painter) const
for (const TextSegment* ts : textList) {
QFont f(ts->font);
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
#ifndef Q_OS_MACOS
TextBase::drawTextWorkaround(painter, f, ts->pos(), ts->text);
#else
painter->setFont(f);
painter->drawText(ts->pos(), ts->text);
#endif
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libmscore/scoreElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void ScoreElement::readProperty(XmlReader& e, Pid id)
v = v.toPointF() * score()->spatium();
break;
case P_TYPE::POINT_SP_MM:
if (sizeIsSpatiumDependent()) {
if (offsetIsSpatiumDependent()) {
v = v.toPointF() * score()->spatium();
} else {
v = v.toPointF() * DPMM;
Expand Down Expand Up @@ -497,7 +497,7 @@ void ScoreElement::writeProperty(XmlWriter& xml, Pid pid) const
return;
}
}
qreal q = sizeIsSpatiumDependent() ? score()->spatium() : DPMM;
qreal q = offsetIsSpatiumDependent() ? score()->spatium() : DPMM;
p = QVariant(p1 / q);
d = QVariant();
}
Expand Down Expand Up @@ -960,7 +960,7 @@ QVariant ScoreElement::styleValue(Pid pid, Sid sid) const
}
case P_TYPE::POINT_SP_MM: {
QPointF val = score()->styleV(sid).toPointF();
if (sizeIsSpatiumDependent()) {
if (offsetIsSpatiumDependent()) {
val *= score()->spatium();
if (isElement()) {
const Element* e = toElement(this);
Expand Down
1 change: 1 addition & 0 deletions src/libmscore/scoreElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class ScoreElement
virtual void resetProperty(Pid id);
QVariant propertyDefault(Pid pid, Tid tid) const;
virtual bool sizeIsSpatiumDependent() const { return true; }
virtual bool offsetIsSpatiumDependent() const { return true; }

virtual void reset(); // reset all properties & position to default

Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void SpannerSegment::setSystem(System* s)
void SpannerSegment::spatiumChanged(qreal ov, qreal nv)
{
Element::spatiumChanged(ov, nv);
if (sizeIsSpatiumDependent()) {
if (offsetIsSpatiumDependent()) {
_offset2 *= (nv / ov);
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,19 @@ void TextFragment::draw(QPainter* p, const TextBase* t) const
QFont f(font(t));
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
#ifndef Q_OS_MACOS
TextBase::drawTextWorkaround(p, f, pos, text);
#else
p->setFont(f);
p->drawText(pos, text);
#endif
}

//---------------------------------------------------------
// drawTextWorkaround
//---------------------------------------------------------

void TextBase::drawTextWorkaround(QPainter* p, QFont& f, const QPointF pos, const QString text)
{
qreal mm = p->worldTransform().m11();
if (!(MScore::pdfPrinting) && (mm < 1.0) && f.bold() && !(f.underline())) {
// workaround for https://musescore.org/en/node/284218
Expand Down Expand Up @@ -973,10 +986,6 @@ void TextFragment::draw(QPainter* p, const TextBase* t) const
p->setFont(f);
p->drawText(pos, text);
}
#else
p->setFont(f);
p->drawText(pos, text);
#endif
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/libmscore/textbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class TextBase : public Element

virtual void draw(QPainter*) const override;
virtual void drawEditMode(QPainter* p, EditData& ed) override;
static void drawTextWorkaround(QPainter* p, QFont& f, const QPointF pos, const QString text);

static QString plainToXmlText(const QString& s) { return s.toHtmlEscaped(); }
void setPlainText(const QString& t) { setXmlText(plainToXmlText(t)); }
Expand Down

0 comments on commit 9fc9146

Please sign in to comment.