Skip to content

Commit

Permalink
[engraving] remove friend class SlurTieLayout from Slur
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Jul 13, 2023
1 parent 74148cb commit 8e09dec
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 122 deletions.
152 changes: 76 additions & 76 deletions src/engraving/layout/v0/slurtielayout.cpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/engraving/libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ bool SlurSegment::isEndPointsEdited() const
Slur::Slur(const Slur& s)
: SlurTie(s)
{
_sourceStemArrangement = s._sourceStemArrangement;
m_sourceStemArrangement = s.m_sourceStemArrangement;
}

//---------------------------------------------------------
Expand All @@ -871,15 +871,15 @@ void Slur::slurPosChord(SlurPos* sp)
if (startChord()->isGraceAfter()) { // grace notes after, coming in reverse order
stChord = endChord();
enChord = startChord();
_up = false;
m_up = false;
} else {
stChord = startChord();
enChord = endChord();
}
Note* _startNote = stChord->downNote();
Note* _endNote = enChord->downNote();
double hw = _startNote->bboxRightPos();
double __up = _up ? -1.0 : 1.0;
double __up = m_up ? -1.0 : 1.0;
double _spatium = spatium();

Measure* measure = endChord()->measure();
Expand All @@ -896,7 +896,7 @@ void Slur::slurPosChord(SlurPos* sp)
double yo;

