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 : #ifndef MU_ENGRAVING_MEASUREREPEAT_H
24 : #define MU_ENGRAVING_MEASUREREPEAT_H
25 :
26 : #include "rest.h"
27 :
28 : #include "utils.h"
29 :
30 : namespace mu::engraving {
31 : class Segment;
32 :
33 : class MeasureRepeat final : public Rest
34 : {
35 280 : OBJECT_ALLOCATOR(engraving, MeasureRepeat)
36 1429 : DECLARE_CLASSOF(ElementType::MEASURE_REPEAT)
37 :
38 : public:
39 : MeasureRepeat(DummyParentOr<Segment> parent);
40 10 : MeasureRepeat(const MeasureRepeat&) = default;
41 : MeasureRepeat& operator=(const MeasureRepeat&) = delete;
42 :
43 10 : MeasureRepeat* clone() const override { return new MeasureRepeat(*this); }
44 10 : EngravingItem* linkedClone() override { return EngravingItem::linkedClone(); }
45 :
46 : static constexpr int MAX_NUM_MEASURES = 4;
47 :
48 : void setNumMeasures(int n);
49 2258 : int numMeasures() const { return m_numMeasures; }
50 :
51 0 : void setNumberOffset(const Spatium y) { m_numberOffset = y; }
52 : Spatium numberOffset() const { return m_numberOffset; }
53 :
54 : Measure* firstMeasureOfGroup() const;
55 : const Measure* referringMeasure(const Measure* measure) const;
56 :
57 : Fraction ticks() const override;
58 0 : Fraction actualTicks() const { return Rest::ticks(); }
59 :
60 : PropertyValue propertyDefault(Pid) const override;
61 : bool setProperty(Pid, const PropertyValue&) override;
62 : PropertyValue getProperty(Pid) const override;
63 :
64 : String accessibleInfo() const override;
65 :
66 0 : int subtype() const override { return m_numMeasures; }
67 : muse::TranslatableString subtypeUserName() const override;
68 :
69 0 : bool placeMultiple() const override { return numMeasures() == 1; } // prevent overlapping additions with range selection
70 :
71 : RectF numberRect() const override;
72 :
73 : PointF numberPosition(const RectF& numberBbox) const;
74 :
75 : struct LayoutData : public Rest::LayoutData {
76 : SymId symId = SymId::noSym;
77 : SymIdList numberSym;
78 :
79 365 : void setSymId(SymId id) { symId = id; }
80 :
81 89 : void setNumberSym(int n) { numberSym = timeSigSymIdsFromString(String::number(n)); }
82 0 : void setNumberSym(const String& s) { numberSym = timeSigSymIdsFromString(s); }
83 276 : void clearNumberSym() { numberSym.clear(); }
84 :
85 : LineF extenderLineLeft = LineF();
86 : LineF extenderLineRight = LineF();
87 : };
88 3989 : DECLARE_LAYOUTDATA_METHODS(MeasureRepeat)
89 :
90 : private:
91 : int m_numMeasures = 0;
92 : Spatium m_numberOffset = 0.0_sp; // vertical offset of number relative to its style position
93 : };
94 : } // namespace mu::engraving
95 : #endif
|