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 1866 : 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 :
43 68 : Segment* segment() const { return toSegment(ownershipParent()); }
44 :
45 : PropertyValue propertyDefault(Pid id) const override;
46 :
47 : double computeDynamicExpressionDistance(const Dynamic* snappedDyn) const;
48 :
49 : std::unique_ptr<ElementGroup> getDragGroup(std::function<bool(const EngravingItem*)> isDragged) override;
50 :
51 : bool acceptDrop(EditData& ed) const override;
52 : EngravingItem* drop(Transaction& tx, EditData& ed) override;
53 :
54 : PropertyValue getProperty(Pid propertyId) const override;
55 : bool setProperty(Pid propertyId, const PropertyValue& v) override;
56 : void mapPropertiesFromOldExpressions(StaffText* staffText);
57 :
58 : Dynamic* snappedDynamic() const;
59 :
60 68 : bool hasVoiceAssignmentProperties() const override { return true; }
61 :
62 : void reset() override;
63 :
64 40 : bool positionRelativeToNoteheadRest() const override { return true; }
65 : };
66 : }
|