Skip to content

Commit

Permalink
Merge pull request #5424 from dmitrio95/296171-spanner-trigger-layout…
Browse files Browse the repository at this point in the history
…-all

fix #296171: fix triggerLayoutAll() for spanners
  • Loading branch information
dmitrio95 authored and anatoly-os committed Oct 30, 2019
1 parent dd15637 commit a9d3d0a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libmscore/element.h
Expand Up @@ -462,7 +462,7 @@ class Element : public ScoreElement {
}

virtual void triggerLayout() const;
void triggerLayoutAll() const;
virtual void triggerLayoutAll() const;
virtual void drawEditMode(QPainter*, EditData&);

void autoplaceSegmentElement(bool above, bool add); // helper functions
Expand Down
11 changes: 11 additions & 0 deletions libmscore/spanner.cpp
Expand Up @@ -1033,10 +1033,21 @@ void Spanner::setTicks(const Fraction& f)

void Spanner::triggerLayout() const
{
// Spanners do not have parent even when added to a score, so can't check parent here
const int tr2 = track2() == -1 ? track() : track2();
score()->setLayout(_tick, _tick + _ticks, staffIdx(), track2staff(tr2), this);
}

void Spanner::triggerLayoutAll() const
{
// Spanners do not have parent even when added to a score, so can't check parent here
score()->setLayoutAll(staffIdx(), this);

const int tr2 = track2();
if (tr2 != -1 && tr2 != track())
score()->setLayoutAll(track2staff(tr2), this);
}

//---------------------------------------------------------
// pushUnusedSegment
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/spanner.h
Expand Up @@ -217,6 +217,7 @@ class Spanner : public Element {
virtual void layoutSystemsDone();

virtual void triggerLayout() const override;
virtual void triggerLayoutAll() const override;
virtual void add(Element*) override;
virtual void remove(Element*) override;
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
Expand Down
2 changes: 1 addition & 1 deletion mscore/scoreview.cpp
Expand Up @@ -4823,7 +4823,7 @@ static bool needViewportMove(Score* cs, ScoreView* cv)
const QRectF viewport = cv->canvasViewport(); // TODO: margins for intersection check?

const Element* editElement = state.element();
if (editElement && editElement->bbox().isValid())
if (editElement && editElement->bbox().isValid() && !editElement->isSpanner())
return !viewport.intersects(editElement->canvasBoundingRect());

if (state.startTick().isZero() && state.endTick() == cs->endTick())
Expand Down

0 comments on commit a9d3d0a

Please sign in to comment.