Line data Source code
1 : #include "partialtie.h"
2 : #include "chord.h"
3 : #include "measure.h"
4 : #include "score.h"
5 : #include "note.h"
6 : #include "staff.h"
7 :
8 : namespace mu::engraving {
9 63 : PartialTie::PartialTie(DummyParentOr<Note> parent)
10 63 : : Tie(ElementType::PARTIAL_TIE, parent)
11 : {
12 63 : }
13 :
14 831 : mu::engraving::PropertyValue mu::engraving::PartialTie::getProperty(Pid propertyId) const
15 : {
16 831 : switch (propertyId) {
17 44 : case Pid::PARTIAL_SPANNER_DIRECTION:
18 44 : return partialSpannerDirection();
19 787 : default:
20 787 : return Tie::getProperty(propertyId);
21 : }
22 : }
23 :
24 660 : PropertyValue PartialTie::propertyDefault(Pid propertyId) const
25 : {
26 660 : switch (propertyId) {
27 44 : case Pid::PARTIAL_SPANNER_DIRECTION:
28 88 : return PartialSpannerDirection::OUTGOING;
29 616 : default:
30 616 : return Tie::propertyDefault(propertyId);
31 : }
32 : }
33 :
34 30 : bool PartialTie::setProperty(Pid propertyId, const PropertyValue& v)
35 : {
36 30 : switch (propertyId) {
37 24 : case Pid::PARTIAL_SPANNER_DIRECTION:
38 24 : setPartialSpannerDirection(v.value<PartialSpannerDirection>());
39 24 : break;
40 6 : default:
41 6 : return Tie::setProperty(propertyId, v);
42 : }
43 24 : triggerLayout();
44 24 : return true;
45 : }
46 :
47 59 : SlurTieSegment* PartialTie::newSlurTieSegment()
48 : {
49 59 : PartialTieSegment* seg = new PartialTieSegment(this);
50 59 : seg->setTrack(track());
51 59 : return seg;
52 : }
53 :
54 48 : void PartialTie::setStartNote(Note* note)
55 : {
56 48 : setPartialSpannerDirection(PartialSpannerDirection::OUTGOING);
57 48 : Tie::setStartNote(note);
58 48 : Tie::setEndNote(nullptr);
59 48 : }
60 :
61 90 : void PartialTie::setEndNote(Note* note)
62 : {
63 90 : setPartialSpannerDirection(PartialSpannerDirection::INCOMING);
64 90 : Tie::setStartNote(nullptr);
65 90 : Tie::setEndNote(note);
66 90 : setOwnershipParent(note);
67 90 : }
68 :
69 368 : bool PartialTie::allJumpPointsInactive() const
70 : {
71 368 : if (!isOutgoing()) {
72 230 : return false;
73 : }
74 138 : return Tie::allJumpPointsInactive();
75 : }
76 :
77 409 : TieJumpPointList* PartialTie::tieJumpPoints()
78 : {
79 409 : if (!isOutgoing()) {
80 13 : return nullptr;
81 : }
82 :
83 396 : return Tie::tieJumpPoints();
84 : }
85 :
86 276 : const TieJumpPointList* PartialTie::tieJumpPoints() const
87 : {
88 276 : if (!isOutgoing()) {
89 0 : return nullptr;
90 : }
91 :
92 276 : return Tie::tieJumpPoints();
93 : }
94 :
95 9991 : Note* PartialTie::startNote() const
96 : {
97 9991 : if (isOutgoing()) {
98 5899 : return Tie::startNote();
99 : }
100 4092 : return startTie() ? startTie()->startNote() : nullptr;
101 : }
102 :
103 59 : PartialTieSegment::PartialTieSegment(PartialTie* sp)
104 59 : : TieSegment(ElementType::PARTIAL_TIE_SEGMENT, sp)
105 : {
106 59 : }
107 :
108 0 : PartialTieSegment::PartialTieSegment(const PartialTieSegment& s)
109 0 : : TieSegment(s)
110 : {
111 0 : }
112 :
113 0 : String PartialTieSegment::formatBarsAndBeats() const
114 : {
115 0 : const PartialTie* pt = this->partialTie();
116 0 : const Note* note = pt ? pt->note() : nullptr;
117 0 : const Chord* chord = note ? note->chord() : nullptr;
118 0 : const Segment* seg = chord ? chord->segment() : nullptr;
119 :
120 0 : if (!seg) {
121 0 : return EngravingItem::formatBarsAndBeats();
122 : }
123 :
124 0 : return seg->formatBarsAndBeats();
125 : }
126 : }
|