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) 2025 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 "transaction/undoablecommand.h"
26 :
27 : #include "../dom/staff.h"
28 :
29 : namespace mu::engraving {
30 : class ChangeProperty : public UndoableCommand
31 : {
32 5749 : OBJECT_ALLOCATOR(engraving, ChangeProperty)
33 : protected:
34 : EngravingObject* element = nullptr;
35 : Pid id;
36 : PropertyValue property;
37 : PropertyFlags flags;
38 :
39 : void flip() override;
40 :
41 : public:
42 3115 : ChangeProperty(EngravingObject* e, Pid i, const PropertyValue& v, PropertyFlags ps = PropertyFlags::NOSTYLE)
43 3115 : : element(e), id(i), property(v), flags(ps) {}
44 :
45 2310 : Pid getId() const { return id; }
46 : EngravingObject* getElement() const { return element; }
47 : PropertyValue data() const { return property; }
48 :
49 2310 : UNDO_TYPE(CommandType::ChangeProperty)
50 0 : UNDO_NAME("ChangeProperty")
51 :
52 : std::vector<EngravingObject*> objectItems() const override;
53 :
54 0 : bool matchesFilter(UndoableCommandFilter f, const EngravingItem* target) const override
55 : {
56 0 : return f == UndoableCommandFilter::ChangePropertyLinked && muse::contains(target->linkList(), element);
57 : }
58 : };
59 :
60 : class ChangeBracketProperty : public ChangeProperty
61 : {
62 4 : OBJECT_ALLOCATOR(engraving, ChangeBracketProperty)
63 :
64 : Staff* staff = nullptr;
65 : size_t level = 0;
66 :
67 : void flip() override;
68 :
69 : public:
70 3 : ChangeBracketProperty(Staff* s, size_t l, Pid i, const PropertyValue& v, PropertyFlags ps = PropertyFlags::NOSTYLE)
71 3 : : ChangeProperty(nullptr, i, v, ps), staff(s), level(l) {}
72 0 : UNDO_NAME("ChangeBracketProperty")
73 3 : UNDO_CHANGED_OBJECTS({ })
74 : };
75 :
76 : class ChangeTextLineProperty : public ChangeProperty
77 : {
78 0 : OBJECT_ALLOCATOR(engraving, ChangeTextLineProperty)
79 :
80 : void flip() override;
81 :
82 : public:
83 0 : ChangeTextLineProperty(EngravingObject* e, PropertyValue v)
84 0 : : ChangeProperty(e, Pid::SYSTEM_FLAG, v, PropertyFlags::NOSTYLE) {}
85 0 : UNDO_NAME("ChangeTextLineProperty")
86 : };
87 : }
|