Skip to content

Commit f2b4a49

Browse files
committed
Implement unison labels
1 parent 75f6eeb commit f2b4a49

34 files changed

Lines changed: 436 additions & 38 deletions

src/engraving/dom/dom.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ set(DOM_SRC
295295
${CMAKE_CURRENT_LIST_DIR}/stafftext.h
296296
${CMAKE_CURRENT_LIST_DIR}/stafftextbase.cpp
297297
${CMAKE_CURRENT_LIST_DIR}/stafftextbase.h
298+
${CMAKE_CURRENT_LIST_DIR}/stavesharinglabel.cpp
299+
${CMAKE_CURRENT_LIST_DIR}/stavesharinglabel.h
298300
${CMAKE_CURRENT_LIST_DIR}/soundflag.cpp
299301
${CMAKE_CURRENT_LIST_DIR}/soundflag.h
300302
${CMAKE_CURRENT_LIST_DIR}/stafftype.cpp

src/engraving/dom/engravingobject.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class Staff;
160160
class StaffLines;
161161
class StaffState;
162162
class StaffText;
163+
class StaveSharingLabel;
163164
class StaffTextBase;
164165
class StaffTypeChange;
165166
class StaffVisibilityIndicator;
@@ -441,6 +442,7 @@ class EngravingObject
441442
CONVERT(MeasureNumber, MEASURE_NUMBER)
442443
CONVERT(MMRestRange, MMREST_RANGE)
443444
CONVERT(StaffText, STAFF_TEXT)
445+
CONVERT(StaveSharingLabel, STAVE_SHARING_LABEL)
444446
CONVERT(SystemText, SYSTEM_TEXT)
445447
CONVERT(SoundFlag, SOUND_FLAG)
446448
CONVERT(PlayCountText, PLAY_COUNT_TEXT)
@@ -571,7 +573,8 @@ class EngravingObject
571573

572574
bool isStaffTextBase() const
573575
{
574-
return isStaffText() || isSystemText() || isTripletFeel() || isPlayTechAnnotation() || isCapo() || isStringTunings();
576+
return isStaffText() || isStaveSharingLabel() || isSystemText() || isTripletFeel() || isPlayTechAnnotation() || isCapo()
577+
|| isStringTunings();
575578
}
576579

577580
bool isArticulationFamily() const
@@ -672,6 +675,7 @@ CONVERT(TripletFeel)
672675
CONVERT(Harmony)
673676
CONVERT(Jump)
674677
CONVERT(StaffText)
678+
CONVERT(StaveSharingLabel);
675679
CONVERT(StaffTextBase)
676680
CONVERT(TextBase)
677681
CONVERT(TextLineBase)

src/engraving/dom/factory.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#include "stafftext.h"
9696
#include "stafftypechange.h"
9797
#include "staffvisibilityindicator.h"
98+
#include "stavesharinglabel.h"
9899
#include "stem.h"
99100
#include "stemslash.h"
100101
#include "sticking.h"
@@ -180,6 +181,7 @@ EngravingItem* Factory::doCreateItem(ElementType type, EngravingItem* parent)
180181
case ElementType::MMREST_RANGE: return new MMRestRange(parent->isMeasure() ? toMeasure(parent) : dummy->measure());
181182
case ElementType::INSTRUMENT_NAME: return new InstrumentName(parent->isSystem() ? toSystem(parent) : dummy->system());
182183
case ElementType::STAFF_TEXT: return new StaffText(parent->isSegment() ? toSegment(parent) : dummy->segment());
184+
case ElementType::STAVE_SHARING_LABEL: return new StaveSharingLabel(parent->isSegment() ? toSegment(parent) : dummy->segment());
183185
case ElementType::PLAY_COUNT_TEXT: return new PlayCountText(parent->isSegment() ? toSegment(parent) : dummy->segment());
184186
case ElementType::PLAYTECH_ANNOTATION: return new PlayTechAnnotation(parent->isSegment() ? toSegment(parent) : dummy->segment());
185187
case ElementType::CAPO: return new Capo(parent->isSegment() ? toSegment(parent) : dummy->segment());
@@ -538,6 +540,13 @@ StaffText* Factory::createStaffText(Segment * parent, TextStyleType textStyleTyp
538540
return staffText;
539541
}
540542

543+
StaveSharingLabel* Factory::createStaveSharingLabel(Segment* parent, TextStyleType textStyleType, bool isAccessibleEnabled)
544+
{
545+
StaveSharingLabel* staveSharingLabel = new StaveSharingLabel(parent, textStyleType);
546+
staveSharingLabel->setAccessibleEnabled(isAccessibleEnabled);
547+
return staveSharingLabel;
548+
}
549+
541550
CREATE_ITEM_IMPL(SoundFlag, EngravingItem, isAccessibleEnabled)
542551

543552
CREATE_ITEM_IMPL(Expression, Segment, isAccessibleEnabled)

src/engraving/dom/factory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class Factory
185185
static std::shared_ptr<StaffTypeChange> makeStaffTypeChange(MeasureBase* parent);
186186

187187
static StaffText* createStaffText(Segment* parent, TextStyleType textStyleType = TextStyleType::STAFF, bool isAccessibleEnabled = true);
188+
static StaveSharingLabel* createStaveSharingLabel(Segment* parent, TextStyleType textStyleType = TextStyleType::STAVE_SHARING,
189+
bool isAccessibleEnabled = true);
188190

189191
static SoundFlag* createSoundFlag(EngravingItem* parent, bool isAccessibleEnabled = true);
190192

src/engraving/dom/segment.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ void Segment::add(EngravingItem* el)
704704
case ElementType::EXPRESSION:
705705
case ElementType::SYMBOL:
706706
case ElementType::STAFF_TEXT:
707+
case ElementType::STAVE_SHARING_LABEL:
707708
case ElementType::SYSTEM_TEXT:
708709
case ElementType::TRIPLET_FEEL:
709710
case ElementType::PLAYTECH_ANNOTATION:
@@ -905,6 +906,7 @@ void Segment::remove(EngravingItem* el)
905906
case ElementType::MARKER:
906907
case ElementType::REHEARSAL_MARK:
907908
case ElementType::STAFF_TEXT:
909+
case ElementType::STAVE_SHARING_LABEL:
908910
case ElementType::SYSTEM_TEXT:
909911
case ElementType::TRIPLET_FEEL:
910912
case ElementType::PLAYTECH_ANNOTATION:
@@ -1974,6 +1976,7 @@ EngravingItem* Segment::nextElement(staff_idx_t activeStaff)
19741976
case ElementType::FRET_DIAGRAM:
19751977
case ElementType::TEMPO_TEXT:
19761978
case ElementType::STAFF_TEXT:
1979+
case ElementType::STAVE_SHARING_LABEL:
19771980
case ElementType::SYSTEM_TEXT:
19781981
case ElementType::TRIPLET_FEEL:
19791982
case ElementType::PLAYTECH_ANNOTATION:
@@ -2192,6 +2195,7 @@ EngravingItem* Segment::prevElement(staff_idx_t activeStaff)
21922195
case ElementType::FRET_DIAGRAM:
21932196
case ElementType::TEMPO_TEXT:
21942197
case ElementType::STAFF_TEXT:
2198+
case ElementType::STAVE_SHARING_LABEL:
21952199
case ElementType::SOUND_FLAG:
21962200
case ElementType::SYSTEM_TEXT:
21972201
case ElementType::TRIPLET_FEEL:

src/engraving/dom/select.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ muse::ByteArray Selection::symbolListMimeData() const
11501150
case ElementType::CAPO:
11511151
case ElementType::STRING_TUNINGS:
11521152
case ElementType::STAFF_TEXT:
1153+
case ElementType::STAVE_SHARING_LABEL:
11531154
seg = toStaffTextBase(e)->segment();
11541155
break;
11551156
case ElementType::EXPRESSION:
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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) 2026 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+
#include "stavesharinglabel.h"
23+
24+
namespace mu::engraving {
25+
static const ElementStyle STAVE_SHARING_LABEL_STYLE {
26+
{ Sid::staveSharingLabelPlacement, Pid::PLACEMENT },
27+
{ Sid::staveSharingLabelMinDistance, Pid::MIN_DISTANCE },
28+
};
29+
30+
StaveSharingLabel::StaveSharingLabel(Segment* parent, TextStyleType tid)
31+
: StaffTextBase(ElementType::STAVE_SHARING_LABEL, parent, tid, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
32+
{
33+
initElementStyle(&STAVE_SHARING_LABEL_STYLE);
34+
}
35+
} // namespace mu::engraving
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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) 2026 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 "stafftextbase.h"
25+
26+
namespace mu::engraving {
27+
class StaveSharingLabel final : public StaffTextBase
28+
{
29+
OBJECT_ALLOCATOR(engraving, StaveSharingLabel)
30+
DECLARE_CLASSOF(ElementType::STAVE_SHARING_LABEL)
31+
32+
public:
33+
StaveSharingLabel(Segment* parent = nullptr, TextStyleType tid = TextStyleType::STAVE_SHARING);
34+
35+
bool isEditAllowed(EditData&) const override { return false; }
36+
37+
StaveSharingLabel* clone() const override { return new StaveSharingLabel(*this); }
38+
};
39+
} // namespace mu::engraving

