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 8737 : 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 : void setOwnershipParent(DummyParentOr<System> parent) { EngravingItem::setOwnershipParent(parent); }
53 :
54 18519 : InstrumentNameType instrumentNameType() const { return m_instrumentNameType; }
55 : void setInstrumentNameType(InstrumentNameType v);
56 :
57 30658 : InstrumentNameRole instrumentNameRole() const { return m_instrumentNameRole; }
58 4398 : void setInstrumentNameRole(InstrumentNameRole v) { m_instrumentNameRole = v; }
59 :
60 142 : System* system() const { return toSystem(ownershipParent()); }
61 :
62 : SysStaff* sysStaff() const { return m_sysStaff; }
63 8796 : void setSysStaff(SysStaff* s) { m_sysStaff = s; }
64 :
65 : double largestStaffSpatium() const;
66 :
67 0 : bool isEditable() const override { return false; }
68 :
69 : bool setProperty(Pid propertyId, const PropertyValue&) override;
70 :
71 42974 : bool positionRelativeToNoteheadRest() const override { return false; }
72 :
73 : staff_idx_t effectiveStaffIdx() const override;
74 :
75 : struct LayoutData : public TextBase::LayoutData {
76 : public:
77 27555 : int column() const { return m_column; }
78 19427 : void setColumn(int v) { m_column = v; }
79 1363 : staff_idx_t endIdxOfGroup() const { return m_endIdxOfGroup; }
80 202 : void setEndIdxOfGroup(staff_idx_t v) { m_endIdxOfGroup = v; }
81 :
82 : private:
83 : int m_column = 0;
84 : staff_idx_t m_endIdxOfGroup = muse::nidx; // one-after last spanned staff (for GROUP types)
85 : };
86 121819 : DECLARE_LAYOUTDATA_METHODS(InstrumentName)
87 :
88 : private:
89 :
90 : InstrumentNameType m_instrumentNameType = InstrumentNameType::LONG;
91 : InstrumentNameRole m_instrumentNameRole = InstrumentNameRole::PART;
92 : SysStaff* m_sysStaff = nullptr;
93 : };
94 : } // namespace mu::engraving
95 : #endif
|