//------p1
if (_up) {
if (m_up) {
xo = _startNote->x() + hw * 1.12;
yo = _startNote->pos().y() + hw * .3 * __up;
} else {
Expand All @@ -906,7 +906,7 @@ void Slur::slurPosChord(SlurPos* sp)
sp->p1 = stChord->pagePos() - pp + PointF(xo, yo);

//------p2
if ((enChord->notes().size() > 1) || (enChord->stem() && !enChord->up() && !_up)) {
if ((enChord->notes().size() > 1) || (enChord->stem() && !enChord->up() && !m_up)) {
xo = _endNote->x() - hw * 0.12;
yo = _endNote->pos().y() + hw * .3 * __up;
} else {
Expand Down
14 changes: 8 additions & 6 deletions src/engraving/libmscore/slur.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class Slur final : public SlurTie

void setTrack(track_idx_t val) override;

void setSourceStemArrangement(int v) { _sourceStemArrangement = v; }
int sourceStemArrangement() const { return m_sourceStemArrangement; }
void setSourceStemArrangement(int v) { m_sourceStemArrangement = v; }

SlurSegment* frontSegment() { return toSlurSegment(Spanner::frontSegment()); }
const SlurSegment* frontSegment() const { return toSlurSegment(Spanner::frontSegment()); }
Expand All @@ -114,24 +115,25 @@ class Slur final : public SlurTie
bool stemSideForBeam(bool start);
bool stemSideStartForBeam() { return stemSideForBeam(true); }
bool stemSideEndForBeam() { return stemSideForBeam(false); }
const StemFloated& stemFloated() const { return _stemFloated; }
const StemFloated& stemFloated() const { return m_stemFloated; }
StemFloated& stemFloated() { return m_stemFloated; }

SlurTieSegment* newSlurTieSegment(System* parent) override { return new SlurSegment(parent); }

static int calcStemArrangement(EngravingItem* start, EngravingItem* end);
static bool isDirectionMixture(Chord* c1, Chord* c2);

private:
void slurPosChord(SlurPos*);

friend class layout::v0::SlurTieLayout;
friend class Factory;
Slur(EngravingItem* parent);
Slur(const Slur&);

int _sourceStemArrangement = -1;
void slurPosChord(SlurPos*);

int m_sourceStemArrangement = -1;

StemFloated _stemFloated; // end point position is attached to stem but floated towards the note
StemFloated m_stemFloated; // end point position is attached to stem but floated towards the note
};
} // namespace mu::engraving
#endif
12 changes: 6 additions & 6 deletions src/engraving/libmscore/slurtie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,17 @@ void SlurTieSegment::drawEditMode(mu::draw::Painter* p, EditData& ed, double /*c
SlurTie::SlurTie(const ElementType& type, EngravingItem* parent)
: Spanner(type, parent)
{
_slurDirection = DirectionV::AUTO;
_up = true;
_styleType = SlurStyleType::Solid;
m_slurDirection = DirectionV::AUTO;
m_up = true;
m_styleType = SlurStyleType::Solid;
}

SlurTie::SlurTie(const SlurTie& t)
: Spanner(t)
{
_up = t._up;
_slurDirection = t._slurDirection;
_styleType = t._styleType;
m_up = t.m_up;
m_slurDirection = t.m_slurDirection;
m_styleType = t.m_styleType;
}

//---------------------------------------------------------
Expand Down
35 changes: 18 additions & 17 deletions src/engraving/libmscore/slurtie.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,42 +153,43 @@ class SlurTie : public Spanner
{
OBJECT_ALLOCATOR(engraving, SlurTie)

SlurStyleType _styleType = SlurStyleType::Undefined;

protected:

friend class layout::v0::SlurTieLayout;

bool _up; // actual direction

DirectionV _slurDirection;
void fixupSegments(unsigned nsegs);

public:
SlurTie(const ElementType& type, EngravingItem* parent);
SlurTie(const SlurTie&);
~SlurTie();

bool up() const { return _up; }
void setUp(bool val) { _up = val; }
bool up() const { return m_up; }
void setUp(bool val) { m_up = val; }

virtual void reset() override;

DirectionV slurDirection() const { return _slurDirection; }
void setSlurDirection(DirectionV d) { _slurDirection = d; }
DirectionV slurDirection() const { return m_slurDirection; }
void setSlurDirection(DirectionV d) { m_slurDirection = d; }
void undoSetSlurDirection(DirectionV d);

virtual void layout2(const PointF, int, struct UP&) {}
virtual bool contains(const PointF&) const { return false; } // not selectable

SlurStyleType styleType() const { return _styleType; }
void setStyleType(SlurStyleType type) { _styleType = type; }
SlurStyleType styleType() const { return m_styleType; }
void setStyleType(SlurStyleType type) { m_styleType = type; }

virtual SlurTieSegment* newSlurTieSegment(System* parent) = 0;

PropertyValue getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const PropertyValue&) override;
PropertyValue propertyDefault(Pid id) const override;

void fixupSegments(unsigned nsegs);

protected:

bool m_up = true; // actual direction

DirectionV m_slurDirection = DirectionV::AUTO;

private:

SlurStyleType m_styleType = SlurStyleType::Undefined;
};
}

Expand Down
24 changes: 12 additions & 12 deletions src/engraving/libmscore/tie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,25 +879,25 @@ void Tie::calculateDirection()
Measure* m1 = c1->measure();
Measure* m2 = c2->measure();

if (_slurDirection == DirectionV::AUTO) {
if (m_slurDirection == DirectionV::AUTO) {
std::vector<Note*> notes = c1->notes();
size_t n = notes.size();
StaffType* st = staff()->staffType(startNote() ? startNote()->tick() : Fraction(0, 1));
bool simpleException = st && st->isSimpleTabStaff();
// if there are multiple voices, the tie direction goes on stem side
if (m1->hasVoices(c1->staffIdx(), c1->tick(), c1->actualTicks())) {
_up = simpleException ? isUpVoice(c1->voice()) : c1->up();
m_up = simpleException ? isUpVoice(c1->voice()) : c1->up();
} else if (m2->hasVoices(c2->staffIdx(), c2->tick(), c2->actualTicks())) {
_up = simpleException ? isUpVoice(c2->voice()) : c2->up();
m_up = simpleException ? isUpVoice(c2->voice()) : c2->up();
} else if (n == 1) {
//
// single note
//
if (c1->up() != c2->up()) {
// if stem direction is mixed, always up
_up = true;
m_up = true;
} else {
_up = !c1->up();
m_up = !c1->up();
}
} else {
//
Expand Down Expand Up @@ -960,27 +960,27 @@ void Tie::calculateDirection()
if (tiesAbove == 0 && tiesBelow == 0 && unisonTies == 0) {
// this is the only tie in the chord.
if (notesAbove == notesBelow) {
_up = !c1->up();
m_up = !c1->up();
} else {
_up = (notesAbove < notesBelow);
m_up = (notesAbove < notesBelow);
}
} else if (tiesAbove == tiesBelow) {
// this note is dead center, so its tie should go counter to the stem direction
_up = !c1->up();
m_up = !c1->up();
} else {
_up = (tiesAbove < tiesBelow);
m_up = (tiesAbove < tiesBelow);
}
} else if (pivotPoint == startNote()) {
// the current note is the lower of the only second or unison in the chord; tie goes down.
_up = false;
m_up = false;
} else {
// if lower than the pivot, tie goes down, otherwise up
int noteDiff = compareNotesPos(startNote(), pivotPoint);
_up = (noteDiff >= 0);
m_up = (noteDiff >= 0);
}
}
} else {
_up = _slurDirection == DirectionV::UP ? true : false;
m_up = m_slurDirection == DirectionV::UP ? true : false;
}
}

Expand Down

0 comments on commit 8e09dec

Please sign in to comment.