src/engraving/editing/edit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6400,6 +6400,7 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
64006400
&& et != ElementType::DYNAMIC
64016401
&& et != ElementType::EXPRESSION
64026402
&& et != ElementType::STAFF_TEXT
6403+
&& et != ElementType::STAVE_SHARING_LABEL
64036404
&& et != ElementType::SYSTEM_TEXT
64046405
&& et != ElementType::TRIPLET_FEEL
64056406
&& et != ElementType::PLAYTECH_ANNOTATION
@@ -6608,6 +6609,7 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
66086609
|| element->isDynamic()
66096610
|| element->isExpression()
66106611
|| element->isStaffText()
6612+
|| element->isStaveSharingLabel()
66116613
|| element->isPlayTechAnnotation()
66126614
|| element->isCapo()
66136615
|| element->isStringTunings()

src/engraving/rendering/editmode/editmoderenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void EditModeRenderer::drawItem(const EngravingItem* item, muse::draw::Painter*
109109
drawSlurTieSegment(item_cast<const SlurTieSegment*>(item), painter, ed, currentViewScaling, opt);
110110
break;
111111
case ElementType::STAFF_TEXT:
112+
case ElementType::STAVE_SHARING_LABEL:
112113
drawTextBase(item_cast<const TextBase*>(item), painter, ed, currentViewScaling, opt);
113114
break;
114115
case ElementType::STICKING:

0 commit comments

Comments
 (0)