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 : #ifndef MU_ENGRAVING_BRACKET_ITEM_H
24 : #define MU_ENGRAVING_BRACKET_ITEM_H
25 :
26 : #include "engravingitem.h"
27 : #include "stafflabel.h"
28 :
29 : #include "../types/types.h"
30 :
31 : namespace mu::engraving {
32 : class Factory;
33 :
34 : //---------------------------------------------------------
35 : // BracketItem
36 : //---------------------------------------------------------
37 :
38 : class BracketItem final : public EngravingItem
39 : {
40 2378 : OBJECT_ALLOCATOR(engraving, BracketItem)
41 :
42 : public:
43 : EngravingItem* clone() const override;
44 : void setOwnershipParent(DummyParentOr<Staff> parent) { EngravingItem::setOwnershipParent(parent); }
45 :
46 : PropertyValue getProperty(Pid) const override;
47 : bool setProperty(Pid, const PropertyValue&) override;
48 : PropertyValue propertyDefault(Pid id) const override;
49 :
50 10344 : size_t bracketSpan() const { return m_bracketSpan; }
51 58999 : BracketType bracketType() const { return m_bracketType; }
52 741 : void setBracketSpan(size_t v) { m_bracketSpan = v; }
53 923 : void setBracketType(BracketType v) { m_bracketType = v; }
54 1 : staff_idx_t startStaffIdx() const { return m_startStaffIdx; }
55 1455 : void setStartStaffIdx(staff_idx_t staffIdx) { m_startStaffIdx = staffIdx; }
56 : Staff* startStaff() const;
57 41857 : size_t column() const { return m_column; }
58 1191 : void setColumn(size_t v) { m_column = v; }
59 :
60 0 : StaffLabel& label() { return m_name; }
61 0 : const StaffLabel& label() const { return m_name; }
62 0 : const String& longName() const { return m_name.longName(); }
63 0 : const String& shortName() const { return m_name.shortName(); }
64 :
65 0 : bool showText() const { return m_showText; }
66 0 : bool showBracket() const { return m_showBracket; }
67 :
68 : bool intersects(const BracketItem* other) const;
69 : bool intersects(staff_idx_t first, staff_idx_t last) const;
70 :
71 : private:
72 :
73 : friend class Factory;
74 :
75 : BracketItem(DummyParentOr<Staff> parent);
76 : BracketItem(DummyParentOr<Staff> parent, BracketType bracketType, size_t span);
77 :
78 : BracketType m_bracketType = BracketType::NO_BRACKET;
79 : size_t m_column = 0;
80 : size_t m_bracketSpan = 0;
81 : staff_idx_t m_startStaffIdx = muse::nidx;
82 :
83 : StaffLabel m_name = StaffLabel(muse::mtrc("systemBrackets", "GROUP"), muse::mtrc("systemBrackets", "GR.", "Short for GROUP"));
84 : bool m_showText = true;
85 : bool m_showBracket = true;
86 : };
87 : }
88 : #endif
|