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 : #pragma once
23 :
24 : #include "styledef.h"
25 : #include "../types/types.h"
26 :
27 : namespace mu::engraving {
28 : struct OffsetSids {
29 : Sid above = Sid::NOSTYLE;
30 : Sid below = Sid::NOSTYLE;
31 : };
32 :
33 : enum class TextStylePropertyType : char {
34 : Undefined = 0,
35 : FontFace,
36 : FontSize,
37 : LineSpacing,
38 : SizeSpatiumDependent,
39 : FontStyle,
40 : Color,
41 : TextAlign,
42 : Offset,
43 : FrameType,
44 : FramePadding,
45 : FrameWidth,
46 : FrameRound,
47 : FrameBorderColor,
48 : FrameFillColor,
49 : MusicalSymbolsScale,
50 : MusicalSymbolsSize,
51 : Position
52 : };
53 :
54 : struct TextStyleProperty {
55 : TextStylePropertyType type;
56 : Sid sid;
57 : Pid pid;
58 : };
59 :
60 : constexpr size_t TEXT_STYLE_SIZE = 16;
61 :
62 : struct TextStyle {
63 : std::array<TextStyleProperty, TEXT_STYLE_SIZE> properties;
64 : OffsetSids offsetSids;
65 :
66 : auto begin() { return properties.begin(); }
67 : auto end() { return properties.end(); }
68 554324 : auto begin() const { return properties.begin(); }
69 554324 : auto end() const { return properties.end(); }
70 :
71 : auto size() const { return properties.size(); }
72 :
73 : auto& operator[](size_t i) { return properties[i]; }
74 : const auto& operator[](size_t i) const { return properties[i]; }
75 : auto& at(size_t i) { return properties.at(i); }
76 1524369 : const auto& at(size_t i) const { return properties.at(i); }
77 : };
78 :
79 : const TextStyle* textStyle(TextStyleType);
80 : const std::vector<TextStyleType>& allTextStyles();
81 : const std::vector<TextStyleType>& editableTextStyles();
82 : const std::vector<TextStyleType>& primaryTextStyles();
83 : }
|