diff --git a/libmscore/chordrest.cpp b/libmscore/chordrest.cpp index 1549ef8b1767..b46531052736 100644 --- a/libmscore/chordrest.cpp +++ b/libmscore/chordrest.cpp @@ -717,8 +717,7 @@ Element* ChordRest::drop(const DropData& data) TempoText* tt = static_cast(e); tt->setParent(segment()); int st = tt->textStyleType(); - if (st != TEXT_STYLE_UNKNOWN) - tt->setTextStyleType(st); + tt->setTextStyleType(st); score()->undoAddElement(tt); } return e; diff --git a/libmscore/dynamic.cpp b/libmscore/dynamic.cpp index 5773984085f4..199143a2e5b1 100644 --- a/libmscore/dynamic.cpp +++ b/libmscore/dynamic.cpp @@ -274,9 +274,8 @@ void Dynamic::startEdit(MuseScoreView* v, const QPointF& p) void Dynamic::endEdit() { Text::endEdit(); - if (!styled() || text() != QString::fromUtf8(dynList[_dynamicType].text)) { + if (text() != QString::fromUtf8(dynList[_dynamicType].text)) _dynamicType = DYNAMIC_OTHER; - } } //--------------------------------------------------------- diff --git a/libmscore/elementlayout.cpp b/libmscore/elementlayout.cpp index 1cd9cb467ecb..02e8e31f81a2 100644 --- a/libmscore/elementlayout.cpp +++ b/libmscore/elementlayout.cpp @@ -75,6 +75,55 @@ void ElementLayout::layout(Element* e) const e->setPos(p + o); } +//--------------------------------------------------------- +// writeProperties +// writout only differences to l +//--------------------------------------------------------- + +void ElementLayout::writeProperties(Xml& xml, const ElementLayout& l) const + { + if ((l._align & ALIGN_HMASK) != (_align & ALIGN_HMASK)) { + const char* p; + if (_align & ALIGN_HCENTER) + p = "center"; + else if (_align & ALIGN_RIGHT) + p = "right"; + else + p = "left"; + xml.tag("halign", p); + } + + if ((l._align & ALIGN_VMASK) != (_align & ALIGN_VMASK)) { + const char* p; + if (_align & ALIGN_BOTTOM) + p = "bottom"; + else if (_align & ALIGN_VCENTER) + p = "center"; + else if (_align & ALIGN_BASELINE) + p = "baseline"; + else + p = "top"; + xml.tag("valign", p); + } + + if (l._offset != _offset) { + QPointF pt(_offset); + if (offsetType() == OFFSET_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 OFFSET_SPATIUM: p = "spatium"; break; + case OFFSET_ABS: p = "absolute"; break; + } + xml.tag("offsetType", p); + } + } + //--------------------------------------------------------- // writeProperties //--------------------------------------------------------- diff --git a/libmscore/elementlayout.h b/libmscore/elementlayout.h index 0ca638c31e73..ac82c6bbb16e 100644 --- a/libmscore/elementlayout.h +++ b/libmscore/elementlayout.h @@ -49,6 +49,7 @@ class ElementLayout { void setOffsetType(OffsetType val) { _offsetType = val; } void layout(Element*) const; void writeProperties(Xml& xml) const; + void writeProperties(Xml& xml, const ElementLayout&) const; bool readProperties(XmlReader& e); }; diff --git a/libmscore/figuredbass.cpp b/libmscore/figuredbass.cpp index 6ab174e5c072..79717e18ee89 100644 --- a/libmscore/figuredbass.cpp +++ b/libmscore/figuredbass.cpp @@ -937,7 +937,7 @@ void FiguredBass::write(Xml& xml) const xml.tag("ticks", ticks()); // if unparseable items or non-standard style, write full text data if (items.size() < 1 || textStyleType() != TEXT_STYLE_FIGURED_BASS) { - if (items.size() < 1 || textStyleType() == TEXT_STYLE_UNSTYLED) + if (items.size() < 1) Text::writeProperties(xml, true); else // if all items parsed and not unstled, we simnply have a special style: write it @@ -945,8 +945,7 @@ void FiguredBass::write(Xml& xml) const } foreach(FiguredBassItem item, items) item.write(xml); - if (textStyleType() != TEXT_STYLE_UNSTYLED) - Element::writeProperties(xml); + Element::writeProperties(xml); xml.etag(); } @@ -980,9 +979,8 @@ void FiguredBass::read(XmlReader& e) else if (!Text::readProperties(e)) e.unknown(); } - // if items could be parsed and text is styled, set normalized text - if(items.size() > 0 && textStyleType() != TEXT_STYLE_UNSTYLED) - setText(normalizedText); // this is the text to show while editing + // if items could be parsed set normalized text + setText(normalizedText); // this is the text to show while editing } //--------------------------------------------------------- @@ -1197,7 +1195,7 @@ void FiguredBass::endEdit() normalizedText.append(pItem->normalizedText()); } // if all items parsed and text is styled, replaced entered text with normalized text - if(items.size() > 0 && textStyleType() != TEXT_STYLE_UNSTYLED) { + if (items.size()) { setText(normalizedText); layout(); } diff --git a/libmscore/harmony.cpp b/libmscore/harmony.cpp index 7e15e9622a88..e29bf02b711f 100644 --- a/libmscore/harmony.cpp +++ b/libmscore/harmony.cpp @@ -137,7 +137,6 @@ Harmony::Harmony(Score* s) : Text(s) { setTextStyleType(TEXT_STYLE_HARMONY); - setUnstyled(); _rootTpc = INVALID_TPC; _baseTpc = INVALID_TPC; _id = -1; diff --git a/libmscore/mscore.h b/libmscore/mscore.h index 197d5f9e6456..c6ebda796e97 100644 --- a/libmscore/mscore.h +++ b/libmscore/mscore.h @@ -253,9 +253,6 @@ const int STAFF_GROUP_MAX = TAB_STAFF_GROUP + 1; // out of enum to avoid co //--------------------------------------------------------- enum { - TEXT_STYLE_UNSTYLED = -1, - TEXT_STYLE_UNKNOWN = -2, - TEXT_STYLE_DEFAULT = 0, TEXT_STYLE_TITLE, TEXT_STYLE_SUBTITLE, diff --git a/libmscore/note.cpp b/libmscore/note.cpp index 8c90284c8244..4760900aff70 100644 --- a/libmscore/note.cpp +++ b/libmscore/note.cpp @@ -1096,8 +1096,7 @@ Element* Note::drop(const DropData& data) // set style Fingering* f = static_cast(e); int st = f->textStyleType(); - if (st != TEXT_STYLE_UNKNOWN) - f->setTextStyleType(st); + f->setTextStyleType(st); } return e; diff --git a/libmscore/style.cpp b/libmscore/style.cpp index dd3573c8f3de..271a52e36fa1 100644 --- a/libmscore/style.cpp +++ b/libmscore/style.cpp @@ -779,6 +779,50 @@ void TextStyleData::writeProperties(Xml& xml) const xml.tag("systemFlag", systemFlag); } +//--------------------------------------------------------- +// writeProperties +// write only changes to the reference r +//--------------------------------------------------------- + +void TextStyleData::writeProperties(Xml& xml, const TextStyleData& r) const + { + ElementLayout::writeProperties(xml, r); + if (!name.isEmpty() && name != r.name) + xml.tag("name", name); + if (family != r.family) + xml.tag("family", family); + if (size != r.size) + xml.tag("size", size); + if (bold != r.bold) + xml.tag("bold", bold); + if (italic != r.italic) + xml.tag("italic", italic); + if (underline != r.underline) + xml.tag("underline", underline); + if (sizeIsSpatiumDependent != r.sizeIsSpatiumDependent) + xml.tag("sizeIsSpatiumDependent", sizeIsSpatiumDependent); + if (foregroundColor != r.foregroundColor) + xml.tag("foregroundColor", foregroundColor); + if (backgroundColor != r.backgroundColor) + xml.tag("backgroundColor", backgroundColor); + if (hasFrame != r.hasFrame) + xml.tag("frame", hasFrame); + if (hasFrame) { + if (frameWidth.val() != r.frameWidth.val()) + xml.tag("frameWidthS", frameWidth.val()); + if (paddingWidth.val() != r.paddingWidth.val()) + xml.tag("paddingWidthS", paddingWidth.val()); + if (frameRound != r.frameRound) + xml.tag("frameRound", frameRound); + if (frameColor != r.frameColor) + xml.tag("frameColor", frameColor); + if (circle != r.circle) + xml.tag("circle", circle); + } + if (systemFlag != r.systemFlag) + xml.tag("systemFlag", systemFlag); + } + //--------------------------------------------------------- // read //--------------------------------------------------------- @@ -830,7 +874,7 @@ bool TextStyleData::readProperties(XmlReader& e) hasFrame = true; frameWidth = Spatium(e.readDouble()); } - else if (tag == "frame") // obsolete + else if (tag == "frame") hasFrame = e.readInt(); else if (tag == "paddingWidth") // obsolete paddingWidthMM = e.readDouble(); @@ -1151,7 +1195,7 @@ int StyleData::textStyleType(const QString& name) const if (name == "Dynamics2") return TEXT_STYLE_DYNAMICS; qDebug("TextStyleType <%s> not found", qPrintable(name)); - return TEXT_STYLE_UNKNOWN; + return TEXT_STYLE_DEFAULT; } //--------------------------------------------------------- @@ -1226,6 +1270,7 @@ QFontMetricsF TextStyle::fontMetrics(qreal space) const { return d->fontMetrics bool TextStyle::operator!=(const TextStyle& s) const { return d->operator!=(*s.d); } void TextStyle::layout(Element* e) const { d->layout(e); } void TextStyle::writeProperties(Xml& xml) const { d->writeProperties(xml); } +void TextStyle::writeProperties(Xml& xml, const TextStyle& r) const { d->writeProperties(xml, *r.d); } bool TextStyle::readProperties(XmlReader& v) { return d->readProperties(v); } //--------------------------------------------------------- diff --git a/libmscore/style.h b/libmscore/style.h index e7fa9d67352e..837306d32a53 100644 --- a/libmscore/style.h +++ b/libmscore/style.h @@ -109,6 +109,7 @@ class TextStyle { Hidden hidden() const { return _hidden; } void write(Xml& xml) const; void writeProperties(Xml& xml) const; + void writeProperties(Xml& xml, const TextStyle&) const; void read(XmlReader& v); bool readProperties(XmlReader& v); QFont font(qreal spatium) const; diff --git a/libmscore/style_p.h b/libmscore/style_p.h index e02c149dcf98..a9d34a4b4e6f 100644 --- a/libmscore/style_p.h +++ b/libmscore/style_p.h @@ -69,6 +69,7 @@ class TextStyleData : public QSharedData, public ElementLayout { void write(Xml&) const; void writeProperties(Xml& xml) const; + void writeProperties(Xml& xml, const TextStyleData&) const; void read(XmlReader&); bool readProperties(XmlReader& v); diff --git a/libmscore/text.cpp b/libmscore/text.cpp index 93595ceb6889..59e626eed539 100644 --- a/libmscore/text.cpp +++ b/libmscore/text.cpp @@ -1737,10 +1737,10 @@ void Text::read(XmlReader& e) void Text::writeProperties(Xml& xml, bool writeText, bool writeStyle) const { Element::writeProperties(xml); - if (xml.clipboardmode || styled()) + if (writeStyle) { xml.tag("style", textStyle().name()); - if ((xml.clipboardmode || !styled()) && writeStyle) - _textStyle.writeProperties(xml); + _textStyle.writeProperties(xml, textStyle()); + } if (writeText) xml.writeXml("text", text()); } @@ -1761,7 +1761,6 @@ bool Text::readProperties(XmlReader& e) if (ok) { // obsolete old text styles switch (i) { - case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; @@ -1802,20 +1801,14 @@ bool Text::readProperties(XmlReader& e) case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); - i = TEXT_STYLE_UNSTYLED; + i = TEXT_STYLE_DEFAULT; break; } st = i; } else st = score()->style()->textStyleType(val); - - if (st == TEXT_STYLE_UNSTYLED) - setUnstyled(); - else if (st == TEXT_STYLE_UNKNOWN) - _styleIndex = st; - else - setTextStyleType(st); + setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text e.skipCurrentElement(); // _styleName = val; @@ -1869,8 +1862,7 @@ bool Text::readProperties(XmlReader& e) void Text::textStyleChanged() { - if (_styleIndex != TEXT_STYLE_UNKNOWN && _styleIndex != TEXT_STYLE_UNSTYLED) - setTextStyle(score()->textStyle(_styleIndex)); + setTextStyle(score()->textStyle(_styleIndex)); score()->setLayoutAll(true); } @@ -1881,8 +1873,7 @@ void Text::textStyleChanged() void Text::setTextStyleType(int st) { _styleIndex = st; - if (st != TEXT_STYLE_UNKNOWN && st != TEXT_STYLE_UNSTYLED) - setTextStyle(score()->textStyle(st)); + setTextStyle(score()->textStyle(st)); } //--------------------------------------------------------- diff --git a/libmscore/text.h b/libmscore/text.h index d3595a4e83aa..451cae98d644 100644 --- a/libmscore/text.h +++ b/libmscore/text.h @@ -170,7 +170,7 @@ class Text : public Element { QString _text; QList _layout; QRectF frame; // calculated in layout() - int _styleIndex; // set to TEXT_STYLE_UNTEXT if not styled + int _styleIndex; bool _layoutToParentWidth; bool _editMode; @@ -207,20 +207,18 @@ class Text : public Element { virtual void draw(QPainter*) const override; - bool editMode() const { return _editMode; } - void setEditMode(bool val) { _editMode = val; } + bool editMode() const { return _editMode; } + void setEditMode(bool val) { _editMode = val; } void setTextStyle(const TextStyle& st) { _textStyle = st; } const TextStyle& textStyle() const { return _textStyle; } TextStyle& textStyle() { return _textStyle; } - void setUnstyled() { _styleIndex = TEXT_STYLE_UNSTYLED; } - bool styled() const { return _styleIndex != TEXT_STYLE_UNSTYLED; } - int textStyleType() const { return _styleIndex; } + int textStyleType() const { return _styleIndex; } void setTextStyleType(int); void setPlainText(const QString&); void setText(const QString&); - QString text() const { return _text; } + QString text() const { return _text; } void insertText(const QString&); virtual void layout() override; @@ -262,7 +260,6 @@ class Text : public Element { void writeProperties(Xml&, bool = true, bool = true) const; bool readProperties(XmlReader&); - void spellCheckUnderline(bool) {} virtual void textStyleChanged(); diff --git a/libmscore/textline.cpp b/libmscore/textline.cpp index d8bf4530b36a..a3ff57cea8de 100644 --- a/libmscore/textline.cpp +++ b/libmscore/textline.cpp @@ -175,10 +175,7 @@ void TextLineSegment::layout1() _text->setParent(this); } else { - if (tl->_beginText->styled()) - _text->setTextStyleType(tl->_beginText->textStyleType()); - else - _text->setTextStyle(tl->_beginText->textStyle()); + _text->setTextStyleType(tl->_beginText->textStyleType()); _text->setText(tl->_beginText->text()); } } @@ -196,10 +193,7 @@ void TextLineSegment::layout1() _text->setParent(this); } else { - if (tl->_beginText->styled()) - _text->setTextStyleType(tl->_beginText->textStyleType()); - else - _text->setTextStyle(tl->_beginText->textStyle()); + _text->setTextStyleType(tl->_beginText->textStyleType()); _text->setText(tl->_continueText->text()); } } diff --git a/libmscore/undo.cpp b/libmscore/undo.cpp index a9f6cca321e0..9dd6534e95a8 100644 --- a/libmscore/undo.cpp +++ b/libmscore/undo.cpp @@ -802,14 +802,7 @@ void Score::undoChangeInvisible(Element* e, bool v) void Score::undoAddElement(Element* element) { - if (element->isText()) { - Text* text = static_cast(element); - if (text->textStyleType() == TEXT_STYLE_UNKNOWN) { - style()->addTextStyle(text->textStyle()); - text->setTextStyleType(style()->textStyleType(text->textStyle().name())); - } - } - QList staffList; + QList staffList; Staff* ostaff = element->staff(); Element::ElementType et = element->type(); @@ -2262,17 +2255,9 @@ void EditText::redo() void EditText::undoRedo() { - if (text->styled()) { - QString s = text->text(); - text->setText(oldText); - oldText = s; - } - else { - if (text->type() == Element::TEMPO_TEXT) { - TempoText* tt = static_cast(text); - tt->score()->setTempo(tt->segment(), tt->tempo()); - } - } + QString s = text->text(); + text->setText(oldText); + oldText = s; text->score()->setLayoutAll(true); } @@ -2461,7 +2446,7 @@ static void updateTextStyle(void* a, Element* e) QString s = *(QString*)a; if (e->isText()) { Text* text = static_cast(e); - if ((text->styled() || text->type() == Element::HARMONY) && text->textStyle().name() == s) { + if (text->textStyle().name() == s) { text->setTextStyle(text->score()->textStyle(s)); text->textStyleChanged(); } diff --git a/libmscore/xml.cpp b/libmscore/xml.cpp index 1e35eea62867..33f288db9293 100644 --- a/libmscore/xml.cpp +++ b/libmscore/xml.cpp @@ -242,34 +242,12 @@ bool compareProperty(void* val, void* defaultVal) Xml::Xml() { setCodec("UTF-8"); - stack.clear(); - curTick = 0; - curTrack = -1; - tickDiff = 0; - trackDiff = 0; - clipboardmode = false; - excerptmode = false; - tupletId = 1; - beamId = 1; - spannerId = 1; - writeOmr = true; } Xml::Xml(QIODevice* device) : QTextStream(device) { setCodec("UTF-8"); - stack.clear(); - curTick = 0; - curTrack = -1; - tickDiff = 0; - trackDiff = 0; - clipboardmode = false; - excerptmode = false; - tupletId = 1; - beamId = 1; - spannerId = 1; - writeOmr = true; } //--------------------------------------------------------- diff --git a/libmscore/xml.h b/libmscore/xml.h index 2400c2292a72..1dc95a2dcdca 100644 --- a/libmscore/xml.h +++ b/libmscore/xml.h @@ -115,18 +115,18 @@ class Xml : public QTextStream { QList _spanner; public: - int curTick; // used to optimize output - int curTrack; - int tickDiff; - int trackDiff; // saved track is curTrack-trackDiff - - bool clipboardmode; // used to modify write() behaviour - bool excerptmode; // true when writing a part - bool writeOmr; // false if writing into *.msc file - - int tupletId; - int beamId; - int spannerId; + int curTick = 0; // used to optimize output + int curTrack = -1; + int tickDiff = 0; + int trackDiff = 0; // saved track is curTrack-trackDiff + + bool clipboardmode = false; // used to modify write() behaviour + bool excerptmode = false; // true when writing a part + bool writeOmr = true; // false if writing into *.msc file + + int tupletId = 1; + int beamId = 1; + int spannerId = 1; QList& spanner() { return _spanner; } void addSpanner(Spanner* s) { _spanner.append(s); } diff --git a/mscore/debugger/debugger.cpp b/mscore/debugger/debugger.cpp index 0b7769807a3f..d1c5264f6976 100644 --- a/mscore/debugger/debugger.cpp +++ b/mscore/debugger/debugger.cpp @@ -1356,7 +1356,6 @@ void TextView::setElement(Element* e) tb.yoffset->setValue(ts.offset().y()); tb.offsetType->setCurrentIndex(int(ts.offsetType())); tb.textStyle->setCurrentIndex(te->textStyleType()); - tb.styled->setChecked(te->styled()); tb.layoutToParentWidth->setChecked(te->layoutToParentWidth()); } @@ -1393,7 +1392,6 @@ void HarmonyView::setElement(Element* e) tb.yoffset->setValue(ts.offset().y()); tb.offsetType->setCurrentIndex(int(ts.offsetType())); //TODO tb.textStyle->setCurrentIndex(ts.textStyleType()); - tb.styled->setChecked(harmony->styled()); tb.layoutToParentWidth->setChecked(harmony->layoutToParentWidth()); hb.tbboxx->setValue(harmony->bboxtight().x()); @@ -1580,7 +1578,6 @@ void DynamicView::setElement(Element* e) tb.yoffset->setValue(ts.offset().y()); tb.offsetType->setCurrentIndex(int(ts.offsetType())); //TODO tb.textStyle->setCurrentIndex(dynamic->textStyleType()); - tb.styled->setChecked(dynamic->styled()); tb.layoutToParentWidth->setChecked(dynamic->layoutToParentWidth()); ShowElementBase::setElement(e); diff --git a/mscore/exportxml.cpp b/mscore/exportxml.cpp index b33f85fce359..e2c3838e5eb5 100644 --- a/mscore/exportxml.cpp +++ b/mscore/exportxml.cpp @@ -1006,8 +1006,7 @@ void ExportMusicXml::credits(Xml& xml) if (element->type() == Element::TEXT) { const Text* text = (const Text*)element; bool mustPrint = true; - if (mustPrint) qDebug("text styled %d style %d(%s) '%s' at %f,%f", - text->styled(), + if (mustPrint) qDebug("text style %d(%s) '%s' at %f,%f", text->textStyleType(), qPrintable(text->textStyle().name()), qPrintable(text->text()), @@ -1050,19 +1049,17 @@ void ExportMusicXml::credits(Xml& xml) // MusicXML credit-words are untyped and simple list position and font info. // TODO: these parameters should be extracted from text layout and style // instead of relying on the style name - if (text->styled()) { - QString styleName = text->textStyle().name(); - if (styleName == "Title") - creditWords(xml, w / 2, ty, fs, "center", "top", text->text()); - else if (styleName == "Subtitle") - creditWords(xml, w / 2, ty, fs, "center", "top", text->text()); - else if (styleName == "Composer") - creditWords(xml, w - rm, ty, fs, "right", "top", text->text()); - else if (styleName == "Lyricist") - creditWords(xml, lm, ty, fs, "left", "top", text->text()); - else - qDebug("credits: text style %s not supported", qPrintable(styleName)); - } + QString styleName = text->textStyle().name(); + if (styleName == "Title") + creditWords(xml, w / 2, ty, fs, "center", "top", text->text()); + else if (styleName == "Subtitle") + creditWords(xml, w / 2, ty, fs, "center", "top", text->text()); + else if (styleName == "Composer") + creditWords(xml, w - rm, ty, fs, "right", "top", text->text()); + else if (styleName == "Lyricist") + creditWords(xml, lm, ty, fs, "left", "top", text->text()); + else + qDebug("credits: text style %s not supported", qPrintable(styleName)); } } } diff --git a/mscore/inspector/inspector.cpp b/mscore/inspector/inspector.cpp index 55433bcc96b9..c9ef7433c726 100644 --- a/mscore/inspector/inspector.cpp +++ b/mscore/inspector/inspector.cpp @@ -600,7 +600,6 @@ void InspectorDynamic::setElement() t.style->blockSignals(true); t.style->clear(); - t.style->addItem(tr("unstyled"), TEXT_STYLE_UNSTYLED); const QList& ts = score->style()->textStyles(); int n = ts.size(); for (int i = 0; i < n; ++i) { diff --git a/mscore/lineproperties.cpp b/mscore/lineproperties.cpp index d5dd6b307dad..9ebd020bd106 100644 --- a/mscore/lineproperties.cpp +++ b/mscore/lineproperties.cpp @@ -148,13 +148,11 @@ void LineProperties::accept() Text* t = tl->beginTextElement(); if (t) { Text* ot = otl->beginTextElement(); - if (t->styled() && t->textStyleType() != ot->textStyleType()) + if (t->textStyleType() != ot->textStyleType()) ot->undoChangeProperty(P_TEXT_STYLE_TYPE, t->textStyleType()); - else { - ot->undoChangeProperty(P_TEXT_STYLE_TYPE, TEXT_STYLE_UNSTYLED); - if (t->textStyle() != ot->textStyle()) - ot->undoChangeProperty(P_TEXT_STYLE, QVariant::fromValue(t->textStyle())); - } + // TODO: only save style difference + if (t->textStyle() != ot->textStyle()) + ot->undoChangeProperty(P_TEXT_STYLE, QVariant::fromValue(t->textStyle())); } // ... diff --git a/mscore/propertymenu.cpp b/mscore/propertymenu.cpp index d470dac9ec5b..8743d91af77c 100644 --- a/mscore/propertymenu.cpp +++ b/mscore/propertymenu.cpp @@ -117,8 +117,7 @@ void ScoreView::genPropertyMenuText(Element* e, QMenu* popup) } popup->addMenu(menuLayer); } - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } @@ -209,8 +208,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Text Properties..."))->setData("d-props"); } else if (e->type() == Element::TEXTLINE_SEGMENT @@ -239,14 +237,11 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) } else if (e->type() == Element::HARMONY) { genPropertyMenu1(e, popup); - // chord symbols always use text style - // even though they are marked unstyled popup->addAction(tr("Text Style..."))->setData("text-style"); } else if (e->type() == Element::TEMPO_TEXT) { genPropertyMenu1(e, popup); - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == Element::KEYSIG) { @@ -264,8 +259,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) } } else if (e->type() == Element::STAFF_STATE && static_cast(e)->staffStateType() == STAFF_STATE_INSTRUMENT) { - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props"); } else if (e->type() == Element::SLUR_SEGMENT) { @@ -300,8 +294,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) } else if (e->type() == Element::INSTRUMENT_CHANGE) { genPropertyMenu1(e, popup); - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Change Instrument..."))->setData("ch-instr"); } else if (e->type() == Element::FRET_DIAGRAM) { @@ -317,8 +310,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) popup->addAction(tr("Glissando Properties..."))->setData("gliss-props"); } else if (e->type() == Element::INSTRUMENT_NAME) { - if (static_cast(e)->styled()) - popup->addAction(tr("Text Style..."))->setData("text-style"); + popup->addAction(tr("Text Style..."))->setData("text-style"); popup->addAction(tr("Staff Properties..."))->setData("staff-props"); } else @@ -431,12 +423,6 @@ void ScoreView::elementPropertyAction(const QString& cmd, Element* e) TextLineSegment* vs = static_cast(e); LineProperties lp(vs->textLine()); lp.exec(); -#if 0 - if (lp.exec()) { - foreach(SpannerSegment* l, vs->textLine()->spannerSegments()) - static_cast(l)->clearText(); - } -#endif } else if (cmd == "tr-props") { TremoloBar* tb = static_cast(e); @@ -508,34 +494,15 @@ void ScoreView::elementPropertyAction(const QString& cmd, Element* e) if (!sl.contains(ot)) sl.append(ot); QList selectedElements; - foreach(Element* e, sl) { + for (auto e : sl) { if (e->type() != ot->type()) continue; - - Text* t = static_cast(e); - Text* tt = t->clone(); - - - if (nText->styled() != ot->styled() || nText->styled()) { - if (nText->styled()) - tt->setTextStyleType(nText->textStyleType()); - else { - tt->setUnstyled(); - } - } - - if (!nText->styled() && (nText->textStyle() != ot->textStyle())) { - tt->setTextStyle(nText->textStyle()); - tt->textStyleChanged(); - } - - if (t->selected()) - selectedElements.append(tt); - score()->undoChangeElement(t, tt); + Text* t = static_cast(e); + if (t->textStyleType() != nText->textStyleType()) + t->undoChangeProperty(P_TEXT_STYLE_TYPE, nText->textStyleType()); + if (t->textStyle() != nText->textStyle()) + t->undoChangeProperty(P_TEXT_STYLE, QVariant::fromValue(nText->textStyle())); } - score()->select(0, SELECT_SINGLE, 0); - foreach(Element* e, selectedElements) - score()->select(e, SELECT_ADD, 0); } delete nText; } diff --git a/mscore/textprop.cpp b/mscore/textprop.cpp index 655f51901cec..8ebe9f03bd27 100644 --- a/mscore/textprop.cpp +++ b/mscore/textprop.cpp @@ -61,8 +61,7 @@ TextProp::TextProp(QWidget* parent) g3->addButton(boxButton); connect(mmUnit, SIGNAL(toggled(bool)), SLOT(mmToggled(bool))); - connect(styledGroup, SIGNAL(toggled(bool)), SLOT(styledToggled(bool))); - connect(unstyledGroup, SIGNAL(toggled(bool)), SLOT(unstyledToggled(bool))); + connect(resetToStyle, SIGNAL(clicked()), SLOT(doResetToTextStyle())); } //--------------------------------------------------------- @@ -71,22 +70,18 @@ TextProp::TextProp(QWidget* parent) void TextProp::setScore(bool onlyStyle, Score* score) { - if (onlyStyle) { - styledGroup->setVisible(false); - unstyledGroup->setCheckable(false); - unstyledGroup->setTitle(tr("Text Style")); - } - else { - // textGroup->setVisible(false); - styles->clear(); - - const QList& scoreStyles = score->style()->textStyles(); - int n = scoreStyles.size(); - for (int i = 0; i < n; ++i) { - // if style not hidden in this context, add to combo with index in score style list as userData - if ( !(scoreStyles.at(i).hidden() & TextStyle::HIDE_IN_LISTS) ) - styles->addItem(scoreStyles.at(i).name(), i); - } + _score = score; + resetToStyle->setVisible(!onlyStyle); + styles->setVisible(!onlyStyle); + styleLabel->setVisible(!onlyStyle); + styles->clear(); + + const QList& scoreStyles = score->style()->textStyles(); + int n = scoreStyles.size(); + for (int i = 0; i < n; ++i) { + // if style not hidden in this context, add to combo with index in score style list as userData + if ( !(scoreStyles.at(i).hidden() & TextStyle::HIDE_IN_LISTS) ) + styles->addItem(scoreStyles.at(i).name(), i); } } @@ -103,27 +98,16 @@ void TextProp::mmToggled(bool val) } //--------------------------------------------------------- -// setStyled -//--------------------------------------------------------- - -void TextProp::setStyled(bool val) - { - styledGroup->setChecked(val); - unstyledGroup->setChecked(!val); - } - -//--------------------------------------------------------- -// setTextStyleType +// setStyle //--------------------------------------------------------- -void TextProp::setTextStyleType(int st) +void TextProp::setStyle(int st, const TextStyle& ts) { - if (st == TEXT_STYLE_UNKNOWN || st == TEXT_STYLE_UNSTYLED) - st = TEXT_STYLE_TITLE; st = styles->findData(st); // find a combo item with that style idx if (st < 0) // if none found... st = 0; // ...=> first combo item styles->setCurrentIndex(st); // set current combo item + setTextStyle(ts); } //--------------------------------------------------------- @@ -135,15 +119,6 @@ int TextProp::textStyleType() const return styles->itemData(styles->currentIndex()).toInt(); } -//--------------------------------------------------------- -// isStyled -//--------------------------------------------------------- - -bool TextProp::isStyled() const - { - return styledGroup->isChecked(); - } - //--------------------------------------------------------- // set //--------------------------------------------------------- @@ -251,21 +226,13 @@ TextStyle TextProp::textStyle() const } //--------------------------------------------------------- -// styledToggled +// doResetToTextStyle //--------------------------------------------------------- -void TextProp::styledToggled(bool val) +void TextProp::doResetToTextStyle() { - unstyledGroup->setChecked(!val); + setTextStyle(_score->textStyle(textStyleType())); } -//--------------------------------------------------------- -// unstyledToggled -//--------------------------------------------------------- - -void TextProp::unstyledToggled(bool val) - { - styledGroup->setChecked(!val); - } } diff --git a/mscore/textprop.h b/mscore/textprop.h index fe2c88d223f0..b27d388771e5 100644 --- a/mscore/textprop.h +++ b/mscore/textprop.h @@ -36,21 +36,21 @@ class Score; class TextProp : public QWidget, public Ui::TextProperties { Q_OBJECT + Score* _score; int curUnit; private slots: void mmToggled(bool); - void styledToggled(bool); - void unstyledToggled(bool); + void doResetToTextStyle(); public: TextProp(QWidget* parent = 0); void setScore(bool _onlyStyle, Score*); + void setTextStyle(const TextStyle&); + void setStyle(int styleType, const TextStyle&); + TextStyle textStyle() const; - bool isStyled() const; - void setStyled(bool val); - void setTextStyleType(int); int textStyleType() const; }; } diff --git a/mscore/textproperties.cpp b/mscore/textproperties.cpp index cf801e560cd4..ba4cc1fde6bc 100644 --- a/mscore/textproperties.cpp +++ b/mscore/textproperties.cpp @@ -70,12 +70,7 @@ TextProperties::TextProperties(Text* t, QWidget* parent) text = t; - tp->setTextStyle(t->textStyle()); - tp->setStyled(t->styled()); - if (t->styled()) - tp->setTextStyleType(t->textStyleType()); - else - tp->setTextStyleType(0); + tp->setStyle(t->textStyleType(), t->textStyle()); connect(bb, SIGNAL(accepted()), SLOT(accept())); connect(bb, SIGNAL(rejected()), SLOT(reject())); @@ -87,17 +82,8 @@ TextProperties::TextProperties(Text* t, QWidget* parent) void TextProperties::accept() { - if (tp->isStyled()) { - if (!text->styled() || (text->textStyleType() != tp->textStyleType())) { - text->setTextStyleType(tp->textStyleType()); - text->textStyleChanged(); - } - } - else { - text->setUnstyled(); - text->setTextStyle(tp->textStyle()); - } - + text->setTextStyleType(tp->textStyleType()); + text->setTextStyle(tp->textStyle()); QDialog::accept(); } } diff --git a/mscore/textproperties.ui b/mscore/textproperties.ui index a59a2264ea94..8ef9b5d5cdd4 100644 --- a/mscore/textproperties.ui +++ b/mscore/textproperties.ui @@ -7,7 +7,7 @@ 0 0 647 - 560 + 664 @@ -15,45 +15,44 @@ - - - Styled - - - true - - + + - - - - 0 - 0 - - - - Style: + + + 0 - - - - + + + + + 0 + 0 + + + + Style: + + + + + + + + + + + 0 + 0 + + + + Reset to Style + + + + - - - - - - - Unstyled - - - true - - - false - - diff --git a/mscore/texttools.cpp b/mscore/texttools.cpp index bed8514c381e..8fed0b2b5872 100644 --- a/mscore/texttools.cpp +++ b/mscore/texttools.cpp @@ -60,9 +60,6 @@ TextTools::TextTools(QWidget* parent) QToolBar* tb = new QToolBar(tr("Text Edit")); tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight)); - textStyles = new QComboBox; - tb->addWidget(textStyles); - showKeyboard = getAction("show-keys"); showKeyboard->setCheckable(true); tb->addAction(showKeyboard); @@ -81,44 +78,6 @@ TextTools::TextTools(QWidget* parent) tb->addSeparator(); -#if 0 - QActionGroup* ha = new QActionGroup(tb); - leftAlign = new QAction(*icons[textLeft_ICON], "", ha); - leftAlign->setToolTip(tr("align left")); - leftAlign->setCheckable(true); - leftAlign->setData(ALIGN_LEFT); - hcenterAlign = new QAction(*icons[textCenter_ICON], "", ha); - hcenterAlign->setToolTip(tr("align horizontal center")); - hcenterAlign->setCheckable(true); - hcenterAlign->setData(ALIGN_HCENTER); - rightAlign = new QAction(*icons[textRight_ICON], "", ha); - rightAlign->setToolTip(tr("align right")); - rightAlign->setCheckable(true); - rightAlign->setData(ALIGN_RIGHT); - tb->addActions(ha->actions()); - - QActionGroup* va = new QActionGroup(tb); - topAlign = new QAction(*icons[textTop_ICON], "", va); - topAlign->setToolTip(tr("align top")); - topAlign->setCheckable(true); - topAlign->setData(ALIGN_TOP); - - bottomAlign = new QAction(*icons[textBottom_ICON], "", va); - bottomAlign->setToolTip(tr("align bottom")); - bottomAlign->setCheckable(true); - bottomAlign->setData(ALIGN_BOTTOM); - - baselineAlign = new QAction(*icons[textBaseline_ICON], "", va); - baselineAlign->setToolTip(tr("align vertical baseline")); - baselineAlign->setCheckable(true); - baselineAlign->setData(ALIGN_BASELINE); - - vcenterAlign = new QAction(*icons[textVCenter_ICON], "", va); - vcenterAlign->setToolTip(tr("align vertical center")); - vcenterAlign->setCheckable(true); - vcenterAlign->setData(ALIGN_VCENTER); - tb->addActions(va->actions()); -#endif typefaceSubscript = tb->addAction(*icons[textSub_ICON], ""); typefaceSubscript->setToolTip(tr("subscript")); typefaceSubscript->setCheckable(true); @@ -127,18 +86,6 @@ TextTools::TextTools(QWidget* parent) typefaceSuperscript->setToolTip(tr("superscript")); typefaceSuperscript->setCheckable(true); -// unorderedList = tb->addAction(*icons[formatListUnordered_ICON], ""); -// unorderedList->setToolTip(tr("unordered list")); - -// orderedList = tb->addAction(*icons[formatListOrdered_ICON], ""); -// orderedList->setToolTip(tr("ordered list")); - -// indentMore = tb->addAction(*icons[formatIndentMore_ICON], ""); -// indentMore->setToolTip(tr("indent more")); - -// indentLess = tb->addAction(*icons[formatIndentLess_ICON], ""); -// indentLess->setToolTip(tr("indent less")); - tb->addSeparator(); typefaceFamily = new QFontComboBox(this); @@ -161,14 +108,7 @@ TextTools::TextTools(QWidget* parent) connect(typefaceSubscript, SIGNAL(triggered(bool)), SLOT(subscriptClicked(bool))); connect(typefaceSuperscript, SIGNAL(triggered(bool)), SLOT(superscriptClicked(bool))); connect(typefaceFamily, SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&))); -// connect(ha, SIGNAL(triggered(QAction*)), SLOT(setHalign(QAction*))); -// connect(va, SIGNAL(triggered(QAction*)), SLOT(setValign(QAction*))); connect(showKeyboard, SIGNAL(triggered(bool)), SLOT(showKeyboardClicked(bool))); - connect(textStyles, SIGNAL(currentIndexChanged(int)), SLOT(styleChanged(int))); -// connect(unorderedList, SIGNAL(triggered()), SLOT(unorderedListClicked())); -// connect(orderedList, SIGNAL(triggered()), SLOT(orderedListClicked())); -// connect(indentLess, SIGNAL(triggered()), SLOT(indentLessClicked())); -// connect(indentMore, SIGNAL(triggered()), SLOT(indentMoreClicked())); } //--------------------------------------------------------- @@ -177,46 +117,7 @@ TextTools::TextTools(QWidget* parent) void TextTools::setText(Text* te) { - textStyles->blockSignals(true); _textElement = te; - textStyles->clear(); - textStyles->addItem(tr("unstyled"), TEXT_STYLE_UNSTYLED); - - const QList& ts = te->score()->style()->textStyles(); - - int n = ts.size(); - for (int i = 0; i < n; ++i) { - if ( !(ts.at(i).hidden() & TextStyle::HIDE_IN_LISTS) ) - textStyles->addItem(ts.at(i).name(), i); - } - int comboIdx = 0; - if (te->styled()) { - int styleIdx = te->textStyleType(); - comboIdx = textStyles->findData(styleIdx); - if (comboIdx < 0) - comboIdx = 0; - } - textStyles->setCurrentIndex(comboIdx); - styleChanged(comboIdx); -#if 0 - Align align = _textElement->textStyle().align(); - if (align & ALIGN_HCENTER) - hcenterAlign->setChecked(true); - else if (align & ALIGN_RIGHT) - rightAlign->setChecked(true); - else - leftAlign->setChecked(true); - - if (align & ALIGN_BOTTOM) - bottomAlign->setChecked(true); - else if (align & ALIGN_BASELINE) - baselineAlign->setChecked(true); - else if (align & ALIGN_VCENTER) - vcenterAlign->setChecked(true); - else - topAlign->setChecked(true); -#endif - textStyles->blockSignals(false); } //--------------------------------------------------------- @@ -234,7 +135,6 @@ void TextTools::blockAllSignals(bool val) typefaceSuperscript->blockSignals(val); typefaceFamily->blockSignals(val); showKeyboard->blockSignals(val); - textStyles->blockSignals(val); } //--------------------------------------------------------- @@ -284,9 +184,7 @@ void TextTools::updateText() void TextTools::layoutText() { QRectF r(_textElement->canvasBoundingRect()); -// _textElement->layout(); _textElement->score()->setLayoutAll(true); -// _textElement->score()->addRefresh(_textElement->canvasBoundingRect() | r); _textElement->score()->end(); } @@ -372,30 +270,6 @@ void TextTools::italicClicked(bool val) updateText(); } -#if 0 -//--------------------------------------------------------- -// setHalign -//--------------------------------------------------------- - -void TextTools::setHalign(QAction* /*a*/) - { -//TODO _textElement->setCurHalign(a->data().toInt()); - updateTools(); - layoutText(); - } - -//--------------------------------------------------------- -// setValign -//--------------------------------------------------------- - -void TextTools::setValign(QAction* /*a*/) - { -//TODO _textElement->setAlign((_textElement->align() & ~ALIGN_VMASK) | Align(a->data().toInt())); - updateTools(); - layoutText(); - } -#endif - //--------------------------------------------------------- // subscriptClicked //--------------------------------------------------------- @@ -422,43 +296,6 @@ void TextTools::superscriptClicked(bool val) updateText(); } -//--------------------------------------------------------- -// styleChanged -//--------------------------------------------------------- - -void TextTools::styleChanged(int comboIdx) - { - blockAllSignals(true); - int styleIdx = textStyles->itemData(comboIdx).toInt(); - if (styleIdx < 0) - styleIdx = TEXT_STYLE_UNSTYLED; - bool unstyled = (styleIdx == TEXT_STYLE_UNSTYLED); - - if (unstyled) - _textElement->setUnstyled(); - else - _textElement->setTextStyleType(styleIdx); -#if 0 - typefaceSize->setEnabled(unstyled); - typefaceFamily->setEnabled(unstyled); -// typefaceBold->setEnabled(unstyled); - typefaceItalic->setEnabled(unstyled); - typefaceUnderline->setEnabled(unstyled); - typefaceSubscript->setEnabled(unstyled); - typefaceSuperscript->setEnabled(unstyled); - typefaceFamily->setEnabled(unstyled); - leftAlign->setEnabled(unstyled); - rightAlign->setEnabled(unstyled); -// hcenterAlign->setEnabled(unstyled); -// topAlign->setEnabled(unstyled); -// bottomAlign->setEnabled(unstyled); -// baselineAlign->setEnabled(unstyled); -// vcenterAlign->setEnabled(unstyled); -#endif - blockAllSignals(false); - updateText(); - } - //--------------------------------------------------------- // showKeyboardClicked //--------------------------------------------------------- diff --git a/mscore/texttools.h b/mscore/texttools.h index c9c64ccbf47f..a0b5b3e0b878 100644 --- a/mscore/texttools.h +++ b/mscore/texttools.h @@ -32,21 +32,9 @@ class TextTools : public QDockWidget { QAction* typefaceBold; QAction* typefaceItalic; QAction* typefaceUnderline; -// QAction* leftAlign; -// QAction* hcenterAlign; -// QAction* topAlign; -// QAction* bottomAlign; -// QAction* vcenterAlign; -// QAction* baselineAlign; -// QAction* rightAlign; QAction* typefaceSubscript; QAction* typefaceSuperscript; QAction* showKeyboard; -// QAction* unorderedList; -// QAction* orderedList; -// QAction* indentMore; -// QAction* indentLess; - QComboBox* textStyles; void blockAllSignals(bool val); void updateText(); @@ -60,14 +48,7 @@ class TextTools : public QDockWidget { void underlineClicked(bool); void subscriptClicked(bool); void superscriptClicked(bool); -// void setHalign(QAction*); -// void setValign(QAction*); void showKeyboardClicked(bool); - void styleChanged(int); -// void unorderedListClicked(); -// void orderedListClicked(); -// void indentMoreClicked(); -// void indentLessClicked(); public: TextTools(QWidget* parent = 0); diff --git a/mtest/libmscore/copypaste/copypaste07-ref.mscx b/mtest/libmscore/copypaste/copypaste07-ref.mscx index 37c3d5826899..9138ed7fca79 100644 --- a/mtest/libmscore/copypaste/copypaste07-ref.mscx +++ b/mtest/libmscore/copypaste/copypaste07-ref.mscx @@ -133,11 +133,9 @@ below - 8va - (8va) diff --git a/mtest/libmscore/copypaste/copypaste08-ref.mscx b/mtest/libmscore/copypaste/copypaste08-ref.mscx index 8bea63ac5f9b..be3605b73aeb 100644 --- a/mtest/libmscore/copypaste/copypaste08-ref.mscx +++ b/mtest/libmscore/copypaste/copypaste08-ref.mscx @@ -117,11 +117,9 @@ 0.1 1 - 8va - (8va) diff --git a/mtest/libmscore/copypaste/copypaste09-ref.mscx b/mtest/libmscore/copypaste/copypaste09-ref.mscx index dbf1c90a7085..0db493f9c785 100644 --- a/mtest/libmscore/copypaste/copypaste09-ref.mscx +++ b/mtest/libmscore/copypaste/copypaste09-ref.mscx @@ -114,11 +114,9 @@ 0.1 1 - 8va - (8va) @@ -196,11 +194,9 @@ 0.1 1 - 8va - (8va)