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 :
27 : namespace mu::engraving {
28 : class Chord;
29 : class Transaction;
30 :
31 : class Stem final : public EngravingItem
32 : {
33 56492 : OBJECT_ALLOCATOR(engraving, Stem)
34 1106 : DECLARE_CLASSOF(ElementType::STEM)
35 :
36 : public:
37 :
38 2514 : Stem(const Stem&) = default;
39 : Stem& operator=(const Stem&) = delete;
40 :
41 0 : Stem* clone() const override { return new Stem(*this); }
42 :
43 : EngravingItem* elementBase() const override;
44 :
45 0 : bool isEditable() const override { return true; }
46 : void startEdit(EditData&) override;
47 : void startDragGrip(EditData&) override;
48 : void dragGrip(EditData&) override;
49 :
50 : bool acceptDrop(EditData&) const override;
51 : EngravingItem* drop(Transaction& tx, EditData&) override;
52 :
53 : void reset() override;
54 : PropertyValue getProperty(Pid propertyId) const override;
55 : bool setProperty(Pid propertyId, const PropertyValue&) override;
56 : PropertyValue propertyDefault(Pid id) const override;
57 :
58 : staff_idx_t vStaffIdx() const override;
59 :
60 2197210 : Chord* chord() const { return toChord(ownershipParent()); }
61 : bool up() const;
62 :
63 60452 : Spatium baseLength() const { return m_baseLength; }
64 : void setBaseLength(Spatium baseLength);
65 :
66 16696 : Spatium userLength() const { return m_userLength; }
67 27510 : void setUserLength(Spatium userLength) { m_userLength = userLength; }
68 :
69 33392 : Spatium lineWidth() const { return m_lineWidth; }
70 : double lineWidthMag() const;
71 28004 : void setLineWidth(Spatium lineWidth) { m_lineWidth = lineWidth; }
72 :
73 : PointF flagPosition() const;
74 221884 : double length() const { return absoluteFromSpatium(m_baseLength + m_userLength); }
75 :
76 0 : bool needStartEditingAfterSelecting() const override { return true; }
77 0 : int gripsCount() const override { return 1; }
78 0 : Grip initialEditModeGrip() const override { return Grip::START; }
79 0 : Grip defaultGrip() const override { return Grip::START; }
80 : std::vector<PointF> gripsPositions(const EditData&) const override;
81 :
82 : struct LayoutData : public EngravingItem::LayoutData {
83 : LineF line;
84 : double beamCorrection = 0.0;
85 : };
86 726520 : DECLARE_LAYOUTDATA_METHODS(Stem)
87 :
88 : private:
89 : friend class Factory;
90 : Stem(DummyParentOr<Chord> parent);
91 :
92 : Spatium m_baseLength = 0.0_sp;
93 :
94 : Spatium m_userLength = 0.0_sp;
95 : Spatium m_lineWidth = 0.0_sp;
96 : };
97 : }
|