Skip to content

Commit

Permalink
23033: Parts are displayed at incorrect zoom level when the Navigator…
Browse files Browse the repository at this point in the history
… is open
  • Loading branch information
krasko78 committed Jan 13, 2025
1 parent 2d9d1b0 commit f00043e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/notation/view/abstractnotationpaintview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ void AbstractNotationPaintView::onCurrentNotationChanged()
void AbstractNotationPaintView::onLoadNotation(INotationPtr)
{
if (viewport().isValid() && !m_notation->viewState()->isMatrixInited()) {
m_inputController->initZoom();
m_inputController->initCanvasPos();
initZoomAndPosition();
}

if (publishMode()) {
Expand Down Expand Up @@ -332,6 +331,10 @@ void AbstractNotationPaintView::onUnloadNotation(INotationPtr)
}
}

void AbstractNotationPaintView::initZoomAndPosition()
{
}

void AbstractNotationPaintView::setMatrix(const Transform& matrix)
{
if (m_matrix == matrix) {
Expand Down Expand Up @@ -380,8 +383,7 @@ void AbstractNotationPaintView::onViewSizeChanged()

if (viewport().isValid()) {
if (!notation()->viewState()->isMatrixInited()) {
m_inputController->initZoom();
m_inputController->initCanvasPos();
initZoomAndPosition();
} else {
m_inputController->updateZoomAfterSizeChange();
}
Expand Down Expand Up @@ -413,6 +415,11 @@ void AbstractNotationPaintView::updateLoopMarkers()
scheduleRedraw();
}

NotationViewInputController* AbstractNotationPaintView::inputController() const
{
return m_inputController.get();
}

INotationPtr AbstractNotationPaintView::notation() const
{
return m_notation;
Expand Down
5 changes: 5 additions & 0 deletions src/notation/view/abstractnotationpaintview.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class AbstractNotationPaintView : public muse::uicomponents::QuickPaintedView, p
protected:
INotationPtr notation() const;
void setNotation(INotationPtr notation);

NotationViewInputController* inputController() const;

void setReadonly(bool readonly);
void setMatrix(const muse::draw::Transform& matrix);

Expand All @@ -183,6 +186,8 @@ class AbstractNotationPaintView : public muse::uicomponents::QuickPaintedView, p
virtual void onLoadNotation(INotationPtr notation);
virtual void onUnloadNotation(INotationPtr notation);

virtual void initZoomAndPosition();

virtual void onMatrixChanged(const muse::draw::Transform& oldMatrix, const muse::draw::Transform& newMatrix, bool overrideZoomType);

protected slots:
Expand Down
8 changes: 8 additions & 0 deletions src/notation/view/notationpaintview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ void NotationPaintView::onUnloadNotation(INotationPtr notation)
notation->viewState()->matrixChanged().resetOnReceive(this);
}

void NotationPaintView::initZoomAndPosition()
{
if (notation() && !notation()->viewState()->isMatrixInited()) {
inputController()->initZoom();
inputController()->initCanvasPos();
}
}

void NotationPaintView::onMatrixChanged(const Transform& oldMatrix, const Transform& newMatrix, bool overrideZoomType)
{
AbstractNotationPaintView::onMatrixChanged(oldMatrix, newMatrix, overrideZoomType);
Expand Down
2 changes: 2 additions & 0 deletions src/notation/view/notationpaintview.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class NotationPaintView : public AbstractNotationPaintView
void onLoadNotation(INotationPtr notation) override;
void onUnloadNotation(INotationPtr notation) override;

void initZoomAndPosition() override;

void onMatrixChanged(const muse::draw::Transform& oldMatrix, const muse::draw::Transform& newMatrix,
bool overrideZoomType = true) override;

Expand Down

0 comments on commit f00043e

Please sign in to comment.