From 9a054060eb376d25553244d75564b8d445d715be Mon Sep 17 00:00:00 2001 From: lasconic Date: Thu, 27 Feb 2014 20:05:52 +0100 Subject: [PATCH 1/7] fix default layout of chordnames and fretboard --- libmscore/fret.cpp | 7 +++---- libmscore/harmony.cpp | 18 ++++++++---------- libmscore/style.cpp | 4 ++-- mscore/scoreview.cpp | 3 ++- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libmscore/fret.cpp b/libmscore/fret.cpp index 4082c113ff0d..c44b3043ccc1 100644 --- a/libmscore/fret.cpp +++ b/libmscore/fret.cpp @@ -298,7 +298,7 @@ void FretDiagram::layout() } bbox().setRect(x, y, w, h); - setPos(-_spatium, -h + score()->styleP(ST_fretY) + _spatium ); + setPos(-_spatium, -h - score()->styleP(ST_fretY) + _spatium ); adjustReadPos(); if (_harmony) @@ -309,9 +309,8 @@ void FretDiagram::layout() Measure* m = static_cast(parent())->measure(); int idx = staffIdx(); MStaff* mstaff = m->mstaff(idx); - System* system = m->system(); - qreal yp = pos().y() + system->staff(idx)->y() + system->y(); - mstaff->distanceUp = qMax(mstaff->distanceUp, h + _spatium * 2 - yp); + qreal dist = -(bbox().top()); + mstaff->distanceUp = qMax(mstaff->distanceUp, dist + _spatium * 2); } //--------------------------------------------------------- diff --git a/libmscore/harmony.cpp b/libmscore/harmony.cpp index 9501b1f1f4bc..addcf80f0a04 100644 --- a/libmscore/harmony.cpp +++ b/libmscore/harmony.cpp @@ -561,7 +561,6 @@ void Harmony::startEdit(MuseScoreView* view, const QPointF& p) if (!textList.isEmpty()) { QString s(harmonyName()); setText(s); - Text::createLayout(); // create TextBlocks from text } Text::startEdit(view, p); } @@ -846,18 +845,17 @@ void Harmony::layout() qreal yy = 0.0; if (parent()->type() == SEGMENT) { - if (!editMode()) { - // done in TextBlock - Measure* m = static_cast(parent()->parent()); - yy = track() < 0 ? 0.0 : m->system()->staff(staffIdx())->y(); - } - yy += score()->styleP(ST_harmonyY); + Measure* m = static_cast(parent()->parent()); + yy = track() < 0 ? 0.0 : m->system()->staff(staffIdx())->y(); + yy -= score()->styleP(ST_harmonyY); Segment* s = static_cast(parent()); - for (Element* e : s->annotations()) { + qreal _spatium = spatium(); + for (Element* e : s->annotations()) { if (e != this && e->type() == FRET_DIAGRAM && e->track() == track()) { - yy = score()->styleP(ST_fretY); + yy += score()->styleP(ST_harmonyY); + yy -= score()->styleP(ST_fretY); + yy -= _spatium * 2; yy -= score()->styleP(ST_harmonyFretDist); - yy -= e->bbox().height(); break; } } diff --git a/libmscore/style.cpp b/libmscore/style.cpp index e56212e07479..1a1f069bf8d4 100644 --- a/libmscore/style.cpp +++ b/libmscore/style.cpp @@ -408,13 +408,13 @@ StyleData::StyleData() { ST_pedalLineWidth, QVariant(.15) }, { ST_pedalLineStyle, QVariant(int(Qt::SolidLine)) }, { ST_trillY, QVariant(-1) }, - { ST_harmonyY, QVariant(-2.5) }, + { ST_harmonyY, QVariant(2.5) }, { ST_harmonyFretDist, QVariant(0.5) }, { ST_minHarmonyDistance, QVariant(0.5) }, { ST_capoPosition, QVariant(0) }, { ST_fretNumMag, QVariant(qreal(2.0)) }, { ST_fretNumPos, QVariant(0) }, - { ST_fretY, QVariant(-2.0) }, + { ST_fretY, QVariant(2.0) }, { ST_showPageNumber, QVariant(true) }, { ST_showPageNumberOne, QVariant(false) }, { ST_pageNumberOddEven, QVariant(true) }, diff --git a/mscore/scoreview.cpp b/mscore/scoreview.cpp index b0d68b033444..96055a59d36f 100644 --- a/mscore/scoreview.cpp +++ b/mscore/scoreview.cpp @@ -4926,8 +4926,9 @@ void ScoreView::cmdAddChordName() _score->undoAddElement(harmony); _score->select(harmony, SELECT_SINGLE, 0); - _score->setLayoutAll(true); startEdit(harmony); + _score->setLayoutAll(true); + _score->update(); } //--------------------------------------------------------- From bc1703187fdd9e27be989528833424eefb0685d7 Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 07:55:52 +0100 Subject: [PATCH 2/7] fix #21981: Mid-bar tempo marking aligns at the start of bar in 1.3 score --- libmscore/element.cpp | 2 +- libmscore/read114.cpp | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/libmscore/element.cpp b/libmscore/element.cpp index d8968d987edc..0b6267e6a799 100644 --- a/libmscore/element.cpp +++ b/libmscore/element.cpp @@ -723,7 +723,7 @@ bool Element::readProperties(XmlReader& e) } else if (tag == "tick") { int val = e.readInt(); - if (val >= 0 && type() != SYMBOL && type() != TEMPO_TEXT && (type() != GLISSANDO || score()->mscVersion() > 114)) // hack for 1.2 + if (val >= 0 && type() != SYMBOL && (type() != GLISSANDO || score()->mscVersion() > 114)) // hack for 1.2 e.setTick(score()->fileDivision(val)); } else if (tag == "offset") diff --git a/libmscore/read114.cpp b/libmscore/read114.cpp index 7a02f968b8d6..52c21dcfb825 100644 --- a/libmscore/read114.cpp +++ b/libmscore/read114.cpp @@ -694,16 +694,6 @@ Score::FileError Score::read114(XmlReader& e) // // move some elements // - for (Segment* s = firstSegment(); s; s = s->next1()) { - foreach (Element* e, s->annotations()) { - if (e->type() == Element::TEMPO_TEXT) { - // reparent from measure to segment - e->setUserOff(QPointF(e->userOff().x() - s->pos().x(), - e->userOff().y())); - } - } - } - for (std::pair p : spanner()) { Spanner* s = p.second; if (s->type() == Element::OTTAVA) { From 877cf8e3b7b82ee35346708fcebb1e325c9497aa Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 10:07:49 +0100 Subject: [PATCH 3/7] no mscore include in libmscore --- libmscore/edit.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index fed0bbd23c93..eb143207a99b 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -54,7 +54,6 @@ #include "repeat.h" #include "bracket.h" #include "ottava.h" -#include "mscore/globals.h" namespace Ms { @@ -440,12 +439,11 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns) static void warnTupletCrossing() { - if(!noGui) - QMessageBox::warning(0, - QT_TRANSLATE_NOOP("addRemoveTimeSig", "MuseScore"), - QT_TRANSLATE_NOOP("addRemoveTimeSig", "cannot rewrite measures:\n" - "tuplet would cross measure") - ); + QMessageBox::warning(0, + QT_TRANSLATE_NOOP("addRemoveTimeSig", "MuseScore"), + QT_TRANSLATE_NOOP("addRemoveTimeSig", "cannot rewrite measures:\n" + "tuplet would cross measure") + ); } //--------------------------------------------------------- From 7a48ced04cf73ab4ba51f4f1a2b3341f4d2a1b6c Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 11:14:43 +0100 Subject: [PATCH 4/7] move noGui to MScore --- libmscore/edit.cpp | 12 +++++++----- libmscore/mscore.cpp | 1 + libmscore/mscore.h | 1 + mscore/capella.cpp | 2 +- mscore/exportmp3.cpp | 12 ++++++------ mscore/file.cpp | 4 ++-- mscore/importgtp.cpp | 2 +- mscore/importmidi.cpp | 2 +- mscore/musescore.cpp | 11 +++++------ mtest/testutils.cpp | 2 +- 10 files changed, 26 insertions(+), 23 deletions(-) diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index eb143207a99b..f298925b7c8e 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -54,6 +54,7 @@ #include "repeat.h" #include "bracket.h" #include "ottava.h" +#include "mscore/globals.h" namespace Ms { @@ -439,11 +440,12 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns) static void warnTupletCrossing() { - QMessageBox::warning(0, - QT_TRANSLATE_NOOP("addRemoveTimeSig", "MuseScore"), - QT_TRANSLATE_NOOP("addRemoveTimeSig", "cannot rewrite measures:\n" - "tuplet would cross measure") - ); + if(!MScore::noGui) + QMessageBox::warning(0, + QT_TRANSLATE_NOOP("addRemoveTimeSig", "MuseScore"), + QT_TRANSLATE_NOOP("addRemoveTimeSig", "cannot rewrite measures:\n" + "tuplet would cross measure") + ); } //--------------------------------------------------------- diff --git a/libmscore/mscore.cpp b/libmscore/mscore.cpp index 59b0bae7008a..cb1f56a9825a 100644 --- a/libmscore/mscore.cpp +++ b/libmscore/mscore.cpp @@ -34,6 +34,7 @@ qreal MScore::DPI = 1200; qreal MScore::DPMM; bool MScore::debugMode; bool MScore::testMode = false; +bool MScore::noGui = false; MStyle* MScore::_defaultStyle; MStyle* MScore::_defaultStyleForParts; diff --git a/libmscore/mscore.h b/libmscore/mscore.h index 0c39d7ed4e5c..40e8b0f854e7 100644 --- a/libmscore/mscore.h +++ b/libmscore/mscore.h @@ -387,6 +387,7 @@ class MScore : public QObject { static qreal DPMM; static bool debugMode; static bool testMode; + static bool noGui; }; //--------------------------------------------------------- diff --git a/mscore/capella.cpp b/mscore/capella.cpp index 1e49f09eaf64..152af5d122fa 100644 --- a/mscore/capella.cpp +++ b/mscore/capella.cpp @@ -2364,7 +2364,7 @@ Score::FileError importCapella(Score* score, const QString& name) cf.read(&fp); } catch (Capella::CapellaError errNo) { - if (!noGui) { + if (!MScore::noGui) { QMessageBox::warning(0, QWidget::tr("MuseScore: Import Capella"), QString("Load failed: ") + cf.error(errNo), diff --git a/mscore/exportmp3.cpp b/mscore/exportmp3.cpp index db1b08f864f8..46d4ac5295d2 100644 --- a/mscore/exportmp3.cpp +++ b/mscore/exportmp3.cpp @@ -72,7 +72,7 @@ bool MP3Exporter::findLibrary() name = getLibraryName(); } - if (noGui) + if (MScore::noGui) return false; QString libPath = QFileDialog::getOpenFileName( @@ -619,7 +619,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) if (!exporter.loadLibrary(MP3Exporter::Maybe)) { QSettings settings; settings.setValue("/Export/lameMP3LibPath", ""); - if(!noGui) + if(!MScore::noGui) QMessageBox::warning(0, tr("Error opening LAME library"), tr("Could not open MP3 encoding library!"), @@ -631,7 +631,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) if (!exporter.validLibraryLoaded()) { QSettings settings; settings.setValue("/Export/lameMP3LibPath", ""); - if(!noGui) + if(!MScore::noGui) QMessageBox::warning(0, tr("Error opening LAME library"), tr("Not a valid or supported MP3 encoding library!"), @@ -660,7 +660,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) int inSamples = exporter.initializeStream(channels, sampleRate); if (inSamples < 0) { - if (!noGui) { + if (!MScore::noGui) { QMessageBox::warning(0, tr("Encoding error"), tr("Unable to initialize MP3 stream"), QString::null, QString::null); @@ -672,7 +672,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) QFile file(name); if (!file.open(QIODevice::WriteOnly)) { - if (!noGui) { + if (!MScore::noGui) { QMessageBox::warning(0, tr("Encoding error"), tr("Unable to open target file for writing"), @@ -788,7 +788,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) else bytes = exporter.encodeBuffer(bufferL, bufferR, bufferOut); if (bytes < 0) { - if (noGui) + if (MScore::noGui) printf("exportmp3: error from encoder: %ld\n", bytes); else { QMessageBox::warning(0, diff --git a/mscore/file.cpp b/mscore/file.cpp index a57ff334f78e..b47cb29f6556 100644 --- a/mscore/file.cpp +++ b/mscore/file.cpp @@ -1925,7 +1925,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy) QString ext = fi.suffix(); if (ext.isEmpty()) { - if(!noGui) QMessageBox::critical(mscore, tr("MuseScore: Save As"), tr("cannot determine file type")); + if(!MScore::noGui) QMessageBox::critical(mscore, tr("MuseScore: Save As"), tr("cannot determine file type")); return false; } return saveAs(cs, saveCopy, fn, ext); @@ -1939,7 +1939,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy) bool MuseScore::saveSelection(Score* cs) { if (cs->selection().state() != SEL_RANGE) { - if(!noGui) QMessageBox::warning(mscore, tr("MuseScore: Save Selection"), tr("Please select one or more measures")); + if(!MScore::noGui) QMessageBox::warning(mscore, tr("MuseScore: Save Selection"), tr("Please select one or more measures")); return false; } QStringList fl; diff --git a/mscore/importgtp.cpp b/mscore/importgtp.cpp index 9d02a53fdd5c..d4381befabec 100644 --- a/mscore/importgtp.cpp +++ b/mscore/importgtp.cpp @@ -2683,7 +2683,7 @@ Score::FileError importGTP(Score* score, const QString& name) gp->read(&fp); } catch(GuitarPro::GuitarProError errNo) { - if (!noGui) { + if (!MScore::noGui) { QMessageBox::warning(0, QWidget::tr("MuseScore: Import Guitar Pro"), QString("Load failed: ") + gp->error(errNo), diff --git a/mscore/importmidi.cpp b/mscore/importmidi.cpp index 0ed75c75dea5..050b2a0d2a33 100644 --- a/mscore/importmidi.cpp +++ b/mscore/importmidi.cpp @@ -984,7 +984,7 @@ Score::FileError importMidi(Score *score, const QString &name) mf.read(&fp); } catch (QString errorText) { - if (!noGui) { + if (!MScore::noGui) { QMessageBox::warning(0, QWidget::tr("MuseScore: load midi"), QWidget::tr("Load failed: ") + errorText, diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 8d2aa8eeea79..63b8fe3893ad 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -115,7 +115,6 @@ QString dataPath; QString iconPath; bool converterMode = false; -bool noGui = false; bool externalIcons = false; static bool pluginMode = false; static bool startWithNewScore = false; @@ -2126,7 +2125,7 @@ static void loadScores(const QStringList& argv) Score* score = mscore->readScore(name); if (score) { mscore->appendScore(score); - if(!noGui) { + if(!MScore::noGui) { mscore->updateRecentScores(score); mscore->writeSessionFile(false); } @@ -4619,14 +4618,14 @@ int main(int argc, char* av[]) break; case 'o': converterMode = true; - noGui = true; + MScore::noGui = true; if (argv.size() - i < 2) usage(); outFileName = argv.takeAt(i + 1); break; case 'p': pluginMode = true; - noGui = true; + MScore::noGui = true; if (argv.size() - i < 2) usage(); pluginName = argv.takeAt(i + 1); @@ -4759,7 +4758,7 @@ int main(int argc, char* av[]) converterDpi = preferences.pngResolution; QSplashScreen* sc = 0; - if (!noGui && preferences.showSplashScreen) { + if (!MScore::noGui && preferences.showSplashScreen) { QPixmap pm(":/data/splash.jpg"); sc = new QSplashScreen(pm); sc->setWindowTitle(QString("MuseScore Startup")); @@ -4891,7 +4890,7 @@ int main(int argc, char* av[]) mscore->setRevision(revision); int files = 0; - if (noGui) { + if (MScore::noGui) { loadScores(argv); exit(processNonGui() ? 0 : -1); } diff --git a/mtest/testutils.cpp b/mtest/testutils.cpp index 4155ac2b5bf5..7228eb340e7d 100644 --- a/mtest/testutils.cpp +++ b/mtest/testutils.cpp @@ -38,7 +38,6 @@ extern Score::FileError importMusicXml(Score*, const QString&); extern Score::FileError importGTP(Score*, const QString&); extern bool saveXml(Score*, const QString&); bool debugMode = false; -bool noGui = true; QString revision; bool enableTestMode; @@ -272,6 +271,7 @@ void MTest::initMTest() MScore::DPI = 120; MScore::PDPI = 120; MScore::DPMM = MScore::DPI / INCH; + MScore::noGui = true; synti = new MasterSynthesizer(); mscore = new MScore; From 28d62d1d9501bc8ba45cfa6b60464568e2d2f85a Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 12:00:32 +0100 Subject: [PATCH 5/7] delay construction of QFont --- libmscore/sym.cpp | 25 +++++++++++++------------ libmscore/sym.h | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libmscore/sym.cpp b/libmscore/sym.cpp index 6ca12965f201..41b509215197 100644 --- a/libmscore/sym.cpp +++ b/libmscore/sym.cpp @@ -4148,7 +4148,7 @@ void ScoreFont::draw(const QString& s, QPainter* painter, qreal mag, const QPoin { qreal imag = 1.0 / mag; painter->scale(mag, mag); - painter->setFont(_font); + painter->setFont(font()); painter->drawText(pos * imag, s); painter->scale(imag, imag); } @@ -4180,10 +4180,10 @@ QString ScoreFont::symToHtml(SymId s, int leftMargin, const TextStyle* ts, qreal size = ts->font(_spatium).pointSizeF(); } else { - size = _font.pixelSize(); + size = _font->pixelSize(); } - QString family = _font.family(); + QString family = _font->family(); return QString( "" "" @@ -4205,8 +4205,8 @@ QString ScoreFont::symToHtml(SymId s, int leftMargin, const TextStyle* ts, qreal QString ScoreFont::symToHtml(SymId s1, SymId s2, int leftMargin) { - qreal size = _font.pixelSize(); - QString family = _font.family(); + qreal size = _font->pixelSize(); + QString family = _font->family(); return QString( "" @@ -4282,17 +4282,18 @@ void ScoreFont::load() exit(-1); } #endif - _font.setWeight(QFont::Normal); // if not set we get system default - _font.setItalic(false); - _font.setFamily(_family); - _font.setStyleStrategy(QFont::NoFontMerging); + _font = new QFont(); + _font->setWeight(QFont::Normal); // if not set we get system default + _font->setItalic(false); + _font->setFamily(_family); + _font->setStyleStrategy(QFont::NoFontMerging); // horizontal hinting is bad as note hooks do not attach to stems // properly at some magnifications - _font.setHintingPreference(QFont::PreferVerticalHinting); + _font->setHintingPreference(QFont::PreferVerticalHinting); qreal size = 20.0 * MScore::DPI / PPI; - _font.setPixelSize(lrint(size)); + _font->setPixelSize(lrint(size)); QFile fi(_fontPath + "glyphnames.json"); if (!fi.open(QIODevice::ReadOnly)) @@ -4303,7 +4304,7 @@ void ScoreFont::load() qDebug("Json parse error in <%s>(offset: %d): %s", qPrintable(fi.fileName()), error.offset, qPrintable(error.errorString())); - _fm = new QFontMetricsF(_font); + _fm = new QFontMetricsF(font()); for (auto i : o.keys()) { bool ok; int code = o.value(i).toObject().value("codepoint").toString().mid(2).toInt(&ok, 16); diff --git a/libmscore/sym.h b/libmscore/sym.h index 71a901966d0e..53f9817e95b5 100644 --- a/libmscore/sym.h +++ b/libmscore/sym.h @@ -1986,7 +1986,7 @@ class Sym { //--------------------------------------------------------- class ScoreFont { - QFont _font; + QFont* _font; QFontMetricsF* _fm = 0; QVector _symbols; QString _name; @@ -2012,7 +2012,7 @@ class ScoreFont { static ScoreFont* fallbackFont(); static const QVector& scoreFonts() { return _scoreFonts; } - const QFont& font() const { return _font; } + const QFont& font() const { return *_font; } const QString& toString(SymId id) const { return _symbols[int(id)].string(); } void draw(SymId id, QPainter* painter, qreal mag, const QPointF& pos = QPointF()) const; From cd6367d5d34314faac99e050f977e8e45cd20302 Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 12:06:20 +0100 Subject: [PATCH 6/7] again, no mscore header in libmscore --- libmscore/edit.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index f298925b7c8e..00699fa9686d 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -54,7 +54,6 @@ #include "repeat.h" #include "bracket.h" #include "ottava.h" -#include "mscore/globals.h" namespace Ms { From bb9c7b3b19325293edb93923efade035e84f2839 Mon Sep 17 00:00:00 2001 From: lasconic Date: Fri, 28 Feb 2014 13:11:00 +0100 Subject: [PATCH 7/7] fix possible crash for barline and hidden staff --- libmscore/barline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmscore/barline.cpp b/libmscore/barline.cpp index 2022d6d9d536..5b929e23faf0 100644 --- a/libmscore/barline.cpp +++ b/libmscore/barline.cpp @@ -88,7 +88,7 @@ QPointF BarLine::pagePos() const int staffIdx1 = staffIdx(); Staff* staff1 = score()->staff(staffIdx1); SysStaff* sysStaff1 = system->staff(staffIdx1); - while ( !(sysStaff1->show() && staff1->show()) ) { + while ( staff1 && sysStaff1 && !(sysStaff1->show() && staff1->show()) ) { staffIdx1++; staff1 = score()->staff(staffIdx1); sysStaff1 = system->staff(staffIdx1);