mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-26 11:50:47 +00:00
fix grid with fractional scaling (#4065)
This commit is contained in:
@@ -666,17 +666,18 @@ void CaptureWidget::paintEvent(QPaintEvent* paintEvent)
|
|||||||
painter.setPen(uicolor);
|
painter.setPen(uicolor);
|
||||||
painter.setBrush(QBrush(uicolor));
|
painter.setBrush(QBrush(uicolor));
|
||||||
|
|
||||||
auto topLeft = mapToGlobal(m_context.selection.topLeft());
|
const auto scale{ m_context.screenshot.devicePixelRatio() };
|
||||||
|
auto topLeft = mapToGlobal(m_context.selection.topLeft() / scale);
|
||||||
topLeft.rx() -= topLeft.x() % m_gridSize;
|
topLeft.rx() -= topLeft.x() % m_gridSize;
|
||||||
topLeft.ry() -= topLeft.y() % m_gridSize;
|
topLeft.ry() -= topLeft.y() % m_gridSize;
|
||||||
topLeft = mapFromGlobal(topLeft);
|
topLeft = mapFromGlobal(topLeft);
|
||||||
|
|
||||||
const auto scale{ m_context.screenshot.devicePixelRatio() };
|
const auto step{ m_gridSize / scale };
|
||||||
const auto step{ m_gridSize * scale };
|
|
||||||
const auto radius{ 1 * scale };
|
const auto radius{ 1 * scale };
|
||||||
|
|
||||||
for (int y = topLeft.y(); y < m_context.selection.bottom(); y += step) {
|
for (int y = topLeft.y(); y < m_context.selection.bottom() / scale;
|
||||||
for (int x = topLeft.x(); x < m_context.selection.right();
|
y += step) {
|
||||||
|
for (int x = topLeft.x(); x < m_context.selection.right() / scale;
|
||||||
x += step) {
|
x += step) {
|
||||||
painter.drawEllipse(x, y, radius, radius);
|
painter.drawEllipse(x, y, radius, radius);
|
||||||
}
|
}
|
||||||
@@ -1812,10 +1813,8 @@ QPoint CaptureWidget::snapToGrid(const QPoint& point) const
|
|||||||
|
|
||||||
const auto scale{ m_context.screenshot.devicePixelRatio() };
|
const auto scale{ m_context.screenshot.devicePixelRatio() };
|
||||||
|
|
||||||
snapPoint.setX((qRound(snapPoint.x() / double(m_gridSize)) * m_gridSize) *
|
snapPoint.setX((qRound(snapPoint.x() / double(m_gridSize)) * m_gridSize));
|
||||||
scale);
|
snapPoint.setY((qRound(snapPoint.y() / double(m_gridSize)) * m_gridSize));
|
||||||
snapPoint.setY((qRound(snapPoint.y() / double(m_gridSize)) * m_gridSize) *
|
|
||||||
scale);
|
|
||||||
|
|
||||||
return mapFromGlobal(snapPoint);
|
return mapFromGlobal(snapPoint);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user