forked from musescore/MuseScore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotationmodule.cpp
More file actions
103 lines (86 loc) · 3.48 KB
/
Copy pathnotationmodule.cpp
File metadata and controls
103 lines (86 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "notationmodule.h"
#include "modularity/ioc.h"
#include "project/inotationwritersregister.h"
#include "internal/notationconfiguration.h"
#include "internal/notationcontextconfiguration.h"
#include "internal/positionswriter.h"
#include "internal/mscnotationwriter.h"
#include "internal/instrumentsrepository.h"
#include "internal/engravingfontscontroller.h"
#include "diagnostics/idiagnosticspathsregister.h"
using namespace mu::notation;
using namespace muse;
using namespace muse::modularity;
static const std::string mname("notation");
std::string NotationModule::moduleName() const
{
return mname;
}
void NotationModule::registerExports()
{
m_configuration = std::make_shared<NotationConfiguration>();
m_instrumentsRepository = std::make_shared<InstrumentsRepository>();
#ifdef MUE_BUILD_ENGRAVING_FONTSCONTROLLER
m_engravingFontsController = std::make_shared<EngravingFontsController>();
#endif
globalIoc()->registerExport<INotationConfiguration>(moduleName(), m_configuration);
globalIoc()->registerExport<IInstrumentsRepository>(mname, m_instrumentsRepository);
}
void NotationModule::resolveImports()
{
auto writers = globalIoc()->resolve<project::INotationWritersRegister>(mname);
if (writers) {
writers->reg({ "spos" }, std::make_shared<PositionsWriter>(PositionsWriter::ElementType::SEGMENT));
writers->reg({ "mpos" }, std::make_shared<PositionsWriter>(PositionsWriter::ElementType::MEASURE));
writers->reg({ "mscz" }, std::make_shared<MscNotationWriter>(engraving::MscIoMode::Zip));
writers->reg({ "mscx" }, std::make_shared<MscNotationWriter>(engraving::MscIoMode::Dir));
}
}
void NotationModule::onInit(const IApplication::RunMode&)
{
m_configuration->init();
m_instrumentsRepository->init();
#ifdef MUE_BUILD_ENGRAVING_FONTSCONTROLLER
m_engravingFontsController->init();
#endif
bool isVertical = m_configuration->canvasOrientation().val == muse::Orientation::Vertical;
mu::engraving::MScore::setVerticalOrientation(isVertical);
auto pr = globalIoc()->resolve<diagnostics::IDiagnosticsPathsRegister>(mname);
if (pr) {
pr->reg("instruments", m_configuration->instrumentsXmlPath());
pr->reg("score orders", m_configuration->scoreOrdersXmlPath());
muse::io::path_t userInstrumentsPath = m_configuration->userInstrumentsFolder();
if (!userInstrumentsPath.empty()) {
pr->reg("user instruments folder", userInstrumentsPath);
}
}
}
IContextSetup* NotationModule::newContext(const ContextPtr& ctx) const
{
return new NotationContext(ctx);
}
void NotationContext::registerExports()
{
ioc()->registerExport<INotationContextConfiguration>(mname, new NotationContextConfiguration(iocContext()));
}