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_INSTRUMENTNAME_H
24 : #define MU_ENGRAVING_INSTRUMENTNAME_H
25 :
26 : #include "textbase.h"
27 :
28 : namespace mu::engraving {
29 : enum class InstrumentNameType : char {
30 : LONG, SHORT
31 : };
32 : enum class InstrumentNameRole : char {
33 : STAFF, SHARED_STAFF, PART, GROUP
34 : };
35 :
36 : class System;
37 : class SysStaff;
38 :
39 : //---------------------------------------------------------
40 : // InstrumentName
41 : //---------------------------------------------------------
42 :
43 : class InstrumentName final : public TextBase
44 : {
45 7483 : OBJECT_ALLOCATOR(engraving, InstrumentName)
46 : DECLARE_CLASSOF(ElementType::INSTRUMENT_NAME)
47 :
48 : public:
49 : InstrumentName(DummyParentOr<System>);
50 :
51 0 : InstrumentName* clone() const override { return new InstrumentName(*this); }
52 :
53 15649 : InstrumentNameType instrumentNameType() const { return m_instrumentNameType; }
54 : void setInstrumentNameType(InstrumentNameType v);
55 :
56 26761 : InstrumentNameRole instrumentNameRole() const { return m_instrumentNameRole; }
57 3771 : void setInstrumentNameRole(InstrumentNameRole v) { m_instrumentNameRole = v; }
58 :
59 142 : System* system() const { return toSystem(ownershipParent()); }
60 :
61 : SysStaff* sysStaff() const { return m_sysStaff; }
62 7542 : void setSysStaff(SysStaff* s) { m_sysStaff = s; }
63 :
64 : double largestStaffSpatium() const;
65 :
66 0 : bool isEditable() const override { return false; }
67 :
68 : bool setProperty(Pid propertyId, const PropertyValue&) override;
69 :
70 34087 : bool positionRelativeToNoteheadRest() const override { return false; }
71 :
72 : staff_idx_t effectiveStaffIdx() const override;
73 :
74 : struct LayoutData : public TextBase::LayoutData {
75 : public:
76 23311 : int column() const { return m_column; }
77 15945 : void setColumn(int v) { m_column = v; }
78 893 : staff_idx_t endIdxOfGroup() const { return m_endIdxOfGroup; }
79 134 : void setEndIdxOfGroup(staff_idx_t v) { m_endIdxOfGroup = v; }
80 :
81 : private:
82 : int m_column = 0;
83 : staff_idx_t m_endIdxOfGroup = muse::nidx; // one-after last spanned staff (for GROUP types)
84 : };
85 99997 : DECLARE_LAYOUTDATA_METHODS(InstrumentName)
86 :
87 : private:
88 :
89 : InstrumentNameType m_instrumentNameType = InstrumentNameType::LONG;
90 : InstrumentNameRole m_instrumentNameRole = InstrumentNameRole::PART;
91 : SysStaff* m_sysStaff = nullptr;
92 : };
93 : } // namespace mu::engraving
94 : #endif
|