Skip to content
2 changes: 2 additions & 0 deletions src/engraving/dom/dom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ set(DOM_SRC
${CMAKE_CURRENT_LIST_DIR}/stafftext.h
${CMAKE_CURRENT_LIST_DIR}/stafftextbase.cpp
${CMAKE_CURRENT_LIST_DIR}/stafftextbase.h
${CMAKE_CURRENT_LIST_DIR}/stavesharinglabel.cpp
${CMAKE_CURRENT_LIST_DIR}/stavesharinglabel.h
${CMAKE_CURRENT_LIST_DIR}/soundflag.cpp
${CMAKE_CURRENT_LIST_DIR}/soundflag.h
${CMAKE_CURRENT_LIST_DIR}/stafftype.cpp
Expand Down
14 changes: 10 additions & 4 deletions src/engraving/dom/engravingitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,16 @@ void EngravingItem::manageExclusionFromParts(bool exclude)
}
}

EngravingItem* EngravingItem::sharedItem() const
{
return ldata()->m_sharedItem;
}

const std::vector<EngravingItem*>& EngravingItem::originItems() const
{
return ldata()->m_originItems;
}

void EngravingItem::connectSharedItem(EngravingItem* sharedItem, EngravingItem* originItem)
{
if (originItem->ldata()->m_sharedItem == sharedItem) {
Expand All @@ -1333,10 +1343,6 @@ void EngravingItem::connectSharedItem(EngravingItem* sharedItem, EngravingItem*
return;
}

if ((originItem->ldata()->m_sharedItem && originItem->ldata()->m_sharedItem != sharedItem)) {
disconnectSharedItem(originItem->ldata()->m_sharedItem, originItem);
}

originItem->mutldata()->m_sharedItem = sharedItem;

std::vector<EngravingItem*>& curOriginItems = sharedItem->mutldata()->m_originItems;
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/engravingitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ class EngravingItem : public EngravingObject
virtual bool canBeExcludedFromOtherParts() const { return false; }
virtual void manageExclusionFromParts(bool exclude);

EngravingItem* sharedItem() const { return m_layoutData->m_sharedItem; }
const std::vector<EngravingItem*>& originItems() const { return m_layoutData->m_originItems; }
EngravingItem* sharedItem() const;
const std::vector<EngravingItem*>& originItems() const;
static void connectSharedItem(EngravingItem* sharedItem, EngravingItem* originItem);
static void disconnectSharedItem(EngravingItem* sharedItem, EngravingItem* originItem);
static void disconnectAllOriginItems(EngravingItem* sharedItem);
Expand Down
27 changes: 1 addition & 26 deletions src/engraving/dom/engravingobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,32 +727,7 @@ bool EngravingObject::isSLineSegment() const

bool EngravingObject::isTextBase() const
{
return type() == ElementType::TEXT
|| type() == ElementType::LYRICS
|| type() == ElementType::DYNAMIC
|| type() == ElementType::EXPRESSION
|| type() == ElementType::FINGERING
|| type() == ElementType::HARMONY
|| type() == ElementType::MARKER
|| type() == ElementType::JUMP
|| type() == ElementType::STAFF_TEXT
|| type() == ElementType::SYSTEM_TEXT
|| type() == ElementType::TRIPLET_FEEL
|| type() == ElementType::PLAY_COUNT_TEXT
|| type() == ElementType::PLAYTECH_ANNOTATION
|| type() == ElementType::CAPO
|| type() == ElementType::STRING_TUNINGS
|| type() == ElementType::REHEARSAL_MARK
|| type() == ElementType::INSTRUMENT_CHANGE
|| type() == ElementType::FIGURED_BASS
|| type() == ElementType::TEMPO_TEXT
|| type() == ElementType::INSTRUMENT_NAME
|| type() == ElementType::MEASURE_NUMBER
|| type() == ElementType::MMREST_RANGE
|| type() == ElementType::STICKING
|| type() == ElementType::HARP_DIAGRAM
|| type() == ElementType::GUITAR_BEND_TEXT
|| type() == ElementType::HAMMER_ON_PULL_OFF_TEXT;
return muse::contains(TEXTBASE_TYPES, type());
}

//---------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/engraving/dom/engravingobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class Staff;
class StaffLines;
class StaffState;
class StaffText;
class StaveSharingLabel;
class StaffTextBase;
class StaffTypeChange;
class StaffVisibilityIndicator;
Expand Down Expand Up @@ -441,6 +442,7 @@ class EngravingObject
CONVERT(MeasureNumber, MEASURE_NUMBER)
CONVERT(MMRestRange, MMREST_RANGE)
CONVERT(StaffText, STAFF_TEXT)
CONVERT(StaveSharingLabel, STAVE_SHARING_LABEL)
CONVERT(SystemText, SYSTEM_TEXT)
CONVERT(SoundFlag, SOUND_FLAG)
CONVERT(PlayCountText, PLAY_COUNT_TEXT)
Expand Down Expand Up @@ -571,7 +573,8 @@ class EngravingObject

bool isStaffTextBase() const
{
return isStaffText() || isSystemText() || isTripletFeel() || isPlayTechAnnotation() || isCapo() || isStringTunings();
return isStaffText() || isStaveSharingLabel() || isSystemText() || isTripletFeel() || isPlayTechAnnotation() || isCapo()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STAVE_SHARING_LABEL also needs to be added to TEXTBASE_TYPES in types.h for the TextBase conversion

|| isStringTunings();
}

bool isArticulationFamily() const
Expand Down Expand Up @@ -672,6 +675,7 @@ CONVERT(TripletFeel)
CONVERT(Harmony)
CONVERT(Jump)
CONVERT(StaffText)
CONVERT(StaveSharingLabel);
CONVERT(StaffTextBase)
CONVERT(TextBase)
CONVERT(TextLineBase)
Expand Down
9 changes: 9 additions & 0 deletions src/engraving/dom/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
#include "stafftext.h"
#include "stafftypechange.h"
#include "staffvisibilityindicator.h"
#include "stavesharinglabel.h"
#include "stem.h"
#include "stemslash.h"
#include "sticking.h"
Expand Down Expand Up @@ -180,6 +181,7 @@ EngravingItem* Factory::doCreateItem(ElementType type, EngravingItem* parent)
case ElementType::MMREST_RANGE: return new MMRestRange(parent->isMeasure() ? toMeasure(parent) : dummy->measure());
case ElementType::INSTRUMENT_NAME: return new InstrumentName(parent->isSystem() ? toSystem(parent) : dummy->system());
case ElementType::STAFF_TEXT: return new StaffText(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::STAVE_SHARING_LABEL: return new StaveSharingLabel(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::PLAY_COUNT_TEXT: return new PlayCountText(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::PLAYTECH_ANNOTATION: return new PlayTechAnnotation(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::CAPO: return new Capo(parent->isSegment() ? toSegment(parent) : dummy->segment());
Expand Down Expand Up @@ -538,6 +540,13 @@ StaffText* Factory::createStaffText(Segment * parent, TextStyleType textStyleTyp
return staffText;
}

StaveSharingLabel* Factory::createStaveSharingLabel(Segment* parent, TextStyleType textStyleType, bool isAccessibleEnabled)
{
StaveSharingLabel* staveSharingLabel = new StaveSharingLabel(parent, textStyleType);
staveSharingLabel->setAccessibleEnabled(isAccessibleEnabled);
return staveSharingLabel;
}

CREATE_ITEM_IMPL(SoundFlag, EngravingItem, isAccessibleEnabled)

CREATE_ITEM_IMPL(Expression, Segment, isAccessibleEnabled)
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class Factory
static std::shared_ptr<StaffTypeChange> makeStaffTypeChange(MeasureBase* parent);

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

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

Expand Down
4 changes: 4 additions & 0 deletions src/engraving/dom/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ void Segment::add(EngravingItem* el)
case ElementType::EXPRESSION:
case ElementType::SYMBOL:
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
case ElementType::SYSTEM_TEXT:
case ElementType::TRIPLET_FEEL:
case ElementType::PLAYTECH_ANNOTATION:
Expand Down Expand Up @@ -905,6 +906,7 @@ void Segment::remove(EngravingItem* el)
case ElementType::MARKER:
case ElementType::REHEARSAL_MARK:
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
case ElementType::SYSTEM_TEXT:
case ElementType::TRIPLET_FEEL:
case ElementType::PLAYTECH_ANNOTATION:
Expand Down Expand Up @@ -1977,6 +1979,7 @@ EngravingItem* Segment::nextElement(staff_idx_t activeStaff)
case ElementType::FRET_DIAGRAM:
case ElementType::TEMPO_TEXT:
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
case ElementType::SYSTEM_TEXT:
case ElementType::TRIPLET_FEEL:
case ElementType::PLAYTECH_ANNOTATION:
Expand Down Expand Up @@ -2195,6 +2198,7 @@ EngravingItem* Segment::prevElement(staff_idx_t activeStaff)
case ElementType::FRET_DIAGRAM:
case ElementType::TEMPO_TEXT:
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
case ElementType::SOUND_FLAG:
case ElementType::SYSTEM_TEXT:
case ElementType::TRIPLET_FEEL:
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ muse::ByteArray Selection::symbolListMimeData() const
case ElementType::CAPO:
case ElementType::STRING_TUNINGS:
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
seg = toStaffTextBase(e)->segment();
break;
case ElementType::EXPRESSION:
Expand Down
35 changes: 35 additions & 0 deletions src/engraving/dom/stavesharinglabel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "stavesharinglabel.h"

namespace mu::engraving {
static const ElementStyle STAVE_SHARING_LABEL_STYLE {
{ Sid::staveSharingLabelPlacement, Pid::PLACEMENT },
{ Sid::staveSharingLabelMinDistance, Pid::MIN_DISTANCE },
};

StaveSharingLabel::StaveSharingLabel(Segment* parent, TextStyleType tid)
: StaffTextBase(ElementType::STAVE_SHARING_LABEL, parent, tid, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
{
initElementStyle(&STAVE_SHARING_LABEL_STYLE);
}
} // namespace mu::engraving
39 changes: 39 additions & 0 deletions src/engraving/dom/stavesharinglabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once

#include "stafftextbase.h"

namespace mu::engraving {
class StaveSharingLabel final : public StaffTextBase
{
OBJECT_ALLOCATOR(engraving, StaveSharingLabel)
DECLARE_CLASSOF(ElementType::STAVE_SHARING_LABEL)

public:
StaveSharingLabel(Segment* parent = nullptr, TextStyleType tid = TextStyleType::STAVE_SHARING);

bool isEditAllowed(EditData&) const override { return false; }

StaveSharingLabel* clone() const override { return new StaveSharingLabel(*this); }
};
} // namespace mu::engraving
2 changes: 2 additions & 0 deletions src/engraving/editing/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6430,6 +6430,7 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
&& et != ElementType::DYNAMIC
&& et != ElementType::EXPRESSION
&& et != ElementType::STAFF_TEXT
&& et != ElementType::STAVE_SHARING_LABEL
&& et != ElementType::SYSTEM_TEXT
&& et != ElementType::TRIPLET_FEEL
&& et != ElementType::PLAYTECH_ANNOTATION
Expand Down Expand Up @@ -6638,6 +6639,7 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
|| element->isDynamic()
|| element->isExpression()
|| element->isStaffText()
|| element->isStaveSharingLabel()
|| element->isPlayTechAnnotation()
|| element->isCapo()
|| element->isStringTunings()
Expand Down
1 change: 1 addition & 0 deletions src/engraving/rendering/editmode/editmoderenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void EditModeRenderer::drawItem(const EngravingItem* item, muse::draw::Painter*
drawSlurTieSegment(item_cast<const SlurTieSegment*>(item), painter, ed, currentViewScaling, opt);
break;
case ElementType::STAFF_TEXT:
case ElementType::STAVE_SHARING_LABEL:
drawTextBase(item_cast<const TextBase*>(item), painter, currentViewScaling, opt);
break;
case ElementType::STICKING:
Expand Down
Loading
Loading