Skip to content

Commit

Permalink
Eliminate (the need for) #undef small and #undef STRING_NONE
Browse files Browse the repository at this point in the history
as it was needed for MSVC, which uses these in some headers, so they
conflict with MuseScore's functions, variables, marcos.

Partial backport of musescore#8765
  • Loading branch information
cbjeukendrup authored and Jojo-Schmitz committed Sep 29, 2021
1 parent 765242b commit 0f1992d
Show file tree
Hide file tree
Showing 45 changed files with 161 additions and 164 deletions.
6 changes: 0 additions & 6 deletions all.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,6 @@
#define Q_ASSERT(a)
#endif

#if (defined (_MSCVER) || defined (_MSC_VER))
// Undefined problematic #def'd macros in Microsoft headers
#undef STRING_NONE
#undef small
#endif

#endif // __cplusplus

#endif
Expand Down
4 changes: 2 additions & 2 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ static int tremoloCorrection(const Note* const note)

static bool isSmallNote(const Note* const note)
{
return note->small() || note->chord()->small();
return note->isSmall() || note->chord()->isSmall();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -3601,7 +3601,7 @@ void ExportMusicXml::rest(Rest* rest, int staff, const std::vector<Lyrics*>* ll)
if (d.type() != TDuration::DurationType::V_MEASURE) {
QString s = d.name();
int dots = rest->dots();
if (rest->small())
if (rest->isSmall())
_xml.tag("type size=\"cue\"", s);
else
_xml.tag("type", s);
Expand Down
26 changes: 13 additions & 13 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ static void markUserAccidentals(const int firstStaff,

static void coerceGraceCue(Chord* mainChord, Chord* graceChord)
{
if (mainChord->small())
if (mainChord->isSmall())
graceChord->setSmall(true);
bool anyPlays = false;
for (auto n : mainChord->notes()) {
Expand Down Expand Up @@ -4949,7 +4949,7 @@ static TDuration determineDuration(const bool rest, const QString& type, const i
static Chord* findOrCreateChord(Score* score, Measure* m,
const Fraction& tick, const int track, const int move,
const TDuration duration, const Fraction dura,
Beam::Mode bm, bool small)
Beam::Mode bm, bool isSmall)
{
//qDebug("findOrCreateChord tick %d track %d dur ticks %d ticks %s bm %hhd",
// tick, track, duration.ticks(), qPrintable(dura.print()), bm);
Expand All @@ -4965,7 +4965,7 @@ static Chord* findOrCreateChord(Score* score, Measure* m,
c->setTrack(track);
// Chord is initialized with the smallness of its first note.
// If a non-small note is added later, this is handled in handleSmallness.
c->setSmall(small);
c->setSmall(isSmall);

setChordRestDuration(c, duration, dura);
Segment* s = m->getSegment(SegmentType::ChordRest, tick);
Expand Down Expand Up @@ -5009,14 +5009,14 @@ NoteType graceNoteType(const TDuration duration, const bool slash)
*/

static Chord* createGraceChord(Score* score, const int track,
const TDuration duration, const bool slash, const bool small)
const TDuration duration, const bool slash, const bool isSmall)
{
Chord* c = new Chord(score);
c->setNoteType(graceNoteType(duration, slash));
c->setTrack(track);
// Chord is initialized with the smallness of its first note.
// If a non-small note is added later, this is handled in handleSmallness.
c->setSmall(small);
c->setSmall(isSmall);
// note grace notes have no durations, use default fraction 0/1
setChordRestDuration(c, duration, Fraction());
return c;
Expand Down Expand Up @@ -5058,11 +5058,11 @@ static void handleDisplayStep(ChordRest* cr, int step, int octave, const Fractio
static void handleSmallness(bool cueOrSmall, Note* note, Chord* c)
{
if (cueOrSmall) {
note->setSmall(!c->small()); // Avoid redundant smallness
note->setSmall(!c->isSmall()); // Avoid redundant smallness
}
else {
note->setSmall(false);
if (c->small()) {
if (c->isSmall()) {
// What was a small chord becomes small notes in a non-small chord
c->setSmall(false);
for (Note* otherNote : c->notes()) {
Expand Down Expand Up @@ -5329,7 +5329,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,

bool chord = false;
bool cue = false;
bool small = false;
bool isSmall = false;
bool grace = false;
bool rest = false;
int staff = 1;
Expand Down Expand Up @@ -5416,7 +5416,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
else if (_e.name() == "stem")
stem(stemDir, noStem);
else if (_e.name() == "type") {
small = (_e.attributes().value("size") == "cue" || _e.attributes().value("size") == "grace-cue");
isSmall = (_e.attributes().value("size") == "cue" || _e.attributes().value("size") == "grace-cue");
type = _e.readElementText();
}
else if (_e.name() == "voice")
Expand Down Expand Up @@ -5521,14 +5521,14 @@ Note* MusicXMLParserPass2::note(const QString& partId,
c = findOrCreateChord(_score, measure,
noteStartTime,
msTrack + msVoice, msMove,
duration, dura, bm, small || cue);
duration, dura, bm, isSmall || cue);
}
else {
// grace note
// TODO: check if explicit stem direction should also be set for grace notes
// (the DOM parser does that, but seems to have no effect on the autotester)
if (!chord || gcl.isEmpty()) {
c = createGraceChord(_score, msTrack + msVoice, duration, graceSlash, small || cue);
c = createGraceChord(_score, msTrack + msVoice, duration, graceSlash, isSmall || cue);
// TODO FIX
// the setStaffMove() below results in identical behaviour as 2.0:
// grace note will be at the wrong staff with the wrong pitch,
Expand Down Expand Up @@ -5570,15 +5570,15 @@ Note* MusicXMLParserPass2::note(const QString& partId,
}
else
cr->setBeamMode(Beam::Mode::NONE);
cr->setSmall(small);
cr->setSmall(isSmall);
if (noteColor != QColor::Invalid)
cr->setColor(noteColor);
cr->setVisible(printObject);
handleDisplayStep(cr, mnp.displayStep(), mnp.displayOctave(), noteStartTime, _score->spatium());
}
}
else {
handleSmallness(cue || small, note, c);
handleSmallness(cue || isSmall, note, c);
note->setPlay(!cue); // cue notes don't play
note->setHeadGroup(headGroup);
if (noteColor != QColor::Invalid)
Expand Down
8 changes: 4 additions & 4 deletions libmscore/accidental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void Accidental::read(XmlReader& e)
_role = r;
}
else if (tag == "small")
_small = e.readInt();
m_isSmall = e.readInt();
else if (Element::readProperties(e))
;
else
Expand Down Expand Up @@ -365,7 +365,7 @@ void Accidental::layout()
}

qreal m = parent() ? parent()->mag() : 1.0;
if (_small)
if (m_isSmall)
m *= score()->styleD(Sid::smallNoteMag);
setMag(m);

Expand Down Expand Up @@ -572,7 +572,7 @@ QVariant Accidental::getProperty(Pid propertyId) const
{
switch (propertyId) {
case Pid::ACCIDENTAL_TYPE: return int(_accidentalType);
case Pid::SMALL: return _small;
case Pid::SMALL: return m_isSmall;
case Pid::ACCIDENTAL_BRACKET: return int(bracket());
case Pid::ROLE: return int(role());
default:
Expand Down Expand Up @@ -607,7 +607,7 @@ bool Accidental::setProperty(Pid propertyId, const QVariant& v)
setAccidentalType(AccidentalType(v.toInt()));
break;
case Pid::SMALL:
_small = v.toBool();
m_isSmall = v.toBool();
break;
case Pid::ACCIDENTAL_BRACKET:
_bracket = AccidentalBracket(v.toInt());
Expand Down
8 changes: 4 additions & 4 deletions libmscore/accidental.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ struct SymElement {
//---------------------------------------------------------
// @@ Accidental
// @P role enum (Accidental.AUTO, .USER) (read only)
// @P small bool
// @P isSmall bool
//---------------------------------------------------------

class Accidental final : public Element {
QList<SymElement> el;
AccidentalType _accidentalType { AccidentalType::NONE };
bool _small { false };
bool m_isSmall { false };
AccidentalBracket _bracket { AccidentalBracket::NONE };
AccidentalRole _role { AccidentalRole::AUTO };

Expand Down Expand Up @@ -108,8 +108,8 @@ class Accidental final : public Element {

void setRole(AccidentalRole r) { _role = r; }

bool small() const { return _small; }
void setSmall(bool val) { _small = val; }
bool isSmall() const { return m_isSmall; }
void setSmall(bool val) { m_isSmall = val; }

void undoSetSmall(bool val);

Expand Down
10 changes: 5 additions & 5 deletions libmscore/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void Beam::layout1()

int staffIdx = -1;
for (ChordRest* cr : qAsConst(_elements)) {
qreal m = cr->small() ? score()->styleD(Sid::smallNoteMag) : 1.0;
qreal m = cr->isSmall() ? score()->styleD(Sid::smallNoteMag) : 1.0;
mag = qMax(mag, m);
if (cr->isChord()) {
c2 = toChord(cr);
Expand Down Expand Up @@ -1503,11 +1503,11 @@ void Beam::computeStemLen(const std::vector<ChordRest*>& cl, qreal& py1, int bea
qreal firstStemLenPoints = bm.l * _spStaff4;
const qreal sgn = (firstStemLenPoints < 0 ? -1.0 : 1.0);
const QPointF p1 = cl[0]->stemPosBeam();
bool small = true;
bool isSmall = true;
for (const ChordRest* cr : cl) {
if (cr->isChord()) {
if (!cr->small())
small = false;
if (!cr->isSmall())
isSmall = false;

const qreal minAbsLen = toChord(cr)->minAbsStemLength();

Expand All @@ -1524,7 +1524,7 @@ void Beam::computeStemLen(const std::vector<ChordRest*>& cl, qreal& py1, int bea
}

py1 += (dy + bm.l) * _spStaff4;
if (small && !staff()->isTabStaff(Fraction(0,1))) {
if (isSmall && !staff()->isTabStaff(Fraction(0,1))) {
const qreal offset = (beamLevels == 4) ? _beamDist/2.0 : 0.0;

if (bm.l > 0)
Expand Down
34 changes: 17 additions & 17 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,49 +1275,49 @@ void Chord::setScore(Score* s)
// Adjustment to the length of the stem in order to accommodate hooks
// This function replaces this bit of code:
// switch (hookIdx) {
// case 3: normalStemLen += small() ? .5 : 0.75; break; //32nd notes
// case 4: normalStemLen += small() ? 1.0 : 1.5; break; //64th notes
// case 5: normalStemLen += small() ? 1.5 : 2.25; break; //128th notes
// case 3: normalStemLen += isSmall() ? .5 : 0.75; break; //32nd notes
// case 4: normalStemLen += isSmall() ? 1.0 : 1.5; break; //64th notes
// case 5: normalStemLen += isSmall() ? 1.5 : 2.25; break; //128th notes
// }
// which was not sufficient for two reasons:
// 1. It only lengthened the stem for 3, 4, or 5 hooks.
// 2. It was too general to produce good results for all combinations of factors.
// This provides a way to take a number of factors into account. Further tweaking may be in order.
//-----------------------------------------------------------------------------

qreal hookAdjustment(QString font, int hooks, bool up, bool small)
qreal hookAdjustment(QString font, int hooks, bool up, bool isSmall)
{
bool fallback = MScore::useFallbackFont && (hooks > 5);

if (font == "Emmentaler" && !fallback) {
if (up) {
if (hooks > 2)
return (hooks - 2) * (small ? .75 : 1);
return (hooks - 2) * (isSmall ? .75 : 1);
}
else {
if (hooks == 3)
return (small ? .75 : 1);
return (isSmall ? .75 : 1);
else if (hooks > 3)
return (hooks - 2) * (small ? .5 : .75);
return (hooks - 2) * (isSmall ? .5 : .75);
}
}
else if (font == "Gonville" && !fallback) {
if (up) {
if (hooks > 2)
return (hooks - 2) * (small ? .5 : .75);
return (hooks - 2) * (isSmall ? .5 : .75);
}
else {
if (hooks > 1)
return (hooks - 1) * (small ? .5 : .75);
return (hooks - 1) * (isSmall ? .5 : .75);
}
}
else if (font == "MuseJazz") {
if (hooks > 2)
return (hooks - 2) * (small ? .75 : 1);
return (hooks - 2) * (isSmall ? .75 : 1);
}
else {
if (hooks > 2)
return (hooks - 2) * (small ? .5 : .75);
return (hooks - 2) * (isSmall ? .5 : .75);
}
return 0;
}
Expand Down Expand Up @@ -1369,12 +1369,12 @@ qreal Chord::defaultStemLength() const
qreal shortest = score()->styleS(Sid::shortestStem).val();
if (hookIdx) {
if (up())
shortest = qMax(shortest, small() ? 2.0 : 3.0);
shortest = qMax(shortest, isSmall() ? 2.0 : 3.0);
else
shortest = qMax(shortest, small() ? 2.25 : 3.5);
shortest = qMax(shortest, isSmall() ? 2.25 : 3.5);
}

qreal normalStemLen = small() ? 2.5 : 3.5;
qreal normalStemLen = isSmall() ? 2.5 : 3.5;
if (hookIdx && tab == 0) {
if (up() && durationType().dots()) {
//
Expand Down Expand Up @@ -2769,7 +2769,7 @@ QVariant Chord::getProperty(Pid propertyId) const
{
switch (propertyId) {
case Pid::NO_STEM: return noStem();
case Pid::SMALL: return small();
case Pid::SMALL: return isSmall();
case Pid::STEM_DIRECTION: return QVariant::fromValue<Direction>(stemDirection());
default:
return ChordRest::getProperty(propertyId);
Expand Down Expand Up @@ -2982,7 +2982,7 @@ void Chord::removeMarkings(bool keepTremolo)
qreal Chord::chordMag() const
{
qreal m = 1.0;
if (small())
if (isSmall())
m *= score()->styleD(Sid::smallNoteMag);
if (_noteType != NoteType::NORMAL)
m *= score()->styleD(Sid::graceNoteMag);
Expand Down Expand Up @@ -3445,7 +3445,7 @@ void Chord::layoutArticulations()
return;
const Staff* st = staff();
const StaffType* staffType = st->staffTypeForElement(this);
qreal mag = (staffType->small() ? score()->styleD(Sid::smallStaffMag) : 1.0) * staffType->userMag();
qreal mag = (staffType->isSmall() ? score()->styleD(Sid::smallStaffMag) : 1.0) * staffType->userMag();
qreal _spatium = score()->spatium() * mag;
qreal _spStaff = _spatium * staffType->lineDistance().val();

Expand Down
10 changes: 5 additions & 5 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ChordRest::ChordRest(Score* s)
_tabDur = 0;
_up = true;
_beamMode = Beam::Mode::AUTO;
_small = false;
m_isSmall = false;
_crossMeasure = CrossMeasure::UNKNOWN;
}

Expand All @@ -78,7 +78,7 @@ ChordRest::ChordRest(const ChordRest& cr, bool link)

_beamMode = cr._beamMode;
_up = cr._up;
_small = cr._small;
m_isSmall = cr.m_isSmall;
_melismaEnds = cr._melismaEnds;
_crossMeasure = cr._crossMeasure;

Expand Down Expand Up @@ -268,7 +268,7 @@ bool ChordRest::readProperties(XmlReader& e)
e.skipCurrentElement();
}
else if (tag == "small")
_small = e.readInt();
m_isSmall = e.readInt();
else if (tag == "duration")
setTicks(e.readFraction());
else if (tag == "ticklen") { // obsolete (version < 1.12)
Expand Down Expand Up @@ -387,7 +387,7 @@ void ChordRest::readAddConnector(ConnectorInfoReader* info, bool pasteMode)

void ChordRest::setSmall(bool val)
{
_small = val;
m_isSmall = val;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -845,7 +845,7 @@ void ChordRest::localSpatiumChanged(qreal oldValue, qreal newValue)
QVariant ChordRest::getProperty(Pid propertyId) const
{
switch (propertyId) {
case Pid::SMALL: return QVariant(small());
case Pid::SMALL: return QVariant(isSmall());
case Pid::BEAM_MODE: return int(beamMode());
case Pid::STAFF_MOVE: return staffMove();
case Pid::DURATION_TYPE: return QVariant::fromValue(actualDurationType());
Expand Down
Loading

0 comments on commit 0f1992d

Please sign in to comment.