Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:musescore/MuseScore
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 28, 2014
2 parents fd66e91 + bb9c7b3 commit 9d32a42
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 63 deletions.
2 changes: 1 addition & 1 deletion libmscore/barline.cpp
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions libmscore/edit.cpp
Expand Up @@ -54,7 +54,6 @@
#include "repeat.h"
#include "bracket.h"
#include "ottava.h"
#include "mscore/globals.h"

namespace Ms {

Expand Down Expand Up @@ -440,7 +439,7 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns)

static void warnTupletCrossing()
{
if(!noGui)
if(!MScore::noGui)
QMessageBox::warning(0,
QT_TRANSLATE_NOOP("addRemoveTimeSig", "MuseScore"),
QT_TRANSLATE_NOOP("addRemoveTimeSig", "cannot rewrite measures:\n"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/element.cpp
Expand Up @@ -741,7 +741,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")
Expand Down
7 changes: 3 additions & 4 deletions libmscore/fret.cpp
Expand Up @@ -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)
Expand All @@ -309,9 +309,8 @@ void FretDiagram::layout()
Measure* m = static_cast<Segment*>(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);
}

//---------------------------------------------------------
Expand Down
18 changes: 8 additions & 10 deletions libmscore/harmony.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -846,18 +845,17 @@ void Harmony::layout()

qreal yy = 0.0;
if (parent()->type() == SEGMENT) {
if (!editMode()) {
// done in TextBlock
Measure* m = static_cast<Measure*>(parent()->parent());
yy = track() < 0 ? 0.0 : m->system()->staff(staffIdx())->y();
}
yy += score()->styleP(ST_harmonyY);
Measure* m = static_cast<Measure*>(parent()->parent());
yy = track() < 0 ? 0.0 : m->system()->staff(staffIdx())->y();
yy -= score()->styleP(ST_harmonyY);
Segment* s = static_cast<Segment*>(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;
}
}
Expand Down
1 change: 1 addition & 0 deletions libmscore/mscore.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libmscore/mscore.h
Expand Up @@ -387,6 +387,7 @@ class MScore : public QObject {
static qreal DPMM;
static bool debugMode;
static bool testMode;
static bool noGui;
};

//---------------------------------------------------------
Expand Down
10 changes: 0 additions & 10 deletions libmscore/read114.cpp
Expand Up @@ -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<int,Spanner*> p : spanner()) {
Spanner* s = p.second;
if (s->type() == Element::OTTAVA) {
Expand Down
4 changes: 2 additions & 2 deletions libmscore/style.cpp
Expand Up @@ -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) },
Expand Down
25 changes: 13 additions & 12 deletions libmscore/sym.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(
"<data>"
"<html>"
Expand All @@ -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(
"<data>"
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libmscore/sym.h
Expand Up @@ -1986,7 +1986,7 @@ class Sym {
//---------------------------------------------------------

class ScoreFont {
QFont _font;
QFont* _font;
QFontMetricsF* _fm = 0;
QVector<Sym> _symbols;
QString _name;
Expand All @@ -2012,7 +2012,7 @@ class ScoreFont {
static ScoreFont* fallbackFont();
static const QVector<ScoreFont>& 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;
Expand Down
2 changes: 1 addition & 1 deletion mscore/capella.cpp
Expand Up @@ -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),
Expand Down
12 changes: 6 additions & 6 deletions mscore/exportmp3.cpp
Expand Up @@ -72,7 +72,7 @@ bool MP3Exporter::findLibrary()
name = getLibraryName();
}

if (noGui)
if (MScore::noGui)
return false;

QString libPath = QFileDialog::getOpenFileName(
Expand Down Expand Up @@ -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!"),
Expand All @@ -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!"),
Expand Down Expand Up @@ -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);
Expand All @@ -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"),
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions mscore/file.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mscore/importgtp.cpp
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion mscore/importmidi.cpp
Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions mscore/musescore.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -4621,14 +4620,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);
Expand Down Expand Up @@ -4761,7 +4760,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"));
Expand Down Expand Up @@ -4893,7 +4892,7 @@ int main(int argc, char* av[])
mscore->setRevision(revision);

int files = 0;
if (noGui) {
if (MScore::noGui) {
loadScores(argv);
exit(processNonGui() ? 0 : -1);
}
Expand Down
3 changes: 2 additions & 1 deletion mscore/scoreview.cpp
Expand Up @@ -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();
}

//---------------------------------------------------------
Expand Down

0 comments on commit 9d32a42

Please sign in to comment.