MuseScore/libmscore/mscore.cpp

206 lines
6.3 KiB
C++
Raw Normal View History

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"
#include "accidental.h"
2012-05-26 14:26:10 +02:00
#include "figuredbass.h"
#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"
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;
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;
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::replaceFractions;
bool MScore::playRepeats;
bool MScore::panPlayback;
qreal MScore::nudgeStep;
qreal MScore::nudgeStep10;
qreal MScore::nudgeStep50;
2012-05-26 14:26:10 +02:00
int MScore::defaultPlayDuration;
QString MScore::partStyle;
QString MScore::lastError;
bool MScore::layoutDebug = false;
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 initStaffTypes();
extern void initDrumset();
2013-11-11 16:53:03 +01:00
extern void initScoreFonts();
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// init
//---------------------------------------------------------
void MScore::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");
qRegisterMetaType<Element::Placement>("Placement");
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");
qRegisterMetaType<Segment::SegmentType>("SegmentType");
2012-08-11 01:15:22 +02:00
qRegisterMetaType<FiguredBassItem::Modifier>("Modifier");
qRegisterMetaType<FiguredBassItem::Parenthesis>("Parenthesis");
qRegisterMetaType<VoltaType>("VoltaType");
qRegisterMetaType<OttavaType>("OttavaType");
2012-09-17 18:09:30 +02:00
qRegisterMetaType<Trill::TrillType>("TrillType");
qRegisterMetaType<Element::DynamicRange>("DynamicRange");
2013-02-25 14:56:34 +01:00
qRegisterMetaType<JumpType>("JumpType");
qRegisterMetaType<MarkerType>("MarkerType");
qRegisterMetaType<BeamMode>("BeamMode");
2013-10-05 23:13:33 +02:00
qRegisterMetaType<LayoutBreak::LayoutBreakType>("LayoutBreakType");
2012-07-13 16:11:39 +02:00
#endif
2012-05-26 14:26:10 +02:00
DPMM = DPI / INCH; // dots/mm
#ifdef Q_OS_WIN
2012-05-26 14:26:10 +02:00
QDir dir(QCoreApplication::applicationDirPath() + QString("/../" INSTALL_NAME));
_globalShare = dir.absolutePath() + "/";
#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
#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
selectColor[3].setNamedColor("#75112b"); //purple
2012-05-26 14:26:10 +02:00
defaultColor = Qt::black;
dropColor = Qt::red;
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-07-31 16:54:00 +02:00
lastError = "";
layoutBreakColor = QColor("#6abed3");
2013-07-04 21:07:38 +02:00
frameMarginColor = QColor("#6abed3");
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);
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_OS_MAC) && !defined(Q_OS_IOS)
2012-05-26 14:26:10 +02:00
static const char* fonts[] = {
"MuseJazz.ttf",
"FreeSans.ttf",
"FreeSerifMscore.ttf",
"FreeSerifBold.ttf",
"mscoreTab.ttf",
2013-08-10 21:02:21 +02:00
"mscore-BC.ttf",
2012-05-26 14:26:10 +02:00
};
for (unsigned i = 0; i < sizeof(fonts)/sizeof(*fonts); ++i) {
QString s = QString(":/fonts/%1").arg(fonts[i]);
if (-1 == QFontDatabase::addApplicationFont(s)) {
2013-04-17 14:00:26 +02:00
qDebug("Mscore: fatal error: cannot load internal font <%s>", qPrintable(s));
2012-05-26 14:26:10 +02:00
if (!MScore::debugMode)
exit(-1);
}
}
#endif
2013-11-06 15:58:05 +01:00
initScoreFonts();
StaffTypeTablature::readConfigFile(0); // get TAB font config, before initStaffTypes()
2012-05-26 14:26:10 +02:00
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
}