Skip to content

Commit 06a4495

Browse files
committed
ScribbleArea::wheelEvent: Use std::pow based formula for pixel delta zooming
Which we've used for angle based zooming for a while now.
1 parent 37cbd97 commit 06a4495

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

core_lib/src/interface/scribblearea.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,20 +549,19 @@ void ScribbleArea::wheelEvent(QWheelEvent* event)
549549
#endif
550550

551551
const qreal currentScale = mEditor->view()->scaling();
552+
552553
// From the pixelDelta documentation: On X11 this value is driver-specific and unreliable, use angleDelta() instead
554+
int delta = 0;
553555
if (!isX11 && !pixels.isNull())
554556
{
555-
// XXX: This pixel-based zooming algorithm currently has some shortcomings compared to the angle-based one:
556-
// Zooming in is faster than zooming out and scrolling twice with delta x yields different zoom than
557-
// scrolling once with delta 2x. Someone with the ability to test this code might want to "upgrade" it.
558-
const int delta = pixels.y();
559-
const qreal newScale = currentScale * (1 + ((delta * mDeltaFactor) * 0.01));
560-
mEditor->view()->scaleAtOffset(newScale, offset);
557+
delta = pixels.y();
561558
}
562-
else if (!angle.isNull())
559+
else if (!angle.isNull()) // Wheel based delta
563560
{
564-
const int delta = angle.y();
565-
// 12 rotation steps at "standard" wheel resolution (120/step) result in 100x zoom
561+
delta = angle.y();
562+
}
563+
564+
if (delta != 0) {
566565
const qreal newScale = currentScale * std::pow(100, (delta * mDeltaFactor) / (12.0 * 120));
567566
mEditor->view()->scaleAtOffset(newScale, offset);
568567
}

0 commit comments

Comments
 (0)