Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Sep 23, 2024
1 parent 8172a9d commit 25706d3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions src/engraving/dom/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const BeamSegment* Beam::topLevelSegmentForElement(const ChordRest* element) con
void Beam::move(const PointF& offset)
{
EngravingItem::move(offset);
for (BeamSegment* bs : beamSegments()) {
for (BeamSegment* bs : m_beamSegments) {
bs->line.translate(offset);
}
}
Expand Down Expand Up @@ -404,8 +404,8 @@ std::vector<PointF> Beam::gripsPositions(const EditData& ed) const
}

int y = pagePos().y();
double beamStartX = startAnchor().x() + (system() ? system()->x() : 0);
double beamEndX = endAnchor().x() + (system() ? system()->x() : 0);
double beamStartX = m_startAnchor.x() + (system() ? system()->x() : 0);
double beamEndX = m_endAnchor.x() + (system() ? system()->x() : 0);
double middleX = (beamStartX + beamEndX) / 2;
double middleY = (f->py1[idx] + y + f->py2[idx] + y) / 2;

Expand All @@ -420,13 +420,13 @@ std::vector<PointF> Beam::gripsPositions(const EditData& ed) const
// setBeamDirection
//---------------------------------------------------------

void Beam::setBeamDirection(DirectionV d)
void Beam::setDirection(DirectionV d)
{
if (direction() == d || m_cross) {
return;
}

setDirection(d);
doSetDirection(d);

if (d != DirectionV::AUTO) {
setUp(d == DirectionV::UP);
Expand Down Expand Up @@ -594,8 +594,8 @@ void Beam::setNoSlope(bool b)

void Beam::computeAndSetSlope()
{
double xDiff = endAnchor().x() - startAnchor().x();
double yDiff = endAnchor().y() - startAnchor().y();
double xDiff = m_endAnchor.x() - m_startAnchor.x();
double yDiff = m_endAnchor.y() - m_startAnchor.y();
if (std::abs(xDiff) < 0.5 * spatium()) {
// Temporary safeguard: a beam this short is invalid, and exists only as a temporary state,
// so don't try to compute the slope as it will be wrong. Needs a better solution in future.
Expand Down Expand Up @@ -694,12 +694,12 @@ PropertyValue Beam::propertyDefault(Pid id) const

void Beam::addSkyline(Skyline& sk)
{
if (beamSegments().empty() || !addToSkyline()) {
if (m_beamSegments.empty() || !addToSkyline()) {
return;
}

// Only add the outer segment, no need to add the inner one
sk.add(beamSegments().front()->shape());
sk.add(m_beamSegments.front()->shape());
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Beam final : public BeamBase
void setId(int i) const { m_id = i; }
int id() const { return m_id; }

void setBeamDirection(DirectionV d) override;
void setDirection(DirectionV d) override;

void calcBeamBreaks(const ChordRest* chord, const ChordRest* prevChord, int level, bool& isBroken32, bool& isBroken64) const;

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/beambase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool BeamBase::setProperty(Pid propertyId, const PropertyValue& v)
setCrossStaffMove(v.toInt());
break;
case Pid::STEM_DIRECTION:
setBeamDirection(v.value<DirectionV>());
setDirection(v.value<DirectionV>());
break;
case Pid::USER_MODIFIED:
setUserModified(v.toBool());
Expand Down
10 changes: 5 additions & 5 deletions src/engraving/dom/beambase.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class BeamBase : public EngravingItem
void setUserModified(bool val);

DirectionV direction() const { return m_direction; }
void setDirection(DirectionV val) { m_direction = val; }
virtual void setBeamDirection(DirectionV v) = 0;
void doSetDirection(DirectionV val) { m_direction = val; }
virtual void setDirection(DirectionV v) = 0;

inline int directionIdx() const { return (m_direction == DirectionV::AUTO || m_direction == DirectionV::DOWN) ? 0 : 1; }

Expand Down Expand Up @@ -189,14 +189,14 @@ class BeamBase : public EngravingItem
protected:
BeamBase(const ElementType& type, EngravingItem* parent, ElementFlags flags = ElementFlag::NOTHING);
BeamBase(const BeamBase&);
std::vector<BeamSegment*> m_beamSegments;
PointF m_startAnchor;
PointF m_endAnchor;

private:
bool m_up = true;
bool m_userModified[2]{ false }; // 0: auto/down 1: up
DirectionV m_direction = DirectionV::AUTO;
std::vector<BeamSegment*> m_beamSegments;
PointF m_startAnchor;
PointF m_endAnchor;
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/engraving/dom/tremolotwochord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ PointF TremoloTwoChord::pagePos() const
// setBeamDirection
//---------------------------------------------------------

void TremoloTwoChord::setBeamDirection(DirectionV d)
void TremoloTwoChord::setDirection(DirectionV d)
{
if (direction() == d) {
return;
}

setDirection(d);
doSetDirection(d);

if (d != DirectionV::AUTO) {
setUp(d == DirectionV::UP);
Expand Down Expand Up @@ -351,8 +351,8 @@ std::vector<PointF> TremoloTwoChord::gripsPositions(const EditData&) const
}

int y = pagePos().y();
double beamStartX = startAnchor().x() + m_chord1->pageX();
double beamEndX = endAnchor().x() + m_chord1->pageX(); // intentional--chord1 is start x
double beamStartX = m_startAnchor.x() + m_chord1->pageX();
double beamEndX = m_endAnchor.x() + m_chord1->pageX(); // intentional--chord1 is start x
double middleX = (beamStartX + beamEndX) / 2;
double middleY = (m_beamFragment.py1[idx] + y + m_beamFragment.py2[idx] + y) / 2;

Expand Down Expand Up @@ -514,7 +514,7 @@ void TremoloTwoChord::clearBeamSegments()
BeamSegment* chord2Segment = m_chord2 ? m_chord2->beamlet() : nullptr;

if (chord1Segment || chord2Segment) {
for (BeamSegment* segment : beamSegments()) {
for (BeamSegment* segment : m_beamSegments) {
if (chord1Segment && chord1Segment == segment) {
m_chord1->setBeamlet(nullptr);
} else if (chord2Segment && chord2Segment == segment) {
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/tremolotwochord.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TremoloTwoChord final : public BeamBase

TremoloStyle tremoloStyle() const { return m_style; }
void setTremoloStyle(TremoloStyle v) { m_style = v; }
void setBeamDirection(DirectionV v) override;
void setDirection(DirectionV v) override;
void setBeamFragment(const BeamFragment& bf) { m_beamFragment = bf; }
const BeamFragment& beamFragment() const { return m_beamFragment; }
BeamFragment& beamFragment() { return m_beamFragment; }
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/tremololayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void TremoloLayout::layoutTwoNotesTremolo(TremoloTwoChord* item, const LayoutCon
if (item->chord1()->beam() && item->chord1()->beam() == item->chord2()->beam()) {
Beam* beam = item->chord1()->beam();
item->setUp(beam->up());
item->setDirection(beam->direction());
item->doSetDirection(beam->direction());
// stem stuff is already taken care of by the beams
} else if (!item->userModified()) {
// user modified trems will be dealt with later
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/tests/beam_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ TEST_F(Engraving_BeamTests, beamStemDir)
Measure* m1 = score->firstMeasure();
ChordRest* cr = toChordRest(m1->findSegment(SegmentType::ChordRest, m1->tick())->element(0));

cr->beam()->setBeamDirection(DirectionV::UP);
cr->beam()->setDirection(DirectionV::UP);

score->update();
score->doLayout();
Expand Down Expand Up @@ -223,7 +223,7 @@ TEST_F(Engraving_BeamTests, flipBeamStemDir)
score->startCmd();
score->cmdFlip();
score->endCmd();
cr->beam()->setBeamDirection(DirectionV::DOWN);
cr->beam()->setDirection(DirectionV::DOWN);

score->update();
score->doLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ static void handleBeamAndStemDir(ChordRest* cr, const BeamMode bm, const Directi
// create a new beam
beam = Factory::createBeam(cr->score()->dummy()->system());
beam->setTrack(cr->track());
beam->setBeamDirection(sd);
beam->setDirection(sd);
}
// add ChordRest to beam
if (beam) {
Expand Down

0 comments on commit 25706d3

Please sign in to comment.