bool TextLine::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& text(e.text()); if (tag == "beginHookHeight") { _beginHookHeight = Spatium(text.toDouble()); _beginHook = true; } else if (tag == "beginHookType") _beginHookType = HookType(text.toInt()); else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete _endHookHeight = Spatium(text.toDouble()); _endHook = true; } else if (tag == "endHookType") _endHookType = HookType(text.toInt()); else if (tag == "hookUp") // obsolete _endHookHeight *= qreal(-1.0); else if (tag == "beginSymbol" || tag == "symbol") // "symbol" is obsolete _beginSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "continueSymbol") _continueSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "endSymbol") _endSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); else if (tag == "beginSymbolOffset") _beginSymbolOffset = readPoint(e); else if (tag == "continueSymbolOffset") _continueSymbolOffset = readPoint(e); else if (tag == "endSymbolOffset") _endSymbolOffset = readPoint(e); else if (tag == "lineWidth") _lineWidth = Spatium(text.toDouble()); else if (tag == "lineStyle") _lineStyle = Qt::PenStyle(text.toInt()); else if (tag == "beginTextPlace") _beginTextPlace = readPlacement(e); else if (tag == "continueTextPlace") _continueTextPlace = readPlacement(e); else if (tag == "lineColor") _lineColor = readColor(e); else if (tag == "beginText") { _beginText = new Text(score()); _beginText->setParent(this); _beginText->read(e); } else if (tag == "continueText") { _continueText = new Text(score()); _continueText->setParent(this); _continueText->read(e); } else if (!SLine::readProperties(e)) { qDebug(" ==readSLineProps: failed"); return false; } return true; }
void SymbolDialog::createSymbols() { int currentIndex = fontList->currentIndex(); const ScoreFont* f = &ScoreFont::scoreFonts()[currentIndex]; sp->clear(); for (int i = 0; i < int(SymId::lastSym); ++i) { if (f->isValid(SymId(i))) { Symbol* s = new Symbol(gscore); s->setSym(SymId(i), f); sp->append(s, Sym::id2userName(SymId(i))); } } }
void SymbolDialog::createSymbols() { int currentIndex = fontList->currentIndex(); const ScoreFont* f = &ScoreFont::scoreFonts()[currentIndex]; // init the font if not done yet ScoreFont::fontFactory(f->name()); sp->clear(); for (int i = 0; i < int(SymId::lastSym); ++i) { if (f->isValid(SymId(i))) { Symbol* s = new Symbol(gscore); s->setSym(SymId(i), f); bool match = true; if (!search->text().isEmpty()) match = Sym::id2userName(SymId(i)).contains(search->text(), Qt::CaseInsensitive); if (match) sp->append(s, Sym::id2userName(SymId(i))); } } }
void KeySig::read(XmlReader& e) { _sig = KeySigEvent(); // invalidate _sig int subtype = 0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "KeySym") { KeySym ks; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "sym") { QString val(e.readElementText()); bool valid; SymId id = SymId(val.toInt(&valid)); if (!valid) id = Sym::name2id(val); if (score()->mscVersion() <= 114) { if (valid) id = KeySig::convertFromOldId(val.toInt(&valid)); else id = Sym::oldName2id(val); } ks.sym = id; } else if (tag == "pos") ks.spos = e.readPoint(); else e.unknown(); } _sig.keySymbols().append(ks); } else if (tag == "showCourtesySig") _showCourtesy = e.readInt(); else if (tag == "showNaturals") // obsolete e.readInt(); else if (tag == "accidental") _sig.setKey(Key(e.readInt())); else if (tag == "natural") // obsolete e.readInt(); else if (tag == "custom") { e.readInt(); _sig.setCustom(true); } else if (tag == "subtype") subtype = e.readInt(); else if (!Element::readProperties(e)) e.unknown(); } if (!_sig.isValid()) _sig.initFromSubtype(subtype); // for backward compatibility }
void initSymbols(int idx) { if (symbolsInitialized[idx]) return; symbolsInitialized[idx] = true; symbols[idx] = QVector<Sym>(lastSym); 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_OS_IOS { extern QString resourcePath(); QString rpath = resourcePath(); path = rpath + QString(idx == 0 ? "/mscore20.xml" : "/mscore/gonville.xml"); } #else path = idx == 0 ? ":/fonts/mscore20.xml" : ":/fonts/gonville.xml"; #endif QFile f(path); if (!f.open(QFile::ReadOnly)) { qDebug("cannot open symbols file %s", qPrintable(path)); if (!MScore::debugMode) exit(-1); } XmlReader e(&f); int fid = idx == 0 ? 0 : 3; while (e.readNextStartElement()) { if (e.name() == "museScore") { while (e.readNextStartElement()) { if (e.name() == "Glyph") { QString name; int code = -1; QPointF p; QRectF b; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "name") name = e.readElementText(); else if (tag == "code") { QString val(e.readElementText()); bool ok; code = val.mid(2).toInt(&ok, 16); if (!ok) qDebug("cannot read code"); } else if (tag == "attach") p = e.readPoint(); else if (tag == "bbox") b = e.readRect(); else e.unknown(); } if (code == -1) qDebug("no code for glyph <%s>", qPrintable(name)); SymId idx1 = Sym::name2id(name); if (idx1 != noSym) symbols[idx][idx1] = Sym(code, fid, p, b); else { qDebug("symbol <%s> declared in %s for symbol set %d not used", qPrintable(name), qPrintable(path), idx); } } else e.unknown(); } } else e.unknown(); } 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))); if (idx > 0) { //fallback to default font symbols[idx][i] = symbols[0][i]; } } } }
void Ottava::read(XmlReader& e) { qDeleteAll(spannerSegments()); spannerSegments().clear(); setId(e.intAttribute("id", -1)); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") { QString s = e.readElementText(); bool ok; int idx = s.toInt(&ok); if (!ok) { idx = int(Type::OTTAVA_8VA); for (unsigned i = 0; i < sizeof(ottavaDefault)/sizeof(*ottavaDefault); ++i) { if (s == ottavaDefault[i].name) { idx = i; break; } } } else if (score()->mscVersion() <= 114) { //subtype are now in a different order... if (idx == 1) idx = 2; else if (idx == 2) idx = 1; } setOttavaType(Type(idx)); } else if (tag == "numbersOnly") { _numbersOnly = e.readInt(); numbersOnlyStyle = PropertyStyle::UNSTYLED; } else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "lineStyle") { setLineStyle(Qt::PenStyle(e.readInt())); lineStyleStyle = PropertyStyle::UNSTYLED; } else if (tag == "beginSymbol") { beginTextStyle = PropertyStyle::UNSTYLED; QString text(e.readElementText()); setBeginText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text)); } else if (tag == "continueSymbol") { continueTextStyle = PropertyStyle::UNSTYLED; QString text(e.readElementText()); setContinueText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text)); } else if (!TextLine::readProperties(e)) e.unknown(); } }
void Xml::tag(P_ID id, QVariant data, QVariant defaultData) { if (data == defaultData) return; const char* name = propertyName(id); if (name == 0) return; switch (propertyType(id)) { case P_TYPE::BOOL: case P_TYPE::SUBTYPE: case P_TYPE::INT: case P_TYPE::SPATIUM: case P_TYPE::SP_REAL: case P_TYPE::REAL: case P_TYPE::SCALE: case P_TYPE::POINT: case P_TYPE::SIZE: case P_TYPE::COLOR: tag(name, data); break; case P_TYPE::ORNAMENT_STYLE: switch (MScore::OrnamentStyle(data.toInt())) { case MScore::OrnamentStyle::BAROQUE: tag(name, QVariant("baroque")); break; default: // tag(name, QVariant("default")); break; } break; case P_TYPE::GLISSANDO_STYLE: switch (MScore::GlissandoStyle(data.toInt())) { case MScore::GlissandoStyle::BLACK_KEYS: tag(name, QVariant("blackkeys")); break; case MScore::GlissandoStyle::WHITE_KEYS: tag(name, QVariant("whitekeys")); break; case MScore::GlissandoStyle::DIATONIC: tag(name, QVariant("diatonic")); break; default: //tag(name, QVariant("Chromatic")); break; } break; case P_TYPE::DIRECTION: tag(name, data.value<Direction>().toString()); break; case P_TYPE::DIRECTION_H: switch (MScore::DirectionH(data.toInt())) { case MScore::DirectionH::LEFT: tag(name, QVariant("left")); break; case MScore::DirectionH::RIGHT: tag(name, QVariant("right")); break; case MScore::DirectionH::AUTO: break; } break; case P_TYPE::LAYOUT_BREAK: switch (LayoutBreak::Type(data.toInt())) { case LayoutBreak::Type::LINE: tag(name, QVariant("line")); break; case LayoutBreak::Type::PAGE: tag(name, QVariant("page")); break; case LayoutBreak::Type::SECTION: tag(name, QVariant("section")); break; } break; case P_TYPE::VALUE_TYPE: switch (Note::ValueType(data.toInt())) { case Note::ValueType::OFFSET_VAL: tag(name, QVariant("offset")); break; case Note::ValueType::USER_VAL: tag(name, QVariant("user")); break; } break; case P_TYPE::PLACEMENT: switch (Element::Placement(data.toInt())) { case Element::Placement::ABOVE: tag(name, QVariant("above")); break; case Element::Placement::BELOW: tag(name, QVariant("below")); break; } break; case P_TYPE::SYMID: tag(name, Sym::id2name(SymId(data.toInt()))); break; case P_TYPE::BARLINE_TYPE: tag(name, BarLine::barLineTypeName(BarLineType(data.toInt()))); break; default: Q_ASSERT(false); } }
void Xml::tag(P_ID id, QVariant data, QVariant defaultData) { if (data == defaultData) return; const char* name = propertyName(id); if (name == 0) return; switch(propertyType(id)) { case T_BOOL: case T_SUBTYPE: case T_INT: case T_SPATIUM: case T_SP_REAL: case T_REAL: case T_SCALE: case T_POINT: case T_SIZE: case T_COLOR: tag(name, data); break; case T_DIRECTION: switch(MScore::Direction(data.toInt())) { case MScore::UP: tag(name, QVariant("up")); break; case MScore::DOWN: tag(name, QVariant("down")); break; case MScore::AUTO: break; } break; case T_DIRECTION_H: switch(MScore::DirectionH(data.toInt())) { case MScore::DH_LEFT: tag(name, QVariant("left")); break; case MScore::DH_RIGHT: tag(name, QVariant("right")); break; case MScore::DH_AUTO: break; } break; case T_LAYOUT_BREAK: switch(LayoutBreak::LayoutBreakType(data.toInt())) { case LayoutBreak::LINE: tag(name, QVariant("line")); break; case LayoutBreak::PAGE: tag(name, QVariant("page")); break; case LayoutBreak::SECTION: tag(name, QVariant("section")); break; } break; case T_VALUE_TYPE: switch(MScore::ValueType(data.toInt())) { case MScore::OFFSET_VAL: tag(name, QVariant("offset")); break; case MScore::USER_VAL: tag(name, QVariant("user")); break; } break; case T_PLACEMENT: switch(Element::Placement(data.toInt())) { case Element::ABOVE: tag(name, QVariant("above")); break; case Element::BELOW: tag(name, QVariant("below")); break; } break; case T_SYMID: tag(name, Sym::id2name(SymId(data.toInt()))); break; default: abort(); } }
void TrillSegment::draw(QPainter* painter) const { QRectF b2(symBbox(SymId::wiggleTrill)); qreal w2 = symWidth(SymId::wiggleTrill); qreal x2 = pos2().x(); QColor color; if (flag(ELEMENT_DROP_TARGET)) color = MScore::dropColor; else if (selected() && !(score() && score()->printing())) color = MScore::selectColor[0]; else if (!visible()) color = Qt::gray; else { color = trill()->curColor(); } painter->setPen(color); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { SymId sym = SymId::noSym; qreal x0 = 0.0, x1 = 0.0, y = 0.0; int n = 0; QRectF b1; switch(trill()->trillType()) { case Trill::TRILL_LINE: sym = SymId::ornamentTrill; b1 = symBbox(sym); x0 = -b1.x(); x1 = x0 + b1.width(); n = int(floor((x2-x1) / w2)); y = 0.0; break; #if 0 // TODO-smufl case Trill::UPPRALL_LINE: sym = SymId(upprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::DOWNPRALL_LINE: sym = SymId(downprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::PRALLPRALL_LINE: sym = SymId(prallprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; #endif case Trill::PURE_LINE: sym = SymId::noSym; x0 = 0; x1 = 0; n = int(floor((x2-x1) / w2)); y = 0.0; } if (n <= 0) n = 1; if (sym != SymId::noSym) drawSymbol(sym, painter, QPointF(x0, y)); drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n); } else { qreal x1 = 0.0; int n = int(floor((x2-x1) / w2)); drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n); } }
void SymbolDialog::createSymbolPalette() { sp = new Palette(); for (int i = 0; i < lastSym; ++i) sp->append(SymId(i)); }