Adjust pixel delta conversion a bit
This commit is contained in:
parent
6ff9eb237b
commit
e9901b1719
2 changed files with 5 additions and 4 deletions
|
|
@ -659,7 +659,7 @@ bool ElasticScroll::handleWheelEvent(not_null<QWheelEvent*> e, bool touch) {
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
_lastScroll = now;
|
_lastScroll = now;
|
||||||
});
|
});
|
||||||
const auto pixels = ScrollDelta(e) / (touch ? kMagicScrollMultiplier : 1.);
|
const auto pixels = ScrollDelta(e, touch);
|
||||||
auto delta = _vertical ? -pixels.y() : pixels.x();
|
auto delta = _vertical ? -pixels.y() : pixels.x();
|
||||||
if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) {
|
if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) {
|
||||||
delta = 0;
|
delta = 0;
|
||||||
|
|
@ -1271,14 +1271,15 @@ rpl::producer<ElasticScrollMovement> ElasticScroll::movementValue() const {
|
||||||
return _movement.value();
|
return _movement.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint ScrollDelta(not_null<QWheelEvent*> e) {
|
QPoint ScrollDelta(not_null<QWheelEvent*> e, bool touch) {
|
||||||
const auto convert = [](QPoint point) {
|
const auto convert = [](QPoint point) {
|
||||||
return QPoint(
|
return QPoint(
|
||||||
style::ConvertScale(point.x()),
|
style::ConvertScale(point.x()),
|
||||||
style::ConvertScale(point.y()));
|
style::ConvertScale(point.y()));
|
||||||
};
|
};
|
||||||
if (!e->pixelDelta().isNull()) {
|
if (!e->pixelDelta().isNull()) {
|
||||||
return convert(e->pixelDelta()) * kMagicScrollMultiplier;
|
return convert(e->pixelDelta())
|
||||||
|
* (touch ? 1. : kMagicScrollMultiplier);
|
||||||
}
|
}
|
||||||
return convert(e->angleDelta()) / kPixelToAngleDelta;
|
return convert(e->angleDelta()) / kPixelToAngleDelta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] QPoint ScrollDelta(not_null<QWheelEvent*> e);
|
[[nodiscard]] QPoint ScrollDelta(not_null<QWheelEvent*> e, bool touch = false);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue