Skip to content

Commit d3e0a74

Browse files
authored
Merge pull request #28245 from mike-spa/tapping
Tapping implementation
2 parents 7dd55e8 + f8519ac commit d3e0a74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1500
-128
lines changed

src/engraving/dom/articulation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ class Articulation : public EngravingItem
110110
Articulation(const Articulation&) = default;
111111
Articulation& operator=(const Articulation&) = delete;
112112

113-
Articulation* clone() const override { return new Articulation(*this); }
113+
virtual Articulation* clone() const override { return new Articulation(*this); }
114114

115-
double mag() const override;
115+
virtual double mag() const override;
116116

117117
SymId symId() const { return m_symId; }
118118
void setSymId(SymId id);
119-
int subtype() const override;
119+
virtual int subtype() const override;
120120
void setTextType(ArticulationTextType textType);
121121
ArticulationTextType textType() const { return m_textType; }
122122
TranslatableString typeUserName() const override;
@@ -158,7 +158,7 @@ class Articulation : public EngravingItem
158158
String channelName() const { return m_channelName; }
159159
void setChannelName(const String& s) { m_channelName = s; }
160160

161-
String accessibleInfo() const override;
161+
virtual String accessibleInfo() const override;
162162

163163
bool isDouble() const { return m_categories & ArticulationCategory::DOUBLE; }
164164
bool isTenuto() const { return m_categories & ArticulationCategory::TENUTO; }

src/engraving/dom/chord.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ void Chord::add(EngravingItem* e)
634634
break;
635635
case ElementType::ARTICULATION:
636636
case ElementType::ORNAMENT:
637+
case ElementType::TAPPING:
637638
{
638639
Articulation* a = toArticulation(e);
639640
if (a->layoutCloseToNote()) {
@@ -736,6 +737,7 @@ void Chord::remove(EngravingItem* e)
736737
break;
737738
case ElementType::ARTICULATION:
738739
case ElementType::ORNAMENT:
740+
case ElementType::TAPPING:
739741
{
740742
Articulation* a = toArticulation(e);
741743
if (!muse::remove(m_articulations, a)) {
@@ -1331,6 +1333,7 @@ EngravingItem* Chord::drop(EditData& data)
13311333
switch (e->type()) {
13321334
case ElementType::ARTICULATION:
13331335
case ElementType::ORNAMENT:
1336+
case ElementType::TAPPING:
13341337
{
13351338
Articulation* atr = toArticulation(e);
13361339
Articulation* oa = hasArticulation(atr);
@@ -1604,6 +1607,20 @@ Articulation* Chord::hasArticulation(const Articulation* aa)
16041607
return 0;
16051608
}
16061609

1610+
Tapping* Chord::tapping() const
1611+
{
1612+
std::vector<Tapping*> tappings;
1613+
tappings.reserve(1);
1614+
for (Articulation* a : m_articulations) {
1615+
if (a->isTapping()) {
1616+
tappings.push_back(toTapping(a));
1617+
}
1618+
}
1619+
DO_ASSERT(tappings.size() <= 1);
1620+
1621+
return tappings.size() > 0 ? tappings.front() : nullptr;
1622+
}
1623+
16071624
void Chord::updateArticulations(const std::set<SymId>& newArticulationIds, ArticulationsUpdateMode updateMode)
16081625
{
16091626
Articulation* staccato = nullptr;

src/engraving/dom/chord.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class Chord final : public ChordRest
247247
const std::vector<Articulation*>& articulations() const { return m_articulations; }
248248
std::set<SymId> articulationSymbolIds() const;
249249
Articulation* hasArticulation(const Articulation*);
250+
Tapping* tapping() const;
250251
bool hasSingleArticulation() const { return m_articulations.size() == 1; }
251252

252253
void updateArticulations(const std::set<SymId>& newArticulationIds,

src/engraving/dom/chordrest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ EngravingItem* ChordRest::nextElement()
934934
switch (e->type()) {
935935
case ElementType::ARTICULATION:
936936
case ElementType::ORNAMENT:
937+
case ElementType::TAPPING:
937938
case ElementType::LYRICS: {
938939
EngravingItem* next = nextArticulationOrLyric(e);
939940
if (next) {
@@ -969,6 +970,7 @@ EngravingItem* ChordRest::prevElement()
969970
switch (e->type()) {
970971
case ElementType::ARTICULATION:
971972
case ElementType::ORNAMENT:
973+
case ElementType::TAPPING:
972974
case ElementType::LYRICS: {
973975
EngravingItem* prev = prevArticulationOrLyric(e);
974976
if (prev) {

src/engraving/dom/cmd.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,13 @@ bool Score::toggleArticulation(EngravingItem* el, Articulation* a)
24092409
return false;
24102410
}
24112411

2412+
Tapping* tap = c->tapping();
2413+
if (tap) {
2414+
// If we got here it means that the user is entering a tap
2415+
// of different hand, so replace the old one
2416+
undoRemoveElement(tap);
2417+
}
2418+
24122419
if (!a->isDouble()) {
24132420
a->setParent(c);
24142421
a->setTrack(c->track());

src/engraving/dom/dom.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ set(DOM_SRC
332332
${CMAKE_CURRENT_LIST_DIR}/systemdivider.h
333333
${CMAKE_CURRENT_LIST_DIR}/systemtext.cpp
334334
${CMAKE_CURRENT_LIST_DIR}/systemtext.h
335+
${CMAKE_CURRENT_LIST_DIR}/tapping.cpp
336+
${CMAKE_CURRENT_LIST_DIR}/tapping.h
335337
${CMAKE_CURRENT_LIST_DIR}/tempo.cpp
336338
${CMAKE_CURRENT_LIST_DIR}/tempo.h
337339
${CMAKE_CURRENT_LIST_DIR}/tempotext.cpp

src/engraving/dom/edit.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,6 +3104,14 @@ void Score::deleteItem(EngravingItem* el)
31043104
}
31053105
break;
31063106

3107+
case ElementType::TAPPING_HALF_SLUR_SEGMENT:
3108+
{
3109+
TappingHalfSlur* halfSlur = toTappingHalfSlur(toTappingHalfSlurSegment(el)->spanner());
3110+
Tapping* tapping = toTapping(halfSlur->parent());
3111+
undoRemoveElement(tapping);
3112+
break;
3113+
}
3114+
31073115
case ElementType::HAMMER_ON_PULL_OFF_TEXT:
31083116
undoRemoveHopoText(toHammerOnPullOffText(el));
31093117
break;
@@ -6349,6 +6357,7 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
63496357
if (ostaff == 0 || (
63506358
et != ElementType::ARTICULATION
63516359
&& et != ElementType::ORNAMENT
6360+
&& et != ElementType::TAPPING
63526361
&& et != ElementType::CHORDLINE
63536362
&& et != ElementType::LYRICS
63546363
&& et != ElementType::SLUR

src/engraving/dom/engravingobject.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class SystemDivider;
164164
class SystemLockIndicator;
165165
class SystemText;
166166
class SoundFlag;
167+
class Tapping;
168+
class TappingHalfSlur;
169+
class TappingHalfSlurSegment;
167170
class TBox;
168171
class TempoText;
169172
class Text;
@@ -456,6 +459,9 @@ class EngravingObject
456459
CONVERT(HammerOnPullOff, HAMMER_ON_PULL_OFF)
457460
CONVERT(HammerOnPullOffSegment, HAMMER_ON_PULL_OFF_SEGMENT)
458461
CONVERT(HammerOnPullOffText, HAMMER_ON_PULL_OFF_TEXT)
462+
CONVERT(Tapping, TAPPING)
463+
CONVERT(TappingHalfSlur, TAPPING_HALF_SLUR)
464+
CONVERT(TappingHalfSlurSegment, TAPPING_HALF_SLUR_SEGMENT)
459465
#undef CONVERT
460466

461467
virtual bool isEngravingItem() const { return false; } // overridden in element.h
@@ -487,12 +493,13 @@ class EngravingObject
487493

488494
bool isSlur() const
489495
{
490-
return type() == ElementType::SLUR || type() == ElementType::HAMMER_ON_PULL_OFF;
496+
return type() == ElementType::SLUR || type() == ElementType::HAMMER_ON_PULL_OFF || type() == ElementType::TAPPING_HALF_SLUR;
491497
}
492498

493499
bool isSlurSegment() const
494500
{
495-
return type() == ElementType::SLUR_SEGMENT || type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT;
501+
return type() == ElementType::SLUR_SEGMENT || type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT
502+
|| type() == ElementType::TAPPING_HALF_SLUR_SEGMENT;
496503
}
497504

498505
bool isLineSegment() const
@@ -572,7 +579,7 @@ class EngravingObject
572579

573580
bool isArticulationFamily() const
574581
{
575-
return isArticulation() || isOrnament();
582+
return isArticulation() || isOrnament() || isTapping();
576583
}
577584

578585
bool isArticulationOrFermata() const
@@ -636,7 +643,7 @@ static inline SlurTieSegment* toSlurTieSegment(EngravingObject* e)
636643
assert(
637644
e == 0 || e->type() == ElementType::SLUR_SEGMENT || e->type() == ElementType::TIE_SEGMENT
638645
|| e->type() == ElementType::LAISSEZ_VIB_SEGMENT || e->type() == ElementType::PARTIAL_TIE_SEGMENT
639-
|| e->type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT);
646+
|| e->type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT || e->type() == ElementType::TAPPING_HALF_SLUR_SEGMENT);
640647
return (SlurTieSegment*)e;
641648
}
642649

@@ -645,7 +652,7 @@ static inline const SlurTieSegment* toSlurTieSegment(const EngravingObject* e)
645652
assert(
646653
e == 0 || e->type() == ElementType::SLUR_SEGMENT || e->type() == ElementType::TIE_SEGMENT
647654
|| e->type() == ElementType::LAISSEZ_VIB_SEGMENT || e->type() == ElementType::PARTIAL_TIE_SEGMENT
648-
|| e->type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT);
655+
|| e->type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT || e->type() == ElementType::TAPPING_HALF_SLUR_SEGMENT);
649656
return (const SlurTieSegment*)e;
650657
}
651658

@@ -890,5 +897,8 @@ CONVERT(ShadowNote)
890897
CONVERT(HammerOnPullOff)
891898
CONVERT(HammerOnPullOffSegment)
892899
CONVERT(HammerOnPullOffText)
900+
CONVERT(Tapping)
901+
CONVERT(TappingHalfSlur)
902+
CONVERT(TappingHalfSlurSegment)
893903
#undef CONVERT
894904
}

src/engraving/dom/factory.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
#include "systemlock.h"
103103
#include "systemtext.h"
104104
#include "soundflag.h"
105+
#include "tapping.h"
105106
#include "tempotext.h"
106107
#include "text.h"
107108
#include "textline.h"
@@ -164,6 +165,7 @@ EngravingItem* Factory::doCreateItem(ElementType type, EngravingItem* parent)
164165
case ElementType::GLISSANDO: return new Glissando(parent);
165166
case ElementType::BRACKET: return new Bracket(parent);
166167
case ElementType::ARTICULATION: return new Articulation(parent->isChordRest() ? toChordRest(parent) : dummy->chord());
168+
case ElementType::TAPPING: return new Tapping(parent->isChordRest() ? toChordRest(parent) : dummy->chord());
167169
case ElementType::ORNAMENT: return new Ornament(parent->isChordRest() ? toChordRest(parent) : dummy->chord());
168170
case ElementType::FERMATA: return new Fermata(parent);
169171
case ElementType::CHORDLINE: return new ChordLine(parent->isChord() ? toChord(parent) : dummy->chord());
@@ -292,6 +294,11 @@ EngravingItem* Factory::doCreateItem(ElementType type, EngravingItem* parent)
292294
case ElementType::FIGURED_BASS_ITEM:
293295
case ElementType::DUMMY:
294296
case ElementType::SYSTEM_LOCK_INDICATOR:
297+
case ElementType::HAMMER_ON_PULL_OFF_SEGMENT:
298+
case ElementType::HAMMER_ON_PULL_OFF_TEXT:
299+
case ElementType::TAPPING_HALF_SLUR:
300+
case ElementType::TAPPING_HALF_SLUR_SEGMENT:
301+
case ElementType::TAPPING_TEXT:
295302
break;
296303
}
297304

@@ -342,6 +349,9 @@ MAKE_ITEM_IMPL(Arpeggio, Chord)
342349
CREATE_ITEM_IMPL(Articulation, ElementType::ARTICULATION, ChordRest, isAccessibleEnabled)
343350
MAKE_ITEM_IMPL(Articulation, ChordRest)
344351

352+
CREATE_ITEM_IMPL(Tapping, ElementType::TAPPING, ChordRest, isAccessibleEnabled)
353+
MAKE_ITEM_IMPL(Tapping, ChordRest)
354+
345355
CREATE_ITEM_IMPL(Ornament, ElementType::ORNAMENT, ChordRest, isAccessibleEnabled)
346356
MAKE_ITEM_IMPL(Ornament, ChordRest)
347357

src/engraving/dom/factory.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "engravingitem.h"
2828
#include "durationtype.h"
29+
#include "tapping.h"
2930
#include "types.h"
3031

3132
namespace mu::engraving {
@@ -57,6 +58,9 @@ class Factory
5758
static Articulation* createArticulation(ChordRest* parent, bool isAccessibleEnabled = true);
5859
static std::shared_ptr<Articulation> makeArticulation(ChordRest* parent);
5960

61+
static Tapping* createTapping(ChordRest* parent, bool isAccessibleEnabled = true);
62+
static std::shared_ptr<Tapping> makeTapping(ChordRest* parent);
63+
6064
static Ornament* createOrnament(ChordRest* parent, bool isAccessibleEnabled = true);
6165
static std::shared_ptr<Ornament> makeOrnament(ChordRest* parent);
6266

0 commit comments

Comments
 (0)