Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
fix: indicator pos error
Browse files Browse the repository at this point in the history
  • Loading branch information
justforlxz committed May 7, 2019
1 parent b048d90 commit cce7ca5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,22 +540,24 @@ void MainWindow::mouseMoveEvent(QMouseEvent *ev)
if (!m_toolBar->isVisible() && !m_isFirstReleaseButton) {
QPoint curPos = this->cursor().pos();
QPoint tmpPos;
if (curPos.x() + INDICATOR_WIDTH + CURSOR_WIDTH > m_backgroundRect.x()
QPoint topLeft = m_backgroundRect.topLeft() * devicePixelRatioF();

if (curPos.x() + INDICATOR_WIDTH + CURSOR_WIDTH > topLeft.x()
+ m_backgroundRect.width()) {
tmpPos.setX(curPos.x() - INDICATOR_WIDTH);
} else {
tmpPos.setX(curPos.x() + CURSOR_WIDTH);
}

if (curPos.y() + INDICATOR_WIDTH > m_backgroundRect.y() + m_backgroundRect.height()) {
if (curPos.y() + INDICATOR_WIDTH > topLeft.y() + m_backgroundRect.height()) {
tmpPos.setY(curPos.y() - INDICATOR_WIDTH);
} else {
tmpPos.setY(curPos.y() + CURSOR_HEIGHT);
}

m_zoomIndicator->showMagnifier(QPoint(
std::max(tmpPos.x() - m_backgroundRect.x(), 0),
std::max(tmpPos.y() - m_backgroundRect.y(), 0)));
std::max(tmpPos.x() - topLeft.x(), 0),
std::max(tmpPos.y() - topLeft.y(), 0)));
}
} else {
m_isFirstMove = true;
Expand Down

0 comments on commit cce7ca5

Please # to comment.