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 "engravingitem.h"
26 : #include "line.h"
27 : #include "property.h"
28 : #include "../types/types.h"
29 :
30 : namespace mu::engraving {
31 : class Glissando;
32 : class Note;
33 : enum class GlissandoType : unsigned char;
34 :
35 : //---------------------------------------------------------
36 : // @@ GlissandoSegment
37 : //---------------------------------------------------------
38 :
39 : class GlissandoSegment final : public LineSegment
40 : {
41 304 : OBJECT_ALLOCATOR(engraving, GlissandoSegment)
42 : DECLARE_CLASSOF(ElementType::GLISSANDO_SEGMENT)
43 :
44 : public:
45 : GlissandoSegment(Glissando* sp);
46 :
47 0 : Glissando* glissando() const { return toGlissando(spanner()); }
48 :
49 5 : GlissandoSegment* clone() const override { return new GlissandoSegment(*this); }
50 :
51 : EngravingObject* propertyDelegate(Pid) const override;
52 : };
53 :
54 : //---------------------------------------------------------
55 : // Glissando
56 : //---------------------------------------------------------
57 :
58 : class Glissando final : public SLine
59 : {
60 332 : OBJECT_ALLOCATOR(engraving, Glissando)
61 1823 : DECLARE_CLASSOF(ElementType::GLISSANDO)
62 :
63 498 : M_PROPERTY(String, text, setText)
64 1001 : M_PROPERTY(GlissandoType, glissandoType, setGlissandoType)
65 401 : M_PROPERTY(GlissandoStyle, glissandoStyle, setGlissandoStyle)
66 270 : M_PROPERTY(bool, glissandoShift, setGlissandoShift)
67 175 : M_PROPERTY(String, fontFace, setFontFace)
68 175 : M_PROPERTY(double, fontSize, setFontSize)
69 370 : M_PROPERTY(bool, showText, setShowText)
70 175 : M_PROPERTY(FontStyle, fontStyle, setFontStyle)
71 252 : M_PROPERTY(int, easeIn, setEaseIn)
72 252 : M_PROPERTY(int, easeOut, setEaseOut)
73 :
74 : public:
75 : static constexpr double GLISS_PALETTE_WIDTH = 4.0;
76 : static constexpr double GLISS_PALETTE_HEIGHT = 4.0;
77 :
78 : Glissando(DummyParentOr<EngravingItem> parent);
79 : Glissando(const Glissando&);
80 :
81 2845 : Anchor anchor() const override { return Anchor::NOTE; }
82 :
83 : static Note* guessInitialNote(Chord* chord);
84 :
85 1398 : std::optional<bool> isHarpGliss() const { return m_isHarpGliss; }
86 160 : void setIsHarpGliss(std::optional<bool> v) { m_isHarpGliss = v; }
87 :
88 : // overridden inherited methods
89 8 : Glissando* clone() const override { return new Glissando(*this); }
90 :
91 : LineSegment* createLineSegment() override;
92 :
93 0 : bool allowTimeAnchor() const override { return false; }
94 :
95 : // property/style methods
96 : Sid getPropertyStyle(Pid id) const override;
97 : PropertyValue getProperty(Pid propertyId) const override;
98 : bool setProperty(Pid propertyId, const PropertyValue&) override;
99 : PropertyValue propertyDefault(Pid) const override;
100 :
101 : TranslatableString subtypeUserName() const override;
102 :
103 : static bool pitchSteps(const Spanner* spanner, std::vector<int>& pitchOffsets);
104 :
105 : protected:
106 389 : bool isInSpannerMap() const override { return false; }
107 :
108 : private:
109 :
110 : std::optional<bool> m_isHarpGliss = std::nullopt;
111 : };
112 : } // namespace mu::engraving
|