MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / wheelEvent

Method wheelEvent

app/src/UI/Widgets/Waterfall.cpp:1444–1463  ·  view source on GitHub ↗

* @brief Wheel = zoom toward the cursor; touch-pad gestures zoom more gently. */

Source from the content-addressed store, hash-verified

1442 * @brief Wheel = zoom toward the cursor; touch-pad gestures zoom more gently.
1443 */
1444void Widgets::Waterfall::wheelEvent(QWheelEvent* event)
1445{
1446 if (event->angleDelta().y() == 0) {
1447 event->ignore();
1448 return;
1449 }
1450
1451 const bool isTouchpad =
1452 !event->pixelDelta().isNull() || event->source() == Qt::MouseEventSynthesizedBySystem;
1453 const double zoomBase = isTouchpad ? 1.05 : 1.15;
1454 constexpr double kInv120 = 1.0 / 120.0;
1455 const double delta = event->angleDelta().y() * kInv120;
1456 const double factor = std::pow(zoomBase, delta);
1457
1458 const QPointF p = event->position();
1459 const double w = qMax(1.0, width());
1460 const double h = qMax(1.0, height());
1461 zoomBy(factor, p.x() / w, p.y() / h);
1462 event->accept();
1463}
1464
1465/**
1466 * @brief Mouse-press starts a drag-to-pan interaction.

Callers

nothing calls this directly

Calls 4

powFunction · 0.85
xMethod · 0.80
acceptMethod · 0.80
sourceMethod · 0.45

Tested by

no test coverage detected