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"
|
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"
|
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;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
MStyle* MScore::_defaultStyle;
|
|
|
|
MStyle* MScore::_baseStyle;
|
|
|
|
QString MScore::_globalShare;
|
|
|
|
int MScore::_vRaster;
|
|
|
|
int MScore::_hRaster;
|
|
|
|
QColor MScore::selectColor[VOICES];
|
|
|
|
QColor MScore::defaultColor;
|
|
|
|
QColor MScore::layoutBreakColor;
|
|
|
|
QColor MScore::bgColor;
|
|
|
|
QColor MScore::dropColor;
|
|
|
|
bool MScore::warnPitchRange;
|
|
|
|
|
|
|
|
bool MScore::replaceFractions;
|
|
|
|
bool MScore::playRepeats;
|
|
|
|
bool MScore::panPlayback;
|
|
|
|
qreal MScore::nudgeStep;
|
|
|
|
int MScore::defaultPlayDuration;
|
|
|
|
QString MScore::partStyle;
|
|
|
|
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;
|
|
|
|
|
|
|
|
Sequencer* MScore::seq = 0;
|
|
|
|
|
|
|
|
extern void initSymbols(int);
|
|
|
|
extern void initStaffTypes();
|
|
|
|
extern void initDrumset();
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// init
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MScore::init()
|
|
|
|
{
|
2012-09-08 11:33:46 +02:00
|
|
|
Sym::init();
|
|
|
|
|
2012-07-13 16:11:39 +02:00
|
|
|
#ifdef SCRIPT_INTERFACE
|
2012-09-13 18:01:34 +02:00
|
|
|
qRegisterMetaType<Element::ElementType>("ElementType");
|
2012-07-13 16:11:39 +02:00
|
|
|
qRegisterMetaType<MScore::ValueType>("ValueType");
|
|
|
|
qRegisterMetaType<MScore::Direction>("Direction");
|
|
|
|
qRegisterMetaType<MScore::DirectionH>("DirectionH");
|
2012-10-30 09:06:24 +01:00
|
|
|
qRegisterMetaType<Element::Placement>("Placement");
|
2012-10-01 20:03:31 +02:00
|
|
|
qRegisterMetaType<Accidental::AccidentalRole>("AccidentalRole");
|
|
|
|
qRegisterMetaType<Accidental::AccidentalType>("AccidentalType");
|
2012-09-12 11:16:36 +02:00
|
|
|
qRegisterMetaType<Spanner::Anchor>("Anchor");
|
2012-08-04 15:46:43 +02:00
|
|
|
qRegisterMetaType<Note::NoteHeadGroup>("NoteHeadGroup");
|
|
|
|
qRegisterMetaType<Note::NoteHeadType>("NoteHeadType");
|
2012-08-03 15:54:02 +02:00
|
|
|
qRegisterMetaType<Segment::SegmentType>("SegmentType");
|
2012-08-11 01:15:22 +02:00
|
|
|
qRegisterMetaType<FiguredBassItem::Modifier>("Modifier");
|
|
|
|
qRegisterMetaType<FiguredBassItem::Parenthesis>("Parenthesis");
|
2013-03-05 20:23:59 +01:00
|
|
|
qRegisterMetaType<VoltaType>("VoltaType");
|
2012-09-17 17:35:49 +02:00
|
|
|
qRegisterMetaType<Ottava::OttavaType>("OttavaType");
|
2012-09-17 18:09:30 +02:00
|
|
|
qRegisterMetaType<Trill::TrillType>("TrillType");
|
2012-10-31 10:15:45 +01:00
|
|
|
qRegisterMetaType<Element::DynamicRange>("DynamicRange");
|
2013-02-25 14:56:34 +01:00
|
|
|
qRegisterMetaType<JumpType>("JumpType");
|
|
|
|
qRegisterMetaType<MarkerType>("MarkerType");
|
2013-03-05 20:23:59 +01:00
|
|
|
qRegisterMetaType<BeamMode>("BeamMode");
|
2012-07-13 16:11:39 +02:00
|
|
|
#endif
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
DPMM = DPI / INCH; // dots/mm
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
QDir dir(QCoreApplication::applicationDirPath() + QString("/../" INSTALL_NAME));
|
|
|
|
_globalShare = dir.absolutePath() + "/";
|
2012-11-21 19:02:04 +01:00
|
|
|
#elif defined(Q_WS_IOS)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
extern QString resourcePath();
|
|
|
|
_globalShare = resourcePath();
|
|
|
|
}
|
2012-11-20 23:07:37 +01:00
|
|
|
#elif defined(Q_WS_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-07-04 17:50:46 +02:00
|
|
|
selectColor[0].setNamedColor("#2456aa"); //blue
|
|
|
|
selectColor[1].setNamedColor("#5f8f00"); //green
|
|
|
|
selectColor[2].setNamedColor("#d79112"); //yellow
|
|
|
|
selectColor[3].setNamedColor("#75112b"); //purple
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
defaultColor = Qt::black;
|
|
|
|
dropColor = Qt::red;
|
|
|
|
nudgeStep = .1; // in spatium units (default 0.1)
|
|
|
|
defaultPlayDuration = 300; // ms
|
|
|
|
warnPitchRange = true;
|
|
|
|
replaceFractions = true;
|
2012-07-31 16:54:00 +02:00
|
|
|
playRepeats = true;
|
|
|
|
panPlayback = true;
|
2012-05-26 14:26:10 +02:00
|
|
|
partStyle = "";
|
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");
|
|
|
|
bgColor.setRgb(0xbf, 0xbf, 0xbf);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
_defaultStyle = new MStyle();
|
2013-05-13 18:49:17 +02:00
|
|
|
Ms::initStyle(_defaultStyle);
|
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
|
|
|
|
//
|
|
|
|
#if !defined(Q_WS_MAC) && !defined(Q_WS_UIKIT)
|
|
|
|
static const char* fonts[] = {
|
2013-07-01 18:53:19 +02:00
|
|
|
"mscore-20.ttf",
|
2012-05-26 14:26:10 +02:00
|
|
|
"MuseJazz.ttf",
|
|
|
|
"FreeSans.ttf",
|
|
|
|
"FreeSerifMscore.ttf",
|
|
|
|
"FreeSerifBold.ttf",
|
2013-07-01 18:53:19 +02:00
|
|
|
"gonville-20.ttf",
|
2012-08-16 12:12:55 +02:00
|
|
|
"mscoreTab.ttf",
|
2012-05-26 14:26:10 +02:00
|
|
|
"mscore-BC.ttf"
|
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(fonts)/sizeof(*fonts); ++i) {
|
|
|
|
QString s = QString(":/fonts/%1").arg(fonts[i]);
|
|
|
|
if (-1 == QFontDatabase::addApplicationFont(s)) {
|
|
|
|
qDebug("Mscore: fatal error: cannot load internal font <%s>\n", fonts[i]);
|
|
|
|
if (!MScore::debugMode)
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-16 18:25:38 +02:00
|
|
|
StaffTypeTablature::readConfigFile(0); // get TAB font config, before initStaffTypes()
|
2012-05-26 14:26:10 +02:00
|
|
|
initSymbols(0); // init emmentaler symbols
|
|
|
|
initStaffTypes();
|
|
|
|
initDrumset();
|
|
|
|
FiguredBass::readConfigFile(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// defaultStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MStyle* MScore::defaultStyle()
|
|
|
|
{
|
|
|
|
return _defaultStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// baseStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MStyle* MScore::baseStyle()
|
|
|
|
{
|
|
|
|
return _baseStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setDefaultStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MScore::setDefaultStyle(MStyle* s)
|
|
|
|
{
|
|
|
|
delete _defaultStyle;
|
|
|
|
_defaultStyle = s;
|
|
|
|
}
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|