From a345f393b4862895c350ec6a4305b2626e637bef Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Sat, 8 Sep 2012 11:33:46 +0200 Subject: [PATCH] Sym() cleanup; use Sym names in TextLine() --- libmscore/dynamic.cpp | 4 +- libmscore/mscore.cpp | 7 +- libmscore/mscore.h | 5 +- libmscore/note.cpp | 36 ++--- libmscore/note.h | 2 +- libmscore/pedal.cpp | 2 +- libmscore/sym.cpp | 267 ++++++++++++-------------------------- libmscore/sym.h | 113 +++++++++------- libmscore/symbol.cpp | 22 +--- libmscore/symbol.h | 9 +- libmscore/textline.cpp | 18 +-- libmscore/textline.h | 14 +- mscore/exportly.cpp | 4 +- mscore/exportxml.cpp | 6 +- mscore/lineproperties.cpp | 12 +- mscore/menus.cpp | 8 +- mscore/palette.cpp | 4 +- mscore/palette.h | 3 +- mscore/symboldialog.cpp | 2 +- 19 files changed, 221 insertions(+), 317 deletions(-) diff --git a/libmscore/dynamic.cpp b/libmscore/dynamic.cpp index 523e4a5d304c8..4cda63f72d026 100644 --- a/libmscore/dynamic.cpp +++ b/libmscore/dynamic.cpp @@ -154,13 +154,13 @@ void Dynamic::setSubtype(const QString& tag) for (int i = 1; i < n; ++i) { if (dynList[i].tag == tag) { _subtype = i; -// setTextStyleType(TEXT_STYLE_DYNAMICS2); + setTextStyleType(TEXT_STYLE_DYNAMICS2); setText(dynList[i].tag); return; } } _subtype = 0; -// setTextStyleType(TEXT_STYLE_DYNAMICS); + setTextStyleType(TEXT_STYLE_DYNAMICS); setText(tag); } diff --git a/libmscore/mscore.cpp b/libmscore/mscore.cpp index a3ca6aaee8dd5..5c7486b5c316e 100644 --- a/libmscore/mscore.cpp +++ b/libmscore/mscore.cpp @@ -61,6 +61,8 @@ extern void initDrumset(); void MScore::init() { + Sym::init(); + #ifdef SCRIPT_INTERFACE qRegisterMetaType("ElementType"); qRegisterMetaType("ValueType"); @@ -133,12 +135,7 @@ void MScore::init() "FreeSerifMscore.ttf", "FreeSerifBold.ttf", "gonville-20.otf", -// "mscore_tab_baroque.ttf", -// "mscore_tab_modern.ttf", -// "mscore_tab_renaiss.ttf", -// "mscore_tab_renaiss2.ttf", "mscoreTab.ttf", -// "FiguredBassMHGPL.otf", "mscore-BC.ttf" }; diff --git a/libmscore/mscore.h b/libmscore/mscore.h index 2f6a6130a0bfa..12eb85f29aaa1 100644 --- a/libmscore/mscore.h +++ b/libmscore/mscore.h @@ -14,8 +14,8 @@ #ifndef __MSCORE_H__ #define __MSCORE_H__ -#define MSC_VERSION "1.24" -static const int MSCVERSION = 124; +#define MSC_VERSION "1.25" +static const int MSCVERSION = 125; // History: // 1.3 added staff->_barLineSpan @@ -42,6 +42,7 @@ static const int MSCVERSION = 124; // 1.22 timesig changed // 1.23 measure property for actual length // 1.24 default image size is spatium dependent +// 1.25 symbol numbers in TextLine() replaced by symbol names class MStyle; diff --git a/libmscore/note.cpp b/libmscore/note.cpp index 9aa26d5f97c33..794b1e4e231df 100644 --- a/libmscore/note.cpp +++ b/libmscore/note.cpp @@ -59,21 +59,21 @@ // note head groups //--------------------------------------------------------- -const int noteHeads[2][Note::HEAD_GROUPS][HEAD_TYPES] = { +const SymId noteHeads[2][Note::HEAD_GROUPS][HEAD_TYPES] = { { // down stem { wholeheadSym, halfheadSym, quartheadSym, brevisheadSym }, { wholecrossedheadSym, halfcrossedheadSym, crossedheadSym, wholecrossedheadSym }, { wholediamondheadSym, halfdiamondheadSym, diamondheadSym, wholediamondheadSym }, { s0triangleHeadSym, d1triangleHeadSym, d2triangleHeadSym, s0triangleHeadSym }, - { s0miHeadSym, s1miHeadSym, s2miHeadSym, -1 }, + { s0miHeadSym, s1miHeadSym, s2miHeadSym, noSym }, { wholeslashheadSym, halfslashheadSym, quartslashheadSym, wholeslashheadSym }, { xcircledheadSym, xcircledheadSym, xcircledheadSym, xcircledheadSym }, - { s0doHeadSym, d1doHeadSym, d2doHeadSym, -1 }, - { s0reHeadSym, d1reHeadSym, d2reHeadSym, -1 }, - { d0faHeadSym, d1faHeadSym, d2faHeadSym, -1 }, - { s0laHeadSym, s1laHeadSym, s2laHeadSym, -1 }, - { s0tiHeadSym, d1tiHeadSym, d2tiHeadSym, -1 }, - { s0solHeadSym, s1solHeadSym, s2solHeadSym, -1 }, + { s0doHeadSym, d1doHeadSym, d2doHeadSym, noSym }, + { s0reHeadSym, d1reHeadSym, d2reHeadSym, noSym }, + { d0faHeadSym, d1faHeadSym, d2faHeadSym, noSym }, + { s0laHeadSym, s1laHeadSym, s2laHeadSym, noSym }, + { s0tiHeadSym, d1tiHeadSym, d2tiHeadSym, noSym }, + { s0solHeadSym, s1solHeadSym, s2solHeadSym, noSym }, { wholeheadSym, halfheadSym, quartheadSym, brevisheadaltSym }, }, { // up stem @@ -81,15 +81,15 @@ const int noteHeads[2][Note::HEAD_GROUPS][HEAD_TYPES] = { { wholecrossedheadSym, halfcrossedheadSym, crossedheadSym, wholecrossedheadSym }, { wholediamondheadSym, halfdiamondheadSym, diamondheadSym, wholediamondheadSym }, { s0triangleHeadSym, u1triangleHeadSym, u2triangleHeadSym, s0triangleHeadSym }, - { s0miHeadSym, s1miHeadSym, s2miHeadSym, -1 }, + { s0miHeadSym, s1miHeadSym, s2miHeadSym, noSym }, { wholeslashheadSym, halfslashheadSym, quartslashheadSym, wholeslashheadSym }, { xcircledheadSym, xcircledheadSym, xcircledheadSym, xcircledheadSym }, - { s0doHeadSym, u1doHeadSym, u2doHeadSym, -1 }, - { s0reHeadSym, u1reHeadSym, u2reHeadSym, -1 }, - { u0faHeadSym, u1faHeadSym, u2faHeadSym, -1 }, - { s0laHeadSym, s1laHeadSym, s2laHeadSym, -1 }, - { s0tiHeadSym, u1tiHeadSym, u2tiHeadSym, -1 }, - { s0solHeadSym, s1solHeadSym, s2solHeadSym, -1 }, + { s0doHeadSym, u1doHeadSym, u2doHeadSym, noSym }, + { s0reHeadSym, u1reHeadSym, u2reHeadSym, noSym }, + { u0faHeadSym, u1faHeadSym, u2faHeadSym, noSym }, + { s0laHeadSym, s1laHeadSym, s2laHeadSym, noSym }, + { s0tiHeadSym, u1tiHeadSym, u2tiHeadSym, noSym }, + { s0solHeadSym, s1solHeadSym, s2solHeadSym, noSym }, { wholeheadSym, halfheadSym, quartheadSym, brevisheadaltSym }, } }; @@ -123,7 +123,7 @@ Sym* noteHeadSym(bool up, int group, int type) void NoteHead::write(Xml& xml) const { xml.stag("NoteHead"); - xml.tag("name", symbols[0][_sym].name()); + xml.tag("name", Sym::id2name(_sym)); Element::writeProperties(xml); xml.etag(); } @@ -1585,7 +1585,7 @@ void Note::updateAccidental(AccidentalState* as) newUserAcc = ACC_SHARP; else newUserAcc = ACC_SHARP2; - + if (_accidental->subtype() != newUserAcc) acci = ACC_NONE; // don't use this any more else { @@ -1594,7 +1594,7 @@ void Note::updateAccidental(AccidentalState* as) AccidentalVal accVal = tpc2alter(_tpc); if ((accVal != as->accidentalVal(int(_line))) || hidden() || as->tieContext(int(_line))) - as->setAccidentalVal(int(_line), + as->setAccidentalVal(int(_line), accVal, _tieBack != 0); } break; diff --git a/libmscore/note.h b/libmscore/note.h index b08f0f33ee2dc..8457d132a5e8c 100644 --- a/libmscore/note.h +++ b/libmscore/note.h @@ -333,7 +333,7 @@ Q_DECLARE_METATYPE(Note::NoteHeadGroup) Q_DECLARE_METATYPE(Note::NoteHeadType) extern Sym* noteHeadSym(bool up, int group, int n); -extern const int noteHeads[2][Note::HEAD_GROUPS][HEAD_TYPES]; +extern const SymId noteHeads[2][Note::HEAD_GROUPS][HEAD_TYPES]; #endif diff --git a/libmscore/pedal.cpp b/libmscore/pedal.cpp index 8ea17260d4981..9a8d6e65ab1f7 100644 --- a/libmscore/pedal.cpp +++ b/libmscore/pedal.cpp @@ -41,7 +41,7 @@ Pedal::Pedal(Score* s) void Pedal::read(const QDomElement& e) { if (score()->mscVersion() >= 110) { - setBeginSymbol(-1); + setBeginSymbol(noSym); setEndHook(false); } TextLine::read(e); diff --git a/libmscore/sym.cpp b/libmscore/sym.cpp index 8292f88426327..bfb7f4f35f68d 100644 --- a/libmscore/sym.cpp +++ b/libmscore/sym.cpp @@ -24,18 +24,21 @@ static bool symbolsInitialized[2] = { false, false }; QMap charReplaceMap; static QReadWriteLock gLock; +QHash Sym::lnhash; +QVector Sym::symNames; +QVector Sym::symUserNames; //--------------------------------------------------------- // SymbolNames //--------------------------------------------------------- struct SymbolNames { - int msIndex; + SymId msIndex; const char* mname; // user visible name - const char* name; + const char* name; // xml symbol name }; -SymbolNames lilypondNames[] = { +static SymbolNames lilypondNames[] = { { wholerestSym, QT_TRANSLATE_NOOP("symbol", "whole rest"), "rests.0" }, { halfrestSym, QT_TRANSLATE_NOOP("symbol", "half rest"), "rests.1" }, { outsidewholerestSym, QT_TRANSLATE_NOOP("symbol", "outside whole rest"), "rests.0o" }, @@ -76,21 +79,21 @@ SymbolNames lilypondNames[] = { { flatflatslashSym, QT_TRANSLATE_NOOP("symbol", "flat flat slash"), "accidentals.flatflat.slash" }, { sharpsharpSym, QT_TRANSLATE_NOOP("symbol", "sharp sharp"), "accidentals.doublesharp" }, { soriSym, QT_TRANSLATE_NOOP("symbol", "sori"), "accidentals.sori" }, - { koronSym, QT_TRANSLATE_NOOP("symbol", "koron"), "accidentals.koron" }, + { koronSym, QT_TRANSLATE_NOOP("symbol", "koron"), "accidentals.koron" }, { rightparenSym, QT_TRANSLATE_NOOP("symbol", "right parenthesis"), "accidentals.rightparen" }, - { leftparenSym, QT_TRANSLATE_NOOP("symbol", "left parenthesis"), "accidentals.leftparen" }, - - { -1, "", "arrowheads.open.01" }, - { -1, "", "arrowheads.open.0M1" }, - { -1, "", "arrowheads.open.11" }, - { -1, "", "arrowheads.open.1M1" }, - { -1, "", "arrowheads.close.01" }, - { -1, "", "arrowheads.close.0M1" }, - { -1, "", "arrowheads.close.11" }, - { -1, "", "arrowheads.close.1M1" }, - - { dotSym, QT_TRANSLATE_NOOP("symbol", "dot"), "dots.dot" }, + { leftparenSym, QT_TRANSLATE_NOOP("symbol", "left parenthesis"), "accidentals.leftparen" }, + + { open01arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "open arrowhead 01"), "arrowheads.open.01" }, + { open0M1arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "open arrowhead 0M1"), "arrowheads.open.0M1" }, + { open11arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "open arrowhead 11"), "arrowheads.open.11" }, + { open1M1arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "open arrowhead 1M1"), "arrowheads.open.1M1" }, + { close01arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "close arrowhead 01"), "arrowheads.close.01" }, + { close0M1arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "close arrowhead 0M1"), "arrowheads.close.0M1" }, + { close11arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "close arrowhead 11"), "arrowheads.close.11" }, + { close1M1arrowHeadSym, QT_TRANSLATE_NOOP("symbol", "close arrowhead 1M1"), "arrowheads.close.1M1" }, + + { dotSym, QT_TRANSLATE_NOOP("symbol", "dot"), "dots.dot" }, { longaupSym, QT_TRANSLATE_NOOP("symbol", "longa up"), "noteheads.uM2" }, { longadownSym, QT_TRANSLATE_NOOP("symbol", "longa down"), "noteheads.dM2" }, { brevisheadSym, QT_TRANSLATE_NOOP("symbol", "brevis head"), "noteheads.sM1" }, @@ -184,8 +187,8 @@ SymbolNames lilypondNames[] = { { varcodaSym, QT_TRANSLATE_NOOP("symbol", "varied coda"), "scripts.varcoda" }, { rcommaSym, QT_TRANSLATE_NOOP("symbol", "rcomma"), "scripts.rcomma" }, { lcommaSym, QT_TRANSLATE_NOOP("symbol", "lcomma"), "scripts.lcomma" }, - { -1, "", "scripts.rvarcomma" }, - { -1, "", "scripts.lvarcomma" }, + { rvarcommaSym, QT_TRANSLATE_NOOP("symbol", "rcomma variation"), "scripts.rvarcomma" }, + { lvarcommaSym, QT_TRANSLATE_NOOP("symbol", "lcomma variation"), "scripts.lvarcomma" }, { arpeggioSym, QT_TRANSLATE_NOOP("symbol", "arpeggio"), "scripts.arpeggio" }, { trillelementSym, QT_TRANSLATE_NOOP("symbol", "trillelement"), "scripts.trill_element" }, { arpeggioarrowdownSym, QT_TRANSLATE_NOOP("symbol", "arpeggio arrow down"), "scripts.arpeggio.arrow.M1" }, @@ -249,12 +252,10 @@ SymbolNames lilypondNames[] = { { accDiscantSym, QT_TRANSLATE_NOOP("symbol", "accordeon discant"), "accordion.accDiscant" }, { accpushSym, QT_TRANSLATE_NOOP("symbol", "accordeon push"), "accordion.push" }, { accpullSym, QT_TRANSLATE_NOOP("symbol", "accordeon pull"), "accordion.pull" }, - { -1, "", "left up" }, - { -1, "", "left down" }, - { -1, "", "plus" }, - { -1, "", "comma" }, - { -1, "", "hyphen" }, - { -1, "", "period" }, + { plusSym, QT_TRANSLATE_NOOP("symbol", "plus"), "plus" }, + { commaSym, QT_TRANSLATE_NOOP("symbol", "comma"), "comma" }, + { hyphenSym, QT_TRANSLATE_NOOP("symbol", "hyphen"), "hyphen" }, + { periodSym, QT_TRANSLATE_NOOP("symblo", "period"), "period" }, { zeroSym, QT_TRANSLATE_NOOP("symbol", "zero"), "zero" }, { oneSym, QT_TRANSLATE_NOOP("symbol", "one"), "one" }, { twoSym, QT_TRANSLATE_NOOP("symbol", "two"), "two" }, @@ -266,7 +267,7 @@ SymbolNames lilypondNames[] = { { eightSym, QT_TRANSLATE_NOOP("symbol", "eight"), "eight" }, { nineSym, QT_TRANSLATE_NOOP("symbol", "nine"), "nine" }, { plusSym, QT_TRANSLATE_NOOP("symbol", "plus"), "plus" }, - { -1, "", "space" }, + { spaceSym, QT_TRANSLATE_NOOP("symbol", "space"), "space" }, { letterzSym, QT_TRANSLATE_NOOP("symbol", "z"), "z" }, { letterfSym, QT_TRANSLATE_NOOP("symbol", "f"), "f" }, { lettersSym, QT_TRANSLATE_NOOP("symbol", "s"), "s" }, @@ -283,112 +284,8 @@ SymbolNames lilypondNames[] = { { tabclef2Sym, QT_TRANSLATE_NOOP("symbol", "tab2 clef"), "clefs.tab2" }, }; -SymCode pSymbols[] = { - SymCode(0xe10e, 1), //natural - SymCode(0xe10c, 1), // sharp - SymCode(0xe10d, 1), // flat - SymCode(0xe104, 1), // note2_Sym - -// SymCode(0xe105, 1), // note4_Sym - SymCode(0x1d15f, 1), // note4_Sym - - SymCode(0xe106, 1), // note8_Sym - - SymCode(0xe107, 1), // note16_Sym - SymCode(0xe108, 1), // note32_Sym - SymCode(0xe109, 1), // note64_Sym - SymCode(0xe10a, 1), // dot - SymCode(0xe10b, 1), // dotdot - SymCode(0xe167, 1), // coda - SymCode(0xe168, 1), // varcoda - SymCode(0xe169, 1), // segno - - SymCode(0, 0), +static SymCode pSymbols[] = { SymCode(0xa9, -1, "(C)", SYMBOL_COPYRIGHT), - SymCode(0x00c0, -1), - SymCode(0x00c1, -1), - SymCode(0x00c2, -1), - SymCode(0x00c3, -1), - SymCode(0x00c4, -1), - SymCode(0x00c5, -1), - SymCode(0x00c6, -1), - SymCode(0x00c7, -1), - SymCode(0x00c8, -1), - SymCode(0x00c9, -1), - SymCode(0x00ca, -1), - SymCode(0x00cb, -1), - SymCode(0x00cc, -1), - SymCode(0x00cd, -1), - SymCode(0x00ce, -1), - SymCode(0x00cf, -1), - - SymCode(0x00d0, -1), - SymCode(0x00d1, -1), - SymCode(0x00d2, -1), - SymCode(0x00d3, -1), - SymCode(0x00d4, -1), - SymCode(0x00d5, -1), - SymCode(0x00d6, -1), - SymCode(0x00d7, -1), - SymCode(0x00d8, -1), - SymCode(0x00d9, -1), - SymCode(0x00da, -1), - SymCode(0x00db, -1), - SymCode(0x00dc, -1), - SymCode(0x00dd, -1), - SymCode(0x00de, -1), - SymCode(0x00df, -1), - - //capital letters esperanto - SymCode(0x0108, -1), - SymCode(0x011c, -1), - SymCode(0x0124, -1), - SymCode(0x0134, -1), - SymCode(0x015c, -1), - SymCode(0x016c, -1), - - SymCode(0x00e0, -1), - SymCode(0x00e1, -1), - SymCode(0x00e2, -1), - SymCode(0x00e3, -1), - SymCode(0x00e4, -1), - SymCode(0x00e5, -1), - SymCode(0x00e6, -1), - SymCode(0x00e7, -1), - SymCode(0x00e8, -1), - SymCode(0x00e9, -1), - SymCode(0x00ea, -1), - SymCode(0x00eb, -1), - SymCode(0x00ec, -1), - SymCode(0x00ed, -1), - SymCode(0x00ee, -1), - SymCode(0x00ef, -1), - - SymCode(0x00f0, -1), - SymCode(0x00f1, -1), - SymCode(0x00f2, -1), - SymCode(0x00f3, -1), - SymCode(0x00f4, -1), - SymCode(0x00f5, -1), - SymCode(0x00f6, -1), - SymCode(0x00f7, -1), - SymCode(0x00f8, -1), - SymCode(0x00f9, -1), - SymCode(0x00fa, -1), - SymCode(0x00fb, -1), - SymCode(0x00fc, -1), - SymCode(0x00fd, -1), - SymCode(0x00fe, -1), - SymCode(0x00ff, -1), - //small letters esperanto - SymCode(0x0109, -1), - SymCode(0x011d, -1), - SymCode(0x0125, -1), - SymCode(0x0135, -1), - SymCode(0x015d, -1), - SymCode(0x016d, -1), - - SymCode(0x00BC, -1, "1/4", SYMBOL_FRACTION), SymCode(0x00BD, -1, "1/2", SYMBOL_FRACTION), SymCode(0x00BE, -1, "3/4", SYMBOL_FRACTION), @@ -404,11 +301,6 @@ SymCode pSymbols[] = { SymCode(0x215C, -1, "3/8", SYMBOL_FRACTION), SymCode(0x215D, -1, "5/8", SYMBOL_FRACTION), SymCode(0x215E, -1, "7/8", SYMBOL_FRACTION), - - // SymCode(0x203F, -1), // curved ligature to connect two syllables - SymCode(0x35c, -1), // curved ligature to connect two syllables - SymCode(0x361, -1), // curved ligature (top) - SymCode(-1, -1) // indicates end }; @@ -473,13 +365,13 @@ void Sym::genGlyphs(const QFont& font) // Sym //--------------------------------------------------------- -Sym::Sym(const char* name, int c, int fid, qreal ax, qreal ay) - : _code(c), fontId(fid), _name(name), _attach(ax * MScore::DPI/PPI, ay * MScore::DPI/PPI) +Sym::Sym(int c, int fid, qreal ax, qreal ay) + : _code(c), fontId(fid), _attach(ax * MScore::DPI/PPI, ay * MScore::DPI/PPI) { QFont _font(fontId2font(fontId)); QFontMetricsF fm(_font); if (!fm.inFont(_code)) { - qDebug("Sym: character 0x%x(%d) <%s> are not in font <%s>\n", c, c, _name, qPrintable(_font.family())); + qDebug("Sym: character 0x%x(%d) are not in font <%s>\n", c, c, qPrintable(_font.family())); return; } w = fm.width(_code); @@ -489,8 +381,8 @@ Sym::Sym(const char* name, int c, int fid, qreal ax, qreal ay) #endif } -Sym::Sym(const char* name, int c, int fid, const QPointF& a, const QRectF& b) - : _code(c), fontId(fid), _name(name) +Sym::Sym(int c, int fid, const QPointF& a, const QRectF& b) + : _code(c), fontId(fid) { qreal ds = MScore::DPI/PPI; _bbox.setRect(b.x() * ds, b.y() * ds, b.width() * ds, b.height() * ds); @@ -647,6 +539,41 @@ QString symToHtml(const Sym& s1, const Sym& s2, int leftMargin) "").arg(family).arg(size).arg(leftMargin).arg(s1.code()).arg(s2.code()); } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void Sym::init() + { + symNames = QVector(lastSym); + symUserNames = QVector(lastSym); + + for (unsigned int i = 0; i < sizeof(lilypondNames)/sizeof(*lilypondNames); ++i) { + SymId id = lilypondNames[i].msIndex; + lnhash[QString(lilypondNames[i].name)] = id; + if (id != noSym) { + symNames[id] = lilypondNames[i].name; + symUserNames[id] = lilypondNames[i].mname; + } + } + +// #define MT(a) QT_TRANSLATE_NOOP("symbol", a) + + symNames[clefEightSym] = "clef eight"; + symNames[clefOneSym] = "clef one"; + symNames[clefFiveSym] = "clef five"; + symNames[letterTSym] = "T"; + symNames[letterSSym] = "S"; + symNames[letterPSym] = "P"; + + for (unsigned i = 0; pSymbols[i].code != -1; ++i) { + if (pSymbols[i].code == 0 || pSymbols[i].text == 0) + continue; + charReplaceMap.insert(pSymbols[i].text, &pSymbols[i]); + } + } + //--------------------------------------------------------- // initSymbols //--------------------------------------------------------- @@ -658,32 +585,12 @@ void initSymbols(int idx) symbolsInitialized[idx] = true; symbols[idx] = QVector(lastSym); -#define MT(a) QT_TRANSLATE_NOOP("symbol", a) - symbols[idx][clefEightSym] = Sym(MT("clef eight"), 0x38, 2); - symbols[idx][clefOneSym] = Sym(MT("clef one"), 0x31, 2); - symbols[idx][clefFiveSym] = Sym(MT("clef five"), 0x35, 2); - symbols[idx][letterfSym] = Sym(MT("f"), 0x66, 1); - symbols[idx][lettermSym] = Sym(MT("m"), 0x6d, 1); - symbols[idx][letterpSym] = Sym(MT("p"), 0x70, 1); - symbols[idx][letterrSym] = Sym(MT("r"), 0x72, 1); - symbols[idx][lettersSym] = Sym(MT("s"), 0x73, 1); - symbols[idx][letterzSym] = Sym(MT("z"), 0x7a, 1); - symbols[idx][letterTSym] = Sym(MT("T"), 'T', 2); - symbols[idx][letterSSym] = Sym(MT("S"), 'S', 2); - symbols[idx][letterPSym] = Sym(MT("P"), 'P', 2); - // used for GUI: -// symbols[idx][note2Sym] = Sym(MT("note 1/4"), 0xe104, 1); - symbols[idx][note4Sym] = Sym(MT("note 1/4"), 0xe104, 1); // 0x1d15f, 1); -// symbols[idx][note8Sym] = Sym(MT("note 1/8"), 0xe106, 1); -// symbols[idx][note16Sym] = Sym(MT("note 1/16"), 0xe107, 1); -// symbols[idx][note32Sym] = Sym(MT("note 1/32"), 0xe108, 1); -// symbols[idx][note64Sym] = Sym(MT("note 1/64"), 0xe109, 1); -// symbols[idx][dotdotSym] = Sym(MT("dot dot"), 0xe10b, 1); -#undef MT - - QHash lnhash; - for (unsigned int i = 0; i < sizeof(lilypondNames)/sizeof(*lilypondNames); ++i) - lnhash[QString(lilypondNames[i].name)] = lilypondNames[i].msIndex; + symbols[idx][clefEightSym] = Sym(0x38, 2); + symbols[idx][clefOneSym] = Sym(0x31, 2); + symbols[idx][clefFiveSym] = Sym(0x35, 2); + symbols[idx][letterTSym] = Sym('T', 2); + symbols[idx][letterSSym] = Sym('S', 2); + symbols[idx][letterPSym] = Sym('P', 2); QString path; #ifdef Q_WS_IOS @@ -744,12 +651,12 @@ void initSymbols(int idx) } if (code == -1) qDebug("no code for glyph <%s>\n", qPrintable(name)); - int idx1 = lnhash[name]; - if (idx1 > 0) - symbols[idx][idx1] = Sym(strdup(qPrintable(name)), code, fid, p, b); - else { // if (idx == 0) -// qDebug("symbol <%s> for symbol set %d not found in %s\n", -// qPrintable(name), idx, qPrintable(path)); + SymId idx1 = Sym::name2id(name); + if (idx1 != noSym) + symbols[idx][idx1] = Sym(code, fid, p, b); + else { + qDebug("symbol <%s> for symbol set %d not found in %s", + qPrintable(name), idx, qPrintable(path)); } } else @@ -759,18 +666,10 @@ void initSymbols(int idx) else domError(e); } - - for (unsigned int i = 0; i < sizeof(lilypondNames)/sizeof(*lilypondNames); ++i) { - int idx1 = lilypondNames[i].msIndex; - if (idx1 != -1) - symbols[idx][idx1].setName(lilypondNames[i].mname); - } - if (charReplaceMap.isEmpty()) { - for (unsigned i = 0; pSymbols[i].code != -1; ++i) { - if (pSymbols[i].code == 0 || pSymbols[i].text == 0) - continue; - charReplaceMap.insert(pSymbols[i].text, &pSymbols[i]); - } + for (int i = 0; i < lastSym; ++i) { + Sym* sym = &symbols[idx][i]; + if (sym->code() == -1) + qDebug("no code for symbol %s", Sym::id2name(SymId(i))); } } diff --git a/libmscore/sym.h b/libmscore/sym.h index 82b9763e5fcf1..cc0d2c6b16949 100644 --- a/libmscore/sym.h +++ b/libmscore/sym.h @@ -44,48 +44,6 @@ struct SymCode { extern QMap charReplaceMap; -extern SymCode pSymbols[]; - -//--------------------------------------------------------- -// Sym -//--------------------------------------------------------- - -class Sym { - int _code; - int fontId; - const char* _name; - qreal w; - QRectF _bbox; - QPointF _attach; -#ifdef USE_GLYPHS - QGlyphRun glyphs; // cached values - void genGlyphs(const QFont& font); -#endif - - public: - Sym() { _code = 0; } - Sym(const char* name, int c, int fid, qreal x=0.0, qreal y=0.0); - Sym(const char* name, int c, int fid, const QPointF&, const QRectF&); - - QFont font() const { return fontId2font(fontId); } - const char* name() const { return _name; } - void setName(const char* s) { _name = s; } - const QRectF bbox(qreal mag) const; - qreal height(qreal mag) const { return _bbox.height() * mag; } - qreal width(qreal mag) const { return w * mag; } - QPointF attach(qreal mag) const { return _attach * mag; } - int code() const { return _code; } - int getFontId() const { return fontId; } - int setFontId(int v) { return fontId = v; } - void draw(QPainter* painter, qreal mag, const QPointF& pos = QPointF()) const; - void draw(QPainter* painter, qreal mag, const QPointF& pos, int n) const; - void setAttach(const QPointF& r) { _attach = r; } - bool isValid() const { return _code != 0; } - QRectF getBbox() const { return _bbox; } - QPointF getAttach() const { return _attach; } - QString toString() const; - }; - //--------------------------------------------------------- // SymId //--------------------------------------------------------- @@ -215,6 +173,15 @@ enum SymId { s1solHeadSym, s2solHeadSym, + open01arrowHeadSym, + open0M1arrowHeadSym, + open11arrowHeadSym, + open1M1arrowHeadSym, + close01arrowHeadSym, + close0M1arrowHeadSym, + close11arrowHeadSym, + close1M1arrowHeadSym, + ufermataSym, dfermataSym, @@ -257,6 +224,8 @@ enum SymId { rcommaSym, lcommaSym, + lvarcommaSym, + rvarcommaSym, arpeggioSym, trillelementSym, @@ -326,19 +295,16 @@ enum SymId { letterrSym, lettersSym, letterzSym, + letterTSym, letterSSym, letterPSym, plusSym, - -// note2Sym, - note4Sym, -// note8Sym, -// note16Sym, -// note32Sym, -// note64Sym, -// dotdotSym, + commaSym, + hyphenSym, + periodSym, + spaceSym, longaupaltSym, longadownaltSym, @@ -353,6 +319,53 @@ enum SymId { lastSym }; +//--------------------------------------------------------- +// Sym +//--------------------------------------------------------- + +class Sym { + int _code; + int fontId; + qreal w; + QRectF _bbox; + QPointF _attach; + +#ifdef USE_GLYPHS + QGlyphRun glyphs; // cached values + void genGlyphs(const QFont& font); +#endif + + static QVector symNames; + static QVector symUserNames; + static QHash lnhash; + + public: + Sym() { _code = -1; } + Sym(int c, int fid, qreal x=0.0, qreal y=0.0); + Sym(int c, int fid, const QPointF&, const QRectF&); + + QFont font() const { return fontId2font(fontId); } + const QRectF bbox(qreal mag) const; + qreal height(qreal mag) const { return _bbox.height() * mag; } + qreal width(qreal mag) const { return w * mag; } + QPointF attach(qreal mag) const { return _attach * mag; } + int code() const { return _code; } + int getFontId() const { return fontId; } + int setFontId(int v) { return fontId = v; } + void draw(QPainter* painter, qreal mag, const QPointF& pos = QPointF()) const; + void draw(QPainter* painter, qreal mag, const QPointF& pos, int n) const; + void setAttach(const QPointF& r) { _attach = r; } + bool isValid() const { return _code != 0; } + QRectF getBbox() const { return _bbox; } + QPointF getAttach() const { return _attach; } + QString toString() const; + + static SymId name2id(const QString& s) { return lnhash[s]; } + static const char* id2name(SymId id) { return symNames[id]; } + static QString id2userName(SymId id) { return symUserNames[id]; } + static void init(); + }; + extern QVector symbols[2]; extern QString symToHtml(const Sym&, int leftMargin=0, const TextStyle* ts = 0, qreal sp=10.0); diff --git a/libmscore/symbol.cpp b/libmscore/symbol.cpp index d4c107cf630ca..3e16a476e73b7 100644 --- a/libmscore/symbol.cpp +++ b/libmscore/symbol.cpp @@ -158,11 +158,11 @@ QRectF BSymbol::drag(const EditData& data) Symbol::Symbol(Score* s) : BSymbol(s) { - _sym = 0; + _sym = noSym; setZ(SYMBOL * 100); } -Symbol::Symbol(Score* s, int sy) +Symbol::Symbol(Score* s, SymId sy) : BSymbol(s) { _sym = sy; @@ -223,7 +223,7 @@ void Symbol::draw(QPainter* p) const void Symbol::write(Xml& xml) const { xml.stag(name()); - xml.tag("name", symbols[score()->symIdx()][_sym].name()); + xml.tag("name", Sym::id2name(_sym)); Element::writeProperties(xml); foreach(const Element* e, leafs()) e->write(xml); @@ -237,22 +237,16 @@ void Symbol::write(Xml& xml) const void Symbol::read(const QDomElement& de) { QPointF pos; - int s = -1; + SymId s = noSym; for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "name") { - for (int i = 0; i < symbols[0].size(); ++i) { - if (val == symbols[0][i].name()) { - s = i; - break; - } - } - if (s == -1) { + s = Sym::name2id(val); + if (s == noSym) { qDebug("unknown symbol <%s>, symbols %d\n", qPrintable(val), symbols[0].size()); - s = 0; } } else if (tag == "Symbol") { @@ -292,10 +286,8 @@ void Symbol::read(const QDomElement& de) else if (!Element::readProperties(e)) domError(e); } - if (s == -1) { + if (s == noSym) qDebug("unknown symbol\n"); - s = 0; - } setPos(pos); setSym(s); } diff --git a/libmscore/symbol.h b/libmscore/symbol.h index 1e97bc19ae926..f6fddd727fd16 100644 --- a/libmscore/symbol.h +++ b/libmscore/symbol.h @@ -15,6 +15,7 @@ #define __SYMBOL_H__ #include "bsymbol.h" +#include "sym.h" class Segment; class QPainter; @@ -28,11 +29,11 @@ class Symbol : public BSymbol { Q_OBJECT protected: - int _sym; + SymId _sym; public: Symbol(Score* s); - Symbol(Score* s, int sy); + Symbol(Score* s, SymId sy); Symbol(const Symbol&); Symbol &operator=(const Symbol&); @@ -40,8 +41,8 @@ class Symbol : public BSymbol { virtual Symbol* clone() const { return new Symbol(*this); } virtual ElementType type() const { return SYMBOL; } - void setSym(int s) { _sym = s; } - int sym() const { return _sym; } + void setSym(SymId s) { _sym = s; } + SymId sym() const { return _sym; } virtual void draw(QPainter*) const; virtual void write(Xml& xml) const; diff --git a/libmscore/textline.cpp b/libmscore/textline.cpp index 1a73749b83437..254fc95935318 100644 --- a/libmscore/textline.cpp +++ b/libmscore/textline.cpp @@ -269,9 +269,9 @@ TextLine::TextLine(Score* s) _lineColor = Qt::black; _mxmlOff2 = 0; - _beginSymbol = -1; - _continueSymbol = -1; - _endSymbol = -1; + _beginSymbol = noSym; + _continueSymbol = noSym; + _endSymbol = noSym; _sp = 0; } @@ -429,15 +429,15 @@ void TextLine::writeProperties(Xml& xml, const TextLine* proto) const xml.etag(); } if (_beginSymbol != -1) { - xml.tag("beginSymbol", _beginSymbol); // symbols[_symbol].name(); + xml.tag("beginSymbol", Sym::id2name(_beginSymbol)); xml.tag("beginSymbolOffset", _beginSymbolOffset); } if (_continueSymbol != -1) { - xml.tag("continueSymbol", _continueSymbol); + xml.tag("continueSymbol", Sym::id2name(_continueSymbol)); xml.tag("continueSymbolOffset", _continueSymbolOffset); } if (_endSymbol != -1) { - xml.tag("endSymbol", _endSymbol); + xml.tag("endSymbol", Sym::id2name(_endSymbol)); xml.tag("endSymbolOffset", _endSymbolOffset); } } @@ -466,11 +466,11 @@ bool TextLine::readProperties(const QDomElement& e) else if (tag == "hookUp") // obsolete _endHookHeight *= qreal(-1.0); else if (tag == "beginSymbol" || tag == "symbol") // "symbol" is obsolete - _beginSymbol = text.toInt(); + _beginSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "continueSymbol") - _continueSymbol = text.toInt(); + _continueSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "endSymbol") - _endSymbol = text.toInt(); + _endSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "beginSymbolOffset") _beginSymbolOffset = readPoint(e); else if (tag == "continueSymbolOffset") diff --git a/libmscore/textline.h b/libmscore/textline.h index 0b57a800ad771..a3aa83d7e2a18 100644 --- a/libmscore/textline.h +++ b/libmscore/textline.h @@ -66,7 +66,7 @@ class TextLine : public SLine { HookType _beginHookType, _endHookType; Spatium _beginHookHeight, _endHookHeight; - int _beginSymbol, _continueSymbol, _endSymbol; // -1: no symbol + SymId _beginSymbol, _continueSymbol, _endSymbol; QPointF _beginSymbolOffset, _continueSymbolOffset, _endSymbolOffset; int _mxmlOff2; @@ -112,9 +112,9 @@ class TextLine : public SLine { Placement continueTextPlace() const { return _continueTextPlace; } void setContinueTextPlace(Placement p) { _continueTextPlace = p; } - void setBeginSymbol(int v) { _beginSymbol = v; } - void setContinueSymbol(int v) { _continueSymbol = v; } - void setEndSymbol(int v) { _endSymbol = v; } + void setBeginSymbol(SymId v) { _beginSymbol = v; } + void setContinueSymbol(SymId v) { _continueSymbol = v; } + void setEndSymbol(SymId v) { _endSymbol = v; } void setBeginHookHeight(Spatium v) { _beginHookHeight = v; } void setEndHookHeight(Spatium v) { _endHookHeight = v; } @@ -127,9 +127,9 @@ class TextLine : public SLine { void setLineWidth(const Spatium& v) { _lineWidth = v; } void setLineColor(const QColor& v) { _lineColor = v; } void setLineStyle(Qt::PenStyle v) { _lineStyle = v; } - int beginSymbol() const { return _beginSymbol; } - int continueSymbol() const { return _continueSymbol; } - int endSymbol() const { return _endSymbol; } + SymId beginSymbol() const { return _beginSymbol; } + SymId continueSymbol() const { return _continueSymbol; } + SymId endSymbol() const { return _endSymbol; } QPointF beginSymbolOffset() const { return _beginSymbolOffset; } QPointF continueSymbolOffset() const { return _continueSymbolOffset; } QPointF endSymbolOffset() const { return _endSymbolOffset; } diff --git a/mscore/exportly.cpp b/mscore/exportly.cpp index 4c7fa67588c4a..4da4605a5a987 100644 --- a/mscore/exportly.cpp +++ b/mscore/exportly.cpp @@ -1520,7 +1520,7 @@ void ExportLy::handleElement(Element* el) { cout << "symbol in anchorlist tick: " << anchors[i].tick << " \n"; sym = (Symbol*) instruction; - name = symbols[0][sym->sym()].name(); + name = Sym::id2name(sym->sym()); writeSymbol(name); break; } @@ -2922,7 +2922,7 @@ bool ExportLy::findNoteSymbol(Note* n, QString& symbolname) foreach(const Element* symbol, n->el()) { if (symbol->type() == SYMBOL) { const Symbol* symb = static_cast(symbol); - symbolname = symbols[0][symb->sym()].name(); + symbolname = Sym::id2name(symb->sym()); return true; // what about more symbols connected to one note? Return array of names? } } diff --git a/mscore/exportxml.cpp b/mscore/exportxml.cpp index 638230b60fb3c..cfe7b7f28cc04 100644 --- a/mscore/exportxml.cpp +++ b/mscore/exportxml.cpp @@ -2913,10 +2913,10 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) xml.tag("offset", offs); if (staff) xml.tag("staff", staff); - + if(dyn->velocity() > 0) xml.tagE(QString("sound dynamics=\"%1\"").arg(QString::number(dyn->velocity() * 100.0 / 90.0, 'f', 2))); - + xml.etag(); } @@ -2929,7 +2929,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff) void ExportMusicXml::symbol(Symbol const* const sym, int staff) { - QString name = symbols[score->symIdx()][sym->sym()].name(); + QString name = Sym::id2name(sym->sym()); const char* mxmlName = ""; if (name == "pedal ped") mxmlName = "pedal type=\"start\""; diff --git a/mscore/lineproperties.cpp b/mscore/lineproperties.cpp index 3362c3edf93a8..9cfa1578b06e6 100644 --- a/mscore/lineproperties.cpp +++ b/mscore/lineproperties.cpp @@ -205,14 +205,14 @@ void LineProperties::accept() else tl->setContinueText(0); - int sym = beginSymbol->itemData(beginSymbol->currentIndex()).toInt(); - tl->setBeginSymbol(beginSymbolRb->isChecked() ? sym : -1); + SymId sym = SymId(beginSymbol->itemData(beginSymbol->currentIndex()).toInt()); + tl->setBeginSymbol(beginSymbolRb->isChecked() ? sym : noSym); - sym = continueSymbol->itemData(continueSymbol->currentIndex()).toInt(); - tl->setContinueSymbol(continueSymbolRb->isChecked() ? sym : -1); + sym = SymId(continueSymbol->itemData(continueSymbol->currentIndex()).toInt()); + tl->setContinueSymbol(continueSymbolRb->isChecked() ? sym : noSym); - sym = endSymbol->itemData(endSymbol->currentIndex()).toInt(); - tl->setEndSymbol(endSymbolRb->isChecked() ? sym : -1); + sym = SymId(endSymbol->itemData(endSymbol->currentIndex()).toInt()); + tl->setEndSymbol(endSymbolRb->isChecked() ? sym : noSym); Placement p = PLACE_ABOVE; switch(beginTextPlace->currentIndex()) { diff --git a/mscore/menus.cpp b/mscore/menus.cpp index 79f130a230c1d..33c225cd7dcf7 100644 --- a/mscore/menus.cpp +++ b/mscore/menus.cpp @@ -459,12 +459,12 @@ Palette* MuseScore::newNoteHeadsPalette() sp->setDrawGrid(true); for (int i = 0; i < Note::HEAD_GROUPS; ++i) { - int sym = noteHeads[0][i][1]; + SymId sym = noteHeads[0][i][1]; if (i == Note::HEAD_BREVIS_ALT) sym = noteHeads[0][i][3]; NoteHead* nh = new NoteHead(gscore); nh->setSym(sym); - sp->append(nh, qApp->translate("symbol", symbols[0][sym].name())); + sp->append(nh, qApp->translate("symbol", Sym::id2name(sym))); } return sp; } @@ -714,7 +714,7 @@ Palette* MuseScore::newLinesPalette() pedal = new Pedal(gscore); pedal->setLen(w); - pedal->setBeginSymbol(-1); + pedal->setBeginSymbol(noSym); pedal->setBeginHook(true); pedal->setBeginHookType(HOOK_45); pedal->setEndHookType(HOOK_45); @@ -722,7 +722,7 @@ Palette* MuseScore::newLinesPalette() pedal = new Pedal(gscore); pedal->setLen(w); - pedal->setBeginSymbol(-1); + pedal->setBeginSymbol(noSym); pedal->setBeginHook(true); pedal->setBeginHookType(HOOK_45); sp->append(pedal, qApp->translate("lines", "Pedal")); diff --git a/mscore/palette.cpp b/mscore/palette.cpp index 260a9a52cb988..5fa721b00890d 100644 --- a/mscore/palette.cpp +++ b/mscore/palette.cpp @@ -402,13 +402,13 @@ PaletteCell* Palette::append(Element* s, const QString& name, QString tag, qreal return add(cells.size() - 1, s, name, tag, mag); } -PaletteCell* Palette::append(int symIdx) +PaletteCell* Palette::append(SymId symIdx) { if (!symbols[0][symIdx].isValid()) return 0; Symbol* s = new Symbol(gscore); s->setSym(symIdx); - return append(s, qApp->translate("symbol", ::symbols[0][symIdx].name())); + return append(s, qApp->translate("symbol", Sym::id2name(symIdx))); } //--------------------------------------------------------- diff --git a/mscore/palette.h b/mscore/palette.h index bc058e9e4d17e..50e73a6e14d05 100644 --- a/mscore/palette.h +++ b/mscore/palette.h @@ -29,6 +29,7 @@ class PaletteScrollArea; #include "ui_palette.h" #include "ui_cellproperties.h" +#include "libmscore/sym.h" //--------------------------------------------------------- // PaletteCell @@ -225,7 +226,7 @@ class Palette : public QWidget { qreal mag = 1.0); PaletteCell* add(int idx, Element*, const QString& name, const QString tag = QString(), qreal mag = 1.0); - PaletteCell* append(int sym); + PaletteCell* append(SymId sym); void setGrid(int, int); Element* element(int idx); diff --git a/mscore/symboldialog.cpp b/mscore/symboldialog.cpp index 44dd049746f8f..1dde8fe75003e 100644 --- a/mscore/symboldialog.cpp +++ b/mscore/symboldialog.cpp @@ -35,7 +35,7 @@ void SymbolDialog::createSymbolPalette() { sp = new Palette(); for (int i = 0; i < lastSym; ++i) - sp->append(i); + sp->append(SymId(i)); } //---------------------------------------------------------