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 : #pragma once
24 :
25 : #include "rest.h"
26 :
27 : #include "utils.h"
28 :
29 : namespace mu::engraving {
30 : class MMRest final : public Rest
31 : {
32 192 : OBJECT_ALLOCATOR(engraving, MMRest)
33 1429 : DECLARE_CLASSOF(ElementType::MMREST)
34 :
35 : public:
36 : MMRest(DummyParentOr<Segment> s);
37 : MMRest(const MMRest&, bool link = false);
38 :
39 0 : MMRest* clone() const override { return new MMRest(*this, false); }
40 0 : EngravingItem* linkedClone() override { return new MMRest(*this, true); }
41 :
42 : bool shouldShowNumberByDefault() const;
43 : bool showNumber() const;
44 :
45 : PropertyValue propertyDefault(Pid) const override;
46 : bool setProperty(Pid, const PropertyValue&) override;
47 : PropertyValue getProperty(Pid) const override;
48 :
49 : RectF numberRect() const override;
50 : PointF numberPos() const;
51 :
52 0 : void setNumberOffset(const Spatium y) { m_numberOffset = y; }
53 4 : Spatium numberOffset() const { return m_numberOffset; }
54 :
55 : double yNumberPos() const;
56 :
57 : bool isOldStyle() const;
58 :
59 : struct LayoutData : public Rest::LayoutData {
60 : int number = 0; // number of measures represented
61 : double yNumberPos = 0.0;
62 : SymIdList numberSym;
63 : SymIdList restSyms; // stores symbols when using old-style rests
64 : double symsWidth = 0.0; // width of symbols with spacing when using old-style
65 :
66 : ld_field<double> restWidth = { "[MMRest] restWidth", 0.0 }; // width of multimeasure rest
67 :
68 356 : void setNumberSym(int n) { numberSym = timeSigSymIdsFromString(String::number(n)); }
69 : };
70 4118 : DECLARE_LAYOUTDATA_METHODS(MMRest)
71 :
72 : private:
73 : Spatium m_numberOffset = 0.0_sp; // vertical offset of number relative to its style position
74 : bool m_numberVisible = false; // show or hide number
75 : };
76 : }
|