2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011 Werner Schweer
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2
|
|
|
|
// as published by the Free Software Foundation and appearing in
|
|
|
|
// the file LICENCE.GPL
|
|
|
|
//=============================================================================
|
|
|
|
|
2012-07-16 15:49:24 +02:00
|
|
|
#include "config.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "style.h"
|
|
|
|
#include "mscore.h"
|
|
|
|
#include "sequencer.h"
|
2014-06-24 16:42:47 +02:00
|
|
|
#include "element.h"
|
|
|
|
#include "dynamic.h"
|
2012-10-01 20:03:31 +02:00
|
|
|
#include "accidental.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "figuredbass.h"
|
2012-08-16 12:12:55 +02:00
|
|
|
#include "stafftype.h"
|
2012-08-04 15:46:43 +02:00
|
|
|
#include "note.h"
|
2012-09-12 11:16:36 +02:00
|
|
|
#include "spanner.h"
|
2012-09-17 15:37:31 +02:00
|
|
|
#include "volta.h"
|
2012-09-17 17:35:49 +02:00
|
|
|
#include "ottava.h"
|
2012-09-17 18:09:30 +02:00
|
|
|
#include "trill.h"
|
2013-02-25 14:56:34 +01:00
|
|
|
#include "repeat.h"
|
|
|
|
#include "jump.h"
|
|
|
|
#include "marker.h"
|
2013-10-05 23:13:33 +02:00
|
|
|
#include "layoutbreak.h"
|
2014-06-25 13:28:17 +02:00
|
|
|
#include "hairpin.h"
|
2014-06-25 14:46:43 +02:00
|
|
|
#include "glissando.h"
|
2014-03-18 15:53:52 +01:00
|
|
|
#include "page.h"
|
2014-04-25 18:43:25 +02:00
|
|
|
#include "slur.h"
|
|
|
|
#include "lyrics.h"
|
|
|
|
#include "accidental.h"
|
|
|
|
#include "notedot.h"
|
|
|
|
#include "tie.h"
|
|
|
|
#include "staff.h"
|
|
|
|
#include "timesig.h"
|
|
|
|
#include "part.h"
|
|
|
|
#include "measure.h"
|
|
|
|
#include "score.h"
|
|
|
|
#include "keysig.h"
|
|
|
|
#include "harmony.h"
|
|
|
|
#include "cursor.h"
|
|
|
|
#include "stafftext.h"
|
|
|
|
#include "mscoreview.h"
|
2014-04-25 19:11:33 +02:00
|
|
|
#include "plugins.h"
|
2014-04-25 19:26:22 +02:00
|
|
|
// #include "mscore/qmlplugin.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal MScore::PDPI = 1200;
|
|
|
|
qreal MScore::DPI = 1200;
|
|
|
|
qreal MScore::DPMM;
|
|
|
|
bool MScore::debugMode;
|
2013-03-28 11:09:31 +01:00
|
|
|
bool MScore::testMode = false;
|
2014-02-28 11:14:43 +01:00
|
|
|
bool MScore::noGui = false;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
MStyle* MScore::_defaultStyle;
|
2014-01-30 13:10:45 +01:00
|
|
|
MStyle* MScore::_defaultStyleForParts;
|
2012-05-26 14:26:10 +02:00
|
|
|
MStyle* MScore::_baseStyle;
|
|
|
|
QString MScore::_globalShare;
|
|
|
|
int MScore::_vRaster;
|
|
|
|
int MScore::_hRaster;
|
|
|
|
QColor MScore::selectColor[VOICES];
|
|
|
|
QColor MScore::defaultColor;
|
|
|
|
QColor MScore::layoutBreakColor;
|
2013-07-04 21:07:38 +02:00
|
|
|
QColor MScore::frameMarginColor;
|
2012-05-26 14:26:10 +02:00
|
|
|
QColor MScore::bgColor;
|
|
|
|
QColor MScore::dropColor;
|
|
|
|
bool MScore::warnPitchRange;
|
|
|
|
|
|
|
|
bool MScore::playRepeats;
|
|
|
|
bool MScore::panPlayback;
|
|
|
|
qreal MScore::nudgeStep;
|
2013-08-26 14:45:01 +02:00
|
|
|
qreal MScore::nudgeStep10;
|
|
|
|
qreal MScore::nudgeStep50;
|
2012-05-26 14:26:10 +02:00
|
|
|
int MScore::defaultPlayDuration;
|
2014-01-30 13:10:45 +01:00
|
|
|
// QString MScore::partStyle;
|
2012-05-26 14:26:10 +02:00
|
|
|
QString MScore::lastError;
|
|
|
|
bool MScore::layoutDebug = false;
|
2013-05-11 18:59:13 +02:00
|
|
|
int MScore::division = 480; // pulses per quarter note (PPQ) // ticks per beat
|
2012-05-26 14:26:10 +02:00
|
|
|
int MScore::sampleRate = 44100;
|
|
|
|
int MScore::mtcType;
|
|
|
|
|
2014-03-04 17:40:23 +01:00
|
|
|
bool MScore::noExcerpts = false;
|
|
|
|
bool MScore::noImages = false;
|
|
|
|
|
2014-04-25 18:43:25 +02:00
|
|
|
#ifdef SCRIPT_INTERFACE
|
|
|
|
QQmlEngine* MScore::_qml = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
Sequencer* MScore::seq = 0;
|
|
|
|
|
|
|
|
extern void initDrumset();
|
2013-11-11 16:53:03 +01:00
|
|
|
extern void initScoreFonts();
|
2014-04-25 19:11:33 +02:00
|
|
|
extern QString mscoreGlobalShare;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// init
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MScore::init()
|
|
|
|
{
|
2012-07-13 16:11:39 +02:00
|
|
|
#ifdef SCRIPT_INTERFACE
|
2014-06-25 13:28:17 +02:00
|
|
|
qRegisterMetaType<Element::Type>("ElementType");
|
2014-06-25 20:02:40 +02:00
|
|
|
qRegisterMetaType<Note::ValueType>("ValueType");
|
2014-05-07 18:09:01 +02:00
|
|
|
qRegisterMetaType<Direction>("Direction");
|
|
|
|
qRegisterMetaType<DirectionH>("DirectionH");
|
2014-06-24 17:27:58 +02:00
|
|
|
qRegisterMetaType<Element::Placement>("Placement");
|
2014-06-25 12:52:12 +02:00
|
|
|
qRegisterMetaType<Accidental::Role>("AccidentalRole");
|
|
|
|
qRegisterMetaType<Accidental::Type>("AccidentalType");
|
2012-09-12 11:16:36 +02:00
|
|
|
qRegisterMetaType<Spanner::Anchor>("Anchor");
|
2014-06-25 21:18:26 +02:00
|
|
|
qRegisterMetaType<NoteHead::Group>("NoteHeadGroup");
|
2014-06-25 22:01:26 +02:00
|
|
|
qRegisterMetaType<NoteHead::Type>("NoteHeadType");
|
2014-06-25 13:28:17 +02:00
|
|
|
qRegisterMetaType<Segment::Type>("SegmentType");
|
2012-08-11 01:15:22 +02:00
|
|
|
qRegisterMetaType<FiguredBassItem::Modifier>("Modifier");
|
|
|
|
qRegisterMetaType<FiguredBassItem::Parenthesis>("Parenthesis");
|
2014-06-25 13:28:17 +02:00
|
|
|
qRegisterMetaType<FiguredBassItem::ContLine>("ContLine");
|
2013-03-05 20:23:59 +01:00
|
|
|
qRegisterMetaType<VoltaType>("VoltaType");
|
2013-08-12 10:37:30 +02:00
|
|
|
qRegisterMetaType<OttavaType>("OttavaType");
|
2014-06-25 14:07:43 +02:00
|
|
|
qRegisterMetaType<Trill::Type>("TrillType");
|
2014-06-24 16:42:47 +02:00
|
|
|
qRegisterMetaType<Dynamic::Range>("DynamicRange");
|
2013-02-25 14:56:34 +01:00
|
|
|
qRegisterMetaType<JumpType>("JumpType");
|
2014-06-25 19:43:43 +02:00
|
|
|
qRegisterMetaType<Marker::Type>("MarkerType");
|
2013-03-05 20:23:59 +01:00
|
|
|
qRegisterMetaType<BeamMode>("BeamMode");
|
2014-06-25 13:28:17 +02:00
|
|
|
qRegisterMetaType<Hairpin::Type>("HairpinType");
|
|
|
|
qRegisterMetaType<Lyrics::Syllabic>("Syllabic");
|
2014-06-25 13:57:29 +02:00
|
|
|
qRegisterMetaType<LayoutBreak::Type>("LayoutBreakType");
|
2014-06-25 14:46:43 +02:00
|
|
|
qRegisterMetaType<Glissando::Type>("Glissando::Type");
|
2014-03-10 10:50:12 +01:00
|
|
|
// qRegisterMetaType<TextStyle>("TextStyle");
|
2012-07-13 16:11:39 +02:00
|
|
|
#endif
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
DPMM = DPI / INCH; // dots/mm
|
|
|
|
|
2013-05-16 16:12:22 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2012-05-26 14:26:10 +02:00
|
|
|
QDir dir(QCoreApplication::applicationDirPath() + QString("/../" INSTALL_NAME));
|
|
|
|
_globalShare = dir.absolutePath() + "/";
|
2013-05-16 16:12:22 +02:00
|
|
|
#elif defined(Q_OS_IOS)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
extern QString resourcePath();
|
|
|
|
_globalShare = resourcePath();
|
|
|
|
}
|
2013-11-06 15:58:05 +01:00
|
|
|
|
2013-05-16 16:12:22 +02:00
|
|
|
#elif defined(Q_OS_MAC)
|
2012-05-26 14:26:10 +02:00
|
|
|
QDir dir(QCoreApplication::applicationDirPath() + QString("/../Resources"));
|
|
|
|
_globalShare = dir.absolutePath() + "/";
|
|
|
|
#else
|
|
|
|
_globalShare = QString( INSTPREFIX "/share/" INSTALL_NAME);
|
|
|
|
#endif
|
2012-11-20 23:07:37 +01:00
|
|
|
|
2013-11-06 15:58:05 +01:00
|
|
|
selectColor[0].setNamedColor("#2456aa"); //blue
|
|
|
|
selectColor[1].setNamedColor("#1a8239"); //green
|
|
|
|
selectColor[2].setNamedColor("#d79112"); //yellow
|
2013-07-04 17:50:46 +02:00
|
|
|
selectColor[3].setNamedColor("#75112b"); //purple
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
defaultColor = Qt::black;
|
|
|
|
dropColor = Qt::red;
|
|
|
|
defaultPlayDuration = 300; // ms
|
|
|
|
warnPitchRange = true;
|
2012-07-31 16:54:00 +02:00
|
|
|
playRepeats = true;
|
|
|
|
panPlayback = true;
|
2012-08-03 15:54:02 +02:00
|
|
|
|
2012-07-31 16:54:00 +02:00
|
|
|
lastError = "";
|
2012-08-03 15:54:02 +02:00
|
|
|
|
2013-07-04 17:50:46 +02:00
|
|
|
layoutBreakColor = QColor("#6abed3");
|
2013-07-04 21:07:38 +02:00
|
|
|
frameMarginColor = QColor("#6abed3");
|
2013-09-13 12:54:09 +02:00
|
|
|
bgColor.setNamedColor("#dddddd");
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
_defaultStyle = new MStyle();
|
2013-05-13 18:49:17 +02:00
|
|
|
Ms::initStyle(_defaultStyle);
|
2014-02-18 08:00:57 +01:00
|
|
|
_defaultStyleForParts = 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
_baseStyle = new MStyle(*_defaultStyle);
|
|
|
|
|
|
|
|
//
|
|
|
|
// load internal fonts
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// do not load application specific fonts
|
|
|
|
// for MAC, they are in Resources/fonts
|
|
|
|
//
|
2013-05-16 16:12:22 +02:00
|
|
|
#if !defined(Q_OS_MAC) && !defined(Q_OS_IOS)
|
2012-05-26 14:26:10 +02:00
|
|
|
static const char* fonts[] = {
|
2014-01-16 12:33:23 +01:00
|
|
|
":/fonts/MuseJazz.ttf",
|
|
|
|
":/fonts/FreeSans.ttf",
|
2014-01-22 16:19:54 +01:00
|
|
|
":/fonts/FreeSerif.ttf",
|
2014-01-16 12:33:23 +01:00
|
|
|
":/fonts/FreeSerifBold.ttf",
|
|
|
|
":/fonts/mscoreTab.ttf",
|
|
|
|
":/fonts/mscore-BC.ttf",
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(fonts)/sizeof(*fonts); ++i) {
|
2014-01-16 12:33:23 +01:00
|
|
|
QString s(fonts[i]);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (-1 == QFontDatabase::addApplicationFont(s)) {
|
2013-04-17 14:00:26 +02:00
|
|
|
qDebug("Mscore: fatal error: cannot load internal font <%s>", qPrintable(s));
|
2014-05-21 12:20:05 +02:00
|
|
|
if (!MScore::debugMode && !MScore::testMode)
|
2012-05-26 14:26:10 +02:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2013-11-06 15:58:05 +01:00
|
|
|
initScoreFonts();
|
2014-04-30 10:08:38 +02:00
|
|
|
StaffType::initStaffTypes();
|
2012-05-26 14:26:10 +02:00
|
|
|
initDrumset();
|
|
|
|
FiguredBass::readConfigFile(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// defaultStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MStyle* MScore::defaultStyle()
|
|
|
|
{
|
|
|
|
return _defaultStyle;
|
|
|
|
}
|
|
|
|
|
2014-01-30 13:10:45 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// defaultStyleForParts
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MStyle* MScore::defaultStyleForParts()
|
|
|
|
{
|
|
|
|
if (!_defaultStyleForParts) {
|
|
|
|
QSettings s;
|
|
|
|
QString partStyle = s.value("partStyle").toString();
|
|
|
|
if (!partStyle.isEmpty()) {
|
|
|
|
QFile f(partStyle);
|
|
|
|
if (f.open(QIODevice::ReadOnly)) {
|
|
|
|
MStyle* s = new MStyle(*defaultStyle());
|
|
|
|
if (s->load(&f))
|
|
|
|
_defaultStyleForParts = s;
|
|
|
|
else
|
|
|
|
delete s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _defaultStyleForParts;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// baseStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MStyle* MScore::baseStyle()
|
|
|
|
{
|
|
|
|
return _baseStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setDefaultStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MScore::setDefaultStyle(MStyle* s)
|
|
|
|
{
|
|
|
|
delete _defaultStyle;
|
|
|
|
_defaultStyle = s;
|
|
|
|
}
|
|
|
|
|
2014-01-30 13:10:45 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// defaultStyleForPartsHasChanged
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MScore::defaultStyleForPartsHasChanged()
|
|
|
|
{
|
|
|
|
delete _defaultStyleForParts;
|
|
|
|
_defaultStyleForParts = 0;
|
|
|
|
}
|
|
|
|
|
2014-05-19 15:19:36 +02:00
|
|
|
#ifdef SCRIPT_INTERFACE
|
2014-04-25 18:43:25 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// qml
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QQmlEngine* MScore::qml()
|
|
|
|
{
|
|
|
|
if (_qml == 0) {
|
|
|
|
//-----------some qt bindings
|
|
|
|
_qml = new QQmlEngine;
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
QStringList importPaths;
|
|
|
|
QDir dir(QCoreApplication::applicationDirPath() + QString("/../qml"));
|
|
|
|
importPaths.append(dir.absolutePath());
|
|
|
|
_qml->setImportPathList(importPaths);
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
QStringList importPaths;
|
|
|
|
QDir dir(mscoreGlobalShare + QString("/qml"));
|
|
|
|
importPaths.append(dir.absolutePath());
|
|
|
|
_qml->setImportPathList(importPaths);
|
|
|
|
#endif
|
2014-04-25 19:11:33 +02:00
|
|
|
qmlRegisterType<MsProcess> ("MuseScore", 1, 0, "QProcess");
|
|
|
|
qmlRegisterType<FileIO, 1> ("FileIO", 1, 0, "FileIO");
|
2014-04-25 18:43:25 +02:00
|
|
|
//-----------mscore bindings
|
|
|
|
qmlRegisterType<MScore> ("MuseScore", 1, 0, "MScore");
|
2014-04-25 19:11:33 +02:00
|
|
|
qmlRegisterType<MsScoreView>("MuseScore", 1, 0, "ScoreView");
|
2014-04-25 19:26:22 +02:00
|
|
|
// qmlRegisterType<QmlPlugin> ("MuseScore", 1, 0, "MuseScore");
|
2014-04-25 18:43:25 +02:00
|
|
|
qmlRegisterType<Score> ("MuseScore", 1, 0, "Score");
|
|
|
|
qmlRegisterType<Segment> ("MuseScore", 1, 0, "Segment");
|
|
|
|
qmlRegisterType<Chord> ("MuseScore", 1, 0, "Chord");
|
|
|
|
qmlRegisterType<Note> ("MuseScore", 1, 0, "Note");
|
|
|
|
qmlRegisterType<Accidental> ("MuseScore", 1, 0, "Accidental");
|
|
|
|
qmlRegisterType<Rest> ("MuseScore", 1, 0, "Rest");
|
|
|
|
qmlRegisterType<Measure> ("MuseScore", 1, 0, "Measure");
|
|
|
|
qmlRegisterType<Cursor> ("MuseScore", 1, 0, "Cursor");
|
|
|
|
qmlRegisterType<StaffText> ("MuseScore", 1, 0, "StaffText");
|
|
|
|
qmlRegisterType<Part> ("MuseScore", 1, 0, "Part");
|
|
|
|
qmlRegisterType<Staff> ("MuseScore", 1, 0, "Staff");
|
|
|
|
qmlRegisterType<Harmony> ("MuseScore", 1, 0, "Harmony");
|
|
|
|
qmlRegisterType<PageFormat> ("MuseScore", 1, 0, "PageFormat");
|
|
|
|
qmlRegisterType<TimeSig> ("MuseScore", 1, 0, "TimeSig");
|
|
|
|
qmlRegisterType<KeySig> ("MuseScore", 1, 0, "KeySig");
|
|
|
|
qmlRegisterType<Slur> ("MuseScore", 1, 0, "Slur");
|
|
|
|
qmlRegisterType<Tie> ("MuseScore", 1, 0, "Tie");
|
|
|
|
qmlRegisterType<NoteDot> ("MuseScore", 1, 0, "NoteDot");
|
|
|
|
qmlRegisterType<FiguredBass>("MuseScore", 1, 0, "FiguredBass");
|
|
|
|
qmlRegisterType<Text> ("MuseScore", 1, 0, "MText");
|
|
|
|
qmlRegisterType<Lyrics> ("MuseScore", 1, 0, "Lyrics");
|
|
|
|
qmlRegisterType<FiguredBassItem>("MuseScore", 1, 0, "FiguredBassItem");
|
|
|
|
qmlRegisterType<LayoutBreak>("MuseScore", 1, 0, "LayoutBreak");
|
|
|
|
|
|
|
|
qmlRegisterUncreatableType<Element>("MuseScore", 1, 0,
|
|
|
|
"Element", tr("you cannot create an element"));
|
|
|
|
|
|
|
|
//-----------virtual classes
|
|
|
|
qmlRegisterType<ChordRest>();
|
|
|
|
qmlRegisterType<SlurTie>();
|
|
|
|
qmlRegisterType<Spanner>();
|
|
|
|
}
|
|
|
|
return _qml;
|
|
|
|
}
|
2014-05-19 15:19:36 +02:00
|
|
|
#endif
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|