From 443191045bd1fcbba6a2e5a5691d6178d970ec90 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 14 Mar 2022 17:36:51 +0300 Subject: [PATCH] Added ability to provide delta to DraggingScrollManager. --- ui/dragging_scroll_manager.cpp | 24 ++++++++++++++---------- ui/dragging_scroll_manager.h | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/dragging_scroll_manager.cpp b/ui/dragging_scroll_manager.cpp index e62d3a3..5df4ee5 100644 --- a/ui/dragging_scroll_manager.cpp +++ b/ui/dragging_scroll_manager.cpp @@ -22,16 +22,8 @@ void DraggingScrollManager::scrollByTimer() { _scrolls.fire_copy(d); } -void DraggingScrollManager::checkDeltaScroll( - const QPoint &point, - int top, - int bottom) { - const auto diff = point.y() - top; - _delta = (diff < 0) - ? diff - : (point.y() >= bottom) - ? (point.y() - bottom + 1) - : 0; +void DraggingScrollManager::checkDeltaScroll(int delta) { + _delta = delta; if (_delta) { _timer.callEach(15); } else { @@ -39,6 +31,18 @@ void DraggingScrollManager::checkDeltaScroll( } } +void DraggingScrollManager::checkDeltaScroll( + const QPoint &point, + int top, + int bottom) { + const auto diff = point.y() - top; + checkDeltaScroll((diff < 0) + ? diff + : (point.y() >= bottom) + ? (point.y() - bottom + 1) + : 0); +} + void DraggingScrollManager::cancel() { _timer.cancel(); } diff --git a/ui/dragging_scroll_manager.h b/ui/dragging_scroll_manager.h index 5102bff..0d73b95 100644 --- a/ui/dragging_scroll_manager.h +++ b/ui/dragging_scroll_manager.h @@ -17,6 +17,7 @@ class DraggingScrollManager final { public: DraggingScrollManager(); + void checkDeltaScroll(int delta); void checkDeltaScroll(const QPoint &point, int top, int bottom); void cancel();