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 : #ifndef MU_ENGRAVING_SCOREORDER_H
23 : #define MU_ENGRAVING_SCOREORDER_H
24 :
25 : #include <map>
26 :
27 : #include "types/translatablestring.h"
28 : #include "../types/types.h"
29 :
30 : namespace mu::engraving {
31 : class XmlWriter;
32 : class XmlReader;
33 : class InstrumentTemplate;
34 : class Score;
35 :
36 : //---------------------------------------------------------
37 : // ScoreGroup
38 : //---------------------------------------------------------
39 :
40 : struct ScoreGroup
41 : {
42 : String family;
43 : String section;
44 : String unsorted; // isEmpty() : equal to <unsorted/>
45 : // !isEmpty() : equal to <unsorted group="unsorted"/>
46 : bool notUnsorted = true; // not an unsorted group
47 :
48 : bool bracket = false;
49 : bool barLineSpan = true;
50 : bool thinBracket = true;
51 : };
52 :
53 : //---------------------------------------------------------
54 : // InstrumentOverwrite
55 : //---------------------------------------------------------
56 :
57 : struct InstrumentOverwrite
58 : {
59 : String id;
60 : String name;
61 : };
62 :
63 : //---------------------------------------------------------
64 : // ScoreOrder
65 : //---------------------------------------------------------
66 :
67 : struct ScoreOrder
68 : {
69 : String id;
70 : TranslatableString name;
71 : std::map<String, InstrumentOverwrite> instrumentMap;
72 : std::vector<ScoreGroup> groups;
73 : bool customized = false;
74 :
75 2610 : ScoreOrder() = default;
76 :
77 : ScoreOrder clone() const;
78 : bool operator==(const ScoreOrder& order) const;
79 : bool operator!=(const ScoreOrder& order) const;
80 :
81 : bool readBoolAttribute(XmlReader& reader, const char* name, bool defValue);
82 : void readInstrument(XmlReader& reader);
83 : void readSoloists(XmlReader& reader, const String section);
84 : void readSection(XmlReader& reader);
85 : bool hasGroup(const String& id, const String& group=String()) const;
86 :
87 : bool isValid() const;
88 : bool isCustom() const;
89 : TranslatableString getName() const;
90 : String getFamilyName(const InstrumentTemplate* instrTemplate, bool soloist) const;
91 : ScoreGroup newUnsortedGroup(const String group, const String section) const;
92 : ScoreGroup getGroup(const String family, const String instrumentGroup) const;
93 : int instrumentSortingIndex(const String& instrumentId, bool isSoloist) const;
94 : bool isScoreOrder(const std::vector<int>& indices) const;
95 : bool isScoreOrder(const Score* score) const;
96 :
97 : void setBracketsAndBarlines(Score* score);
98 :
99 : void read(XmlReader& reader);
100 : void write(XmlWriter& xml) const;
101 :
102 : void updateInstruments(const Score* score);
103 : };
104 : } // namespace mu::engraving
105 :
106 : #endif
|