Skip to content

Commit

Permalink
fix #41371: preserve score position when switching page/continuous view
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Dec 14, 2014
1 parent 7a67e63 commit 9397513
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4344,13 +4344,25 @@ void MuseScore::switchLayoutMode(int val)
if (cs) {
cs->startCmd();
LayoutMode mode;
// find a measure to use as reference, if possible
QRectF view = cv->toLogical(QRect(0.0, 0.0, width(), height()));
MeasureBase* m = cs->measures()->first();
while (m && !view.intersects(m->canvasBoundingRect()))
m = m->nextMM();
if (val == 0)
mode = LayoutMode::PAGE;
else
mode = LayoutMode::LINE;
cs->undo(new ChangeLayoutMode(cs, mode));
cv->loopUpdate(getAction("loop")->isChecked());
cs->endCmd();
// adjustCanvasPosition often tries to preserve Y position
// but this doesn't make sense when switching modes
// also, better positioning is usually achieved if you start from the top
// and there is really no better place to position canvas if we were all the way off page previously
cv->pageTop();
if (m)
cv->adjustCanvasPosition(m, false);
endCmd();
}
}
Expand Down
3 changes: 2 additions & 1 deletion mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3648,7 +3648,7 @@ void ScoreView::pagePrev()
void ScoreView::pageTop()
{
if (score()->layoutMode() == LayoutMode::LINE)
setOffset(0.0, yoffset());
setOffset(0.0, 0.0);
else
setOffset(10.0, 10.0);
update();
Expand Down Expand Up @@ -3686,6 +3686,7 @@ void ScoreView::adjustCanvasPosition(const Element* el, bool playBack)
return;

if (score()->layoutMode() == LayoutMode::LINE) {

if (!el)
return;

Expand Down

0 comments on commit 9397513

Please sign in to comment.