Fixed naming conflict regarding STRING_NONE
Also added some constexpr and updated a license header.
This commit is contained in:
parent
2a7f778ea3
commit
78736658db
13 changed files with 86 additions and 75 deletions
|
@ -1,21 +1,24 @@
|
|||
//=============================================================================
|
||||
// MusE
|
||||
// Linux Music Editor
|
||||
//
|
||||
// Copyright (C) 2002-2010 by Werner Schweer and others
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//=============================================================================
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
* MuseScore-CLA-applies
|
||||
*
|
||||
* MuseScore
|
||||
* Music Composition & Notation
|
||||
*
|
||||
* Copyright (C) 2021 MuseScore BVBA and others
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MUSESCORE_CONFIG_H
|
||||
#define MUSESCORE_CONFIG_H
|
||||
|
|
|
@ -3344,7 +3344,7 @@ void Score::cmdSlashFill()
|
|||
p.segment = s;
|
||||
p.staffIdx = staffIdx;
|
||||
p.line = line;
|
||||
p.fret = FRET_NONE;
|
||||
p.fret = INVALID_FRET_INDEX;
|
||||
_is.setRest(false); // needed for tab
|
||||
nv = noteValForPosition(p, AccidentalType::NONE, error);
|
||||
}
|
||||
|
|
|
@ -52,21 +52,27 @@ enum class NoteEntryMethod : char {
|
|||
|
||||
class InputState
|
||||
{
|
||||
TDuration _duration { TDuration::DurationType::V_INVALID }; // currently duration
|
||||
int _drumNote { -1 };
|
||||
int _track { 0 };
|
||||
int _prevTrack { 0 }; // used for navigation
|
||||
Segment* _lastSegment { 0 };
|
||||
Segment* _segment { 0 }; // current segment
|
||||
int _string { VISUAL_STRING_NONE }; // visual string selected for input (TAB staves only)
|
||||
bool _rest { false }; // rest mode
|
||||
NoteType _noteType { NoteType::NORMAL };
|
||||
Beam::Mode _beamMode { Beam::Mode::AUTO };
|
||||
bool _noteEntryMode { false };
|
||||
int _track { 0 };
|
||||
int _prevTrack { 0 }; // used for navigation
|
||||
|
||||
int _drumNote { -1 };
|
||||
int _string { VISUAL_INVALID_STRING_INDEX }; // visual string selected for input (TAB staves only)
|
||||
|
||||
Segment* _lastSegment = nullptr;
|
||||
Segment* _segment = nullptr; // current segment
|
||||
|
||||
bool _noteEntryMode { false };
|
||||
NoteEntryMethod _noteEntryMethod { NoteEntryMethod::STEPTIME };
|
||||
|
||||
TDuration _duration { TDuration::DurationType::V_INVALID }; // currently duration
|
||||
bool _rest { false }; // rest mode
|
||||
|
||||
NoteType _noteType { NoteType::NORMAL };
|
||||
Beam::Mode _beamMode { Beam::Mode::AUTO };
|
||||
|
||||
AccidentalType _accidentalType { AccidentalType::NONE };
|
||||
Slur* _slur { 0 };
|
||||
bool _insertMode { false };
|
||||
Slur* _slur = nullptr;
|
||||
bool _insertMode { false };
|
||||
|
||||
std::set<SymId> _articulationIds;
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
#ifndef __MSCORE_H__
|
||||
#define __MSCORE_H__
|
||||
|
||||
#include "draw/color.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "draw/color.h"
|
||||
#include "style/style.h"
|
||||
|
||||
namespace Ms {
|
||||
|
@ -89,51 +90,52 @@ enum class HairpinType : signed char;
|
|||
|
||||
static constexpr int INVALID_INDEX = -1;
|
||||
|
||||
inline int staff2track(int staffIdx, int voiceIdx = 0)
|
||||
inline constexpr int staff2track(int staffIdx, int voiceIdx = 0)
|
||||
{
|
||||
return staffIdx >= 0 ? staffIdx * VOICES + voiceIdx : INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int track2staff(int track)
|
||||
inline constexpr int track2staff(int track)
|
||||
{
|
||||
return track >= 0 ? track / VOICES : INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int track2voice(int track)
|
||||
inline constexpr int track2voice(int track)
|
||||
{
|
||||
return track >= 0 ? track % VOICES : INVALID_INDEX;
|
||||
}
|
||||
|
||||
inline int trackZeroVoice(int track)
|
||||
inline constexpr int trackZeroVoice(int track)
|
||||
{
|
||||
return track >= 0 ? (track / VOICES) * VOICES : INVALID_INDEX;
|
||||
}
|
||||
|
||||
static const int MAX_TAGS = 32;
|
||||
static constexpr int MAX_TAGS = 32;
|
||||
|
||||
static const int MAX_HEADERS = 3;
|
||||
static const int MAX_FOOTERS = 3;
|
||||
static constexpr int MAX_HEADERS = 3;
|
||||
static constexpr int MAX_FOOTERS = 3;
|
||||
|
||||
static constexpr qreal INCH = 25.4;
|
||||
static constexpr qreal PPI = 72.0; // printer points per inch
|
||||
static constexpr qreal PPI = 72.0; // printer points per inch
|
||||
static constexpr qreal DPI_F = 5;
|
||||
static constexpr qreal DPI = 72.0 * DPI_F;
|
||||
static constexpr qreal SPATIUM20 = 5.0 * (DPI / 72.0);
|
||||
static constexpr qreal DPMM = DPI / INCH;
|
||||
|
||||
static constexpr int MAX_STAVES = 4;
|
||||
static constexpr int MAX_STAVES = 4;
|
||||
|
||||
static const int SHADOW_NOTE_LIGHT = 135;
|
||||
static constexpr int SHADOW_NOTE_LIGHT = 135;
|
||||
|
||||
static const char mimeSymbolFormat[] = "application/musescore/symbol";
|
||||
static const char mimeSymbolListFormat[] = "application/musescore/symbollist";
|
||||
static const char mimeStaffListFormat[] = "application/musescore/stafflist";
|
||||
static constexpr char mimeSymbolFormat[] = "application/musescore/symbol";
|
||||
static constexpr char mimeSymbolListFormat[] = "application/musescore/symbollist";
|
||||
static constexpr char mimeStaffListFormat[] = "application/musescore/stafflist";
|
||||
|
||||
static const int VISUAL_STRING_NONE = -100; // no ordinal for the visual repres. of string (topmost in TAB
|
||||
// varies according to visual order and presence of bass strings)
|
||||
#undef STRING_NONE
|
||||
static const int STRING_NONE = -1; // no ordinal for a physical string (0 = topmost in instrument)
|
||||
static const int FRET_NONE = -1; // no ordinal for a fret
|
||||
static constexpr int INVALID_STRING_INDEX = -1; // no ordinal for a physical string (0 = topmost in instrument)
|
||||
static constexpr int INVALID_FRET_INDEX = -1; // no ordinal for a fret
|
||||
|
||||
// no ordinal for the visual repres. of string
|
||||
// (topmost in TAB varies according to visual order and presence of bass strings)
|
||||
static constexpr int VISUAL_INVALID_STRING_INDEX = -100;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// BracketType
|
||||
|
|
|
@ -1135,7 +1135,7 @@ qreal Note::noteheadCenterX() const
|
|||
qreal Note::tabHeadWidth(const StaffType* tab) const
|
||||
{
|
||||
qreal val;
|
||||
if (tab && _fret != FRET_NONE && _string != STRING_NONE) {
|
||||
if (tab && _fret != INVALID_FRET_INDEX && _string != INVALID_STRING_INDEX) {
|
||||
mu::draw::Font f = tab->fretFont();
|
||||
f.setPointSizeF(tab->fretFontSize());
|
||||
val = mu::draw::FontMetrics::width(f, _fretString) * magS();
|
||||
|
@ -1163,7 +1163,7 @@ qreal Note::headHeight() const
|
|||
|
||||
qreal Note::tabHeadHeight(const StaffType* tab) const
|
||||
{
|
||||
if (tab && _fret != FRET_NONE && _string != STRING_NONE) {
|
||||
if (tab && _fret != INVALID_FRET_INDEX && _string != INVALID_STRING_INDEX) {
|
||||
return tab->fretBoxH() * magS();
|
||||
}
|
||||
return headHeight();
|
||||
|
|
|
@ -200,8 +200,8 @@ struct NoteVal {
|
|||
int pitch { -1 };
|
||||
int tpc1 { Tpc::TPC_INVALID };
|
||||
int tpc2 { Tpc::TPC_INVALID };
|
||||
int fret { FRET_NONE };
|
||||
int string { STRING_NONE };
|
||||
int fret { INVALID_FRET_INDEX };
|
||||
int string { INVALID_STRING_INDEX };
|
||||
NoteHead::Group headGroup { NoteHead::Group::HEAD_NORMAL };
|
||||
|
||||
NoteVal() {}
|
||||
|
|
|
@ -101,7 +101,7 @@ NoteVal Score::noteValForPosition(Position pos, AccidentalType at, bool& error)
|
|||
}
|
||||
// build a default NoteVal for that string
|
||||
nval.string = line;
|
||||
if (pos.fret != FRET_NONE) { // if a fret is given, use it
|
||||
if (pos.fret != INVALID_FRET_INDEX) { // if a fret is given, use it
|
||||
nval.fret = pos.fret;
|
||||
} else { // if no fret, use 0 as default
|
||||
_is.setString(line);
|
||||
|
|
|
@ -1208,7 +1208,7 @@ bool Score::getPosition(Position* pos, const PointF& p, int voice) const
|
|||
return false;
|
||||
}
|
||||
|
||||
pos->fret = FRET_NONE;
|
||||
pos->fret = INVALID_FRET_INDEX;
|
||||
//
|
||||
// search staff
|
||||
//
|
||||
|
@ -3536,7 +3536,7 @@ void Score::collectNoteMatch(void* data, Element* e)
|
|||
if (p->pitch != -1 && p->pitch != n->pitch()) {
|
||||
return;
|
||||
}
|
||||
if (p->string != STRING_NONE && p->string != n->string()) {
|
||||
if (p->string != INVALID_STRING_INDEX && p->string != n->string()) {
|
||||
return;
|
||||
}
|
||||
if (p->tpc != Tpc::TPC_INVALID && p->tpc != n->tpc()) {
|
||||
|
|
|
@ -247,7 +247,7 @@ struct Position {
|
|||
Segment* segment { 0 };
|
||||
int staffIdx { -1 };
|
||||
int line { 0 };
|
||||
int fret { FRET_NONE };
|
||||
int fret { INVALID_FRET_INDEX };
|
||||
mu::PointF pos;
|
||||
};
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ struct ElementPattern {
|
|||
struct NotePattern {
|
||||
QList<Note*> el;
|
||||
int pitch = -1;
|
||||
int string = STRING_NONE;
|
||||
int string = INVALID_STRING_INDEX;
|
||||
int tpc = Tpc::TPC_INVALID;
|
||||
NoteHead::Group notehead = NoteHead::Group::HEAD_INVALID;
|
||||
TDuration durationType = TDuration();
|
||||
|
|
|
@ -685,7 +685,7 @@ static const QString unknownFret = QString("?");
|
|||
|
||||
QString StaffType::fretString(int fret, int string, bool ghost) const
|
||||
{
|
||||
if (fret == FRET_NONE) {
|
||||
if (fret == INVALID_FRET_INDEX) {
|
||||
return unknownFret;
|
||||
}
|
||||
if (ghost) {
|
||||
|
|
|
@ -149,7 +149,7 @@ int StringData::getPitch(int string, int fret, Staff* staff, const Fraction& tic
|
|||
// fret
|
||||
// Returns the fret corresponding to the pitch / string combination
|
||||
// at given tick of given staff.
|
||||
// Returns FRET_NONE if not possible
|
||||
// Returns INVALID_FRET_INDEX if not possible
|
||||
//---------------------------------------------------------
|
||||
|
||||
int StringData::fret(int pitch, int string, Staff* staff, const Fraction& tick) const
|
||||
|
@ -217,13 +217,13 @@ void StringData::fretChords(Chord* chord) const
|
|||
minFret = INT32_MAX;
|
||||
maxFret = INT32_MIN;
|
||||
foreach (Note* note, sortedNotes) {
|
||||
if (note->string() != STRING_NONE) {
|
||||
if (note->string() != INVALID_STRING_INDEX) {
|
||||
bUsed[note->string()]++;
|
||||
}
|
||||
if (note->fret() != FRET_NONE && note->fret() < minFret) {
|
||||
if (note->fret() != INVALID_FRET_INDEX && note->fret() < minFret) {
|
||||
minFret = note->fret();
|
||||
}
|
||||
if (note->fret() != FRET_NONE && note->fret() > maxFret) {
|
||||
if (note->fret() != INVALID_FRET_INDEX && note->fret() > maxFret) {
|
||||
maxFret = note->fret();
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ void StringData::fretChords(Chord* chord) const
|
|||
nFret = nNewFret = note->fret();
|
||||
note->setFretConflict(false); // assume no conflicts on this note
|
||||
// if no fretting (any invalid fretting has been erased by sortChordNotes() )
|
||||
if (nString == STRING_NONE /*|| nFret == FRET_NONE || getPitch(nString, nFret) != note->pitch()*/) {
|
||||
if (nString == INVALID_STRING_INDEX /*|| nFret == INVALID_FRET_INDEX || getPitch(nString, nFret) != note->pitch()*/) {
|
||||
// get a new fretting
|
||||
if (!convertPitch(note->pitch(), pitchOffset, &nNewString, &nNewFret)) {
|
||||
// no way to fit this note in this tab:
|
||||
|
@ -260,7 +260,7 @@ void StringData::fretChords(Chord* chord) const
|
|||
// attempt to find a suitable string, from topmost
|
||||
for (nTempString=0; nTempString < strings(); nTempString++) {
|
||||
if (bUsed[nTempString] < 1
|
||||
&& (nTempFret=fret(note->pitch(), nTempString, pitchOffset)) != FRET_NONE) {
|
||||
&& (nTempFret=fret(note->pitch(), nTempString, pitchOffset)) != INVALID_FRET_INDEX) {
|
||||
bUsed[nNewString]--; // free previous string
|
||||
bUsed[nTempString]++; // and occupy new string
|
||||
nNewFret = nTempFret;
|
||||
|
@ -420,18 +420,18 @@ int StringData::getPitch(int string, int fret, int pitchOffset) const
|
|||
//---------------------------------------------------------
|
||||
// fret
|
||||
// Returns the fret corresponding to the pitch / string / pitchOffset combination.
|
||||
// returns FRET_NONE if not possible
|
||||
// returns INVALID_FRET_INDEX if not possible
|
||||
//---------------------------------------------------------
|
||||
|
||||
int StringData::fret(int pitch, int string, int pitchOffset) const
|
||||
{
|
||||
int strings = stringTable.size();
|
||||
if (strings < 1) { // no strings at all!
|
||||
return FRET_NONE;
|
||||
return INVALID_FRET_INDEX;
|
||||
}
|
||||
|
||||
if (string < 0 || string >= strings) { // no such a string
|
||||
return FRET_NONE;
|
||||
return INVALID_FRET_INDEX;
|
||||
}
|
||||
|
||||
pitch += pitchOffset;
|
||||
|
@ -444,7 +444,7 @@ int StringData::fret(int pitch, int string, int pitchOffset) const
|
|||
|
||||
// fret number is invalid or string cannot be fretted
|
||||
if (fret < 0 || fret >= _frets || (fret > 0 && strg.open)) {
|
||||
return FRET_NONE;
|
||||
return INVALID_FRET_INDEX;
|
||||
}
|
||||
return fret;
|
||||
}
|
||||
|
@ -469,10 +469,10 @@ void StringData::sortChordNotes(QMap<int, Note*>& sortedNotes, const Chord* chor
|
|||
fret = note->fret();
|
||||
// if note not fretted yet or current fretting no longer valid,
|
||||
// use most convenient string as key
|
||||
if (string <= STRING_NONE || fret <= FRET_NONE
|
||||
if (string <= INVALID_STRING_INDEX || fret <= INVALID_FRET_INDEX
|
||||
|| getPitch(string, fret, pitchOffset) != note->pitch()) {
|
||||
note->setString(STRING_NONE);
|
||||
note->setFret(FRET_NONE);
|
||||
note->setString(INVALID_STRING_INDEX);
|
||||
note->setFret(INVALID_FRET_INDEX);
|
||||
convertPitch(note->pitch(), pitchOffset, &string, &fret);
|
||||
}
|
||||
key = string * 100000;
|
||||
|
|
|
@ -507,7 +507,7 @@ struct FilterElementsOptions
|
|||
struct FilterNotesOptions : FilterElementsOptions
|
||||
{
|
||||
int pitch = -1;
|
||||
int string = Ms::STRING_NONE;
|
||||
int string = Ms::INVALID_STRING_INDEX;
|
||||
int tpc = Ms::Tpc::TPC_INVALID;
|
||||
NoteHead::Group notehead = NoteHead::Group::HEAD_INVALID;
|
||||
Ms::TDuration durationType = Ms::TDuration();
|
||||
|
|
Loading…
Reference in a new issue