Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "writecontext.h"
24 :
25 : #include "iengravingconfiguration.h"
26 :
27 : using namespace mu::engraving;
28 : using namespace mu::engraving::write;
29 :
30 2509 : std::shared_ptr<IEngravingConfiguration> WriteContext::configuration() const
31 : {
32 2509 : return m_score->configuration();
33 : }
34 :
35 67567 : bool WriteContext::canWrite(const EngravingItem* e) const
36 : {
37 67567 : if (!_filter.has_value()) {
38 66685 : return true;
39 : }
40 :
41 882 : return _filter.value().canSelect(e);
42 : }
43 :
44 42354 : bool WriteContext::canWriteNoteIdx(size_t noteIdx, size_t totalNotesInChord) const
45 : {
46 42354 : if (!_filter.has_value()) {
47 40935 : return true;
48 : }
49 :
50 1419 : const Selection& sel = m_score->selection();
51 1419 : return _filter.value().canSelectNoteIdx(noteIdx, totalNotesInChord, sel.rangeContainsMultiNoteChords());
52 : }
53 :
54 65820 : bool WriteContext::canWriteVoice(track_idx_t track) const
55 : {
56 65820 : if (!_filter.has_value()) {
57 65484 : return true;
58 : }
59 :
60 336 : return _filter.value().canSelectVoice(track);
61 : }
|