void ElementLayout::writeProperties(Xml& xml) const { if (_align & ALIGN_HCENTER) xml.tag("halign", "center"); else if (_align & ALIGN_RIGHT) xml.tag("halign", "right"); else xml.tag("halign", "left"); if (_align & ALIGN_BOTTOM) xml.tag("valign", "bottom"); else if (_align & ALIGN_VCENTER) xml.tag("valign", "center"); else if (_align & ALIGN_BASELINE) xml.tag("valign", "baseline"); else xml.tag("valign", "top"); if (!_offset.isNull()) { QPointF pt(_offset); if (offsetType() == OffsetType::ABS) pt *= INCH; xml.tag("xoffset", pt.x()); // save in spatium or metric mm xml.tag("yoffset", pt.y()); } const char* p = 0; switch(_offsetType) { case OffsetType::SPATIUM: p = "spatium"; break; case OffsetType::ABS: p = "absolute"; break; } xml.tag("offsetType", p); }
void StaffText::layout() { if (autoplace()) setUserOff(QPointF()); // TODO: add above/below offset properties QPointF p(offset() * (offsetType() == OffsetType::SPATIUM ? spatium() : DPI)); if (placement() == Element::Placement::BELOW) p.ry() = - p.ry() + lineHeight(); setPos(p); Text::layout1(); if (!parent()) // palette & clone trick return; if (autoplace() && segment()) { qreal minDistance = score()->styleP(StyleIdx::dynamicsMinDistance); // TODO Shape s1 = segment()->measure()->staffShape(staffIdx()); Shape s2 = shape().translated(segment()->pos() + pos()); if (placement() == Element::Placement::ABOVE) { qreal d = s2.minVerticalDistance(s1); if (d > -minDistance) rUserYoffset() = -d - minDistance; } else { qreal d = s1.minVerticalDistance(s2); if (d > -minDistance) rUserYoffset() = d + minDistance; } } adjustReadPos(); }
void ElementLayout::writeProperties(Xml& xml, const ElementLayout& l) const { if ((l._align & AlignmentFlags::HMASK) != (_align & AlignmentFlags::HMASK)) { const char* p; if (_align & AlignmentFlags::HCENTER) p = "center"; else if (_align & AlignmentFlags::RIGHT) p = "right"; else p = "left"; xml.tag("halign", p); } if ((l._align & AlignmentFlags::VMASK) != (_align & AlignmentFlags::VMASK)) { const char* p; if (_align & AlignmentFlags::BOTTOM) p = "bottom"; else if (_align & AlignmentFlags::VCENTER) p = "center"; else if (_align & AlignmentFlags::BASELINE) p = "baseline"; else p = "top"; xml.tag("valign", p); } if (l._offset != _offset) { QPointF pt(_offset); if (offsetType() == OffsetType::ABS) pt *= INCH; xml.tag("xoffset", pt.x()); // save in spatium or metric mm xml.tag("yoffset", pt.y()); } if (_offsetType != l._offsetType) { const char* p = 0; switch(_offsetType) { case OffsetType::SPATIUM: p = "spatium"; break; case OffsetType::ABS: p = "absolute"; break; } xml.tag("offsetType", p); } }
bool TextStyleData::operator!=(const TextStyleData& s) const { return s.name != name || s.family != family || s.size != size || s.bold != bold || s.italic != italic || s.underline != underline || s.hasFrame != hasFrame || s.sizeIsSpatiumDependent != sizeIsSpatiumDependent || s.frameWidth != frameWidth || s.paddingWidth != paddingWidth || s.frameRound != frameRound || s.frameColor != frameColor || s.circle != circle || s.systemFlag != systemFlag || s.foregroundColor != foregroundColor || s.backgroundColor != backgroundColor || s.align() != align() || s.offset() != offset() || s.offsetType() != offsetType() ; }
bool ElementLayout::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "halign") { const QString& val(e.readElementText()); _align &= ~(ALIGN_HCENTER | ALIGN_RIGHT); if (val == "center") _align |= ALIGN_HCENTER; else if (val == "right") _align |= ALIGN_RIGHT; else if (val == "left") ; else qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val)); } else if (tag == "valign") { const QString& val(e.readElementText()); _align &= ~(ALIGN_VCENTER | ALIGN_BOTTOM | ALIGN_BASELINE); if (val == "center") _align |= ALIGN_VCENTER; else if (val == "bottom") _align |= ALIGN_BOTTOM; else if (val == "baseline") _align |= ALIGN_BASELINE; else if (val == "top") ; else qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val)); } else if (tag == "xoffset") { qreal xo = e.readDouble(); if (offsetType() == OffsetType::ABS) xo /= INCH; setXoff(xo); } else if (tag == "yoffset") { qreal yo = e.readDouble(); if (offsetType() == OffsetType::ABS) yo /= INCH; setYoff(yo); } else if (tag == "rxoffset") // obsolete e.readDouble(); else if (tag == "ryoffset") // obsolete e.readDouble(); else if (tag == "offsetType") { const QString& val(e.readElementText()); OffsetType ot = OffsetType::ABS; if (val == "spatium" || val == "1") ot = OffsetType::SPATIUM; if (ot != offsetType()) { setOffsetType(ot); if (ot == OffsetType::ABS) _offset /= INCH; // convert spatium -> inch else _offset *= INCH; // convert inch -> spatium } } else return false; return true; }
bool ElementLayout::readProperties(XmlReader* r) { MString8 tag = r->tag(); QString val; int i; qreal d; if (r->readString("halign", &val)) { _align &= ~(ALIGN_HCENTER | ALIGN_RIGHT); if (val == "center") _align |= ALIGN_HCENTER; else if (val == "right") _align |= ALIGN_RIGHT; else if (val == "left") { ; } } else if (r->readString("valign", &val)) { _align &= ~(ALIGN_VCENTER | ALIGN_BOTTOM | ALIGN_BASELINE); if (val == "center") _align |= ALIGN_VCENTER; else if (val == "bottom") _align |= ALIGN_BOTTOM; else if (val == "baseline") _align |= ALIGN_BASELINE; else if (val == "top") { ; } } else if (r->readReal("xoffset", &d)) { if (offsetType() == OFFSET_ABS) d /= INCH; setXoff(d); } else if (r->readReal("yoffset", &d)) { if (offsetType() == OFFSET_ABS) d /= INCH; setYoff(d); } else if (r->readReal("rxoffset", &d)) setRxoff(d); else if (r->readReal("ryoffset", &d)) setRyoff(val.toDouble()); else if (r->readInt("offsetType", &i)) { OffsetType ot = (OffsetType)i; if (ot != offsetType()) { setOffsetType(ot); if (ot == OFFSET_ABS) { _xoff /= INCH; _yoff /= INCH; } else { _xoff *= INCH; _yoff *= INCH; } } } else return false; return true; }