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 "textbase.h"
25 :
26 : namespace mu::engraving {
27 : class Dynamic;
28 : class Transaction;
29 :
30 : class Expression final : public TextBase
31 : {
32 39 : M_PROPERTY(bool, snapToDynamics, setSnapToDynamics)
33 1868 : DECLARE_CLASSOF(ElementType::EXPRESSION)
34 :
35 : public:
36 : Expression(DummyParentOr<Segment> parent);
37 : Expression(const Expression& expression);
38 :
39 : bool isEditAllowed(EditData&) const override;
40 :
41 1 : Expression* clone() const override { return new Expression(*this); }
42 : void setOwnershipParent(DummyParentOr<Segment> parent) { EngravingItem::setOwnershipParent(parent); }
43 :
44 68 : Segment* segment() const { return toSegment(ownershipParent()); }
45 :
46 : PropertyValue propertyDefault(Pid id) const override;
47 :
48 : double computeDynamicExpressionDistance(const Dynamic* snappedDyn) const;
49 :
50 : std::unique_ptr<ElementGroup> getDragGroup(std::function<bool(const EngravingItem*)> isDragged) override;
51 :
52 : bool acceptDrop(EditData& ed) const override;
53 : EngravingItem* drop(Transaction& tx, EditData& ed) override;
54 :
55 : PropertyValue getProperty(Pid propertyId) const override;
56 : bool setProperty(Pid propertyId, const PropertyValue& v) override;
57 : void mapPropertiesFromOldExpressions(StaffText* staffText);
58 :
59 : Dynamic* snappedDynamic() const;
60 :
61 68 : bool hasVoiceAssignmentProperties() const override { return true; }
62 :
63 : void reset() override;
64 :
65 40 : bool positionRelativeToNoteheadRest() const override { return true; }
66 : };
67 : }
|