Replaced timer for dragging scroll in Ui::BoxContent with manager.
This commit is contained in:
parent
d27e4803a1
commit
2779a7d036
2 changed files with 9 additions and 22 deletions
|
|
@ -98,6 +98,12 @@ void BoxContent::finishScrollCreate() {
|
|||
updateInnerVisibleTopBottom();
|
||||
updateShadowsVisibility();
|
||||
}, lifetime());
|
||||
_draggingScroll.scrolls(
|
||||
) | rpl::start_with_next([=](int delta) {
|
||||
if (_scroll) {
|
||||
_scroll->scrollToY(_scroll->scrollTop() + delta);
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void BoxContent::scrollToWidget(not_null<QWidget*> widget) {
|
||||
|
|
@ -117,24 +123,7 @@ void BoxContent::scrollToY(int top, int bottom) {
|
|||
}
|
||||
|
||||
void BoxContent::scrollByDraggingDelta(int delta) {
|
||||
_draggingScrollDelta = _scroll ? delta : 0;
|
||||
if (_draggingScrollDelta) {
|
||||
if (!_draggingScrollTimer) {
|
||||
_draggingScrollTimer = std::make_unique<base::Timer>([=] {
|
||||
draggingScrollTimerCallback();
|
||||
});
|
||||
}
|
||||
_draggingScrollTimer->callEach(15);
|
||||
} else {
|
||||
_draggingScrollTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void BoxContent::draggingScrollTimerCallback() {
|
||||
const auto delta = (_draggingScrollDelta > 0)
|
||||
? qMin(_draggingScrollDelta * 3 / 20 + 1, int32(kMaxScrollSpeed))
|
||||
: qMax(_draggingScrollDelta * 3 / 20 - 1, -int32(kMaxScrollSpeed));
|
||||
_scroll->scrollToY(_scroll->scrollTop() + delta);
|
||||
_draggingScroll.checkDeltaScroll(_scroll ? delta : 0);
|
||||
}
|
||||
|
||||
void BoxContent::updateInnerVisibleTopBottom() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "base/unique_qptr.h"
|
||||
#include "base/flags.h"
|
||||
#include "ui/dragging_scroll_manager.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/layers/layer_widget.h"
|
||||
|
|
@ -287,8 +288,6 @@ private:
|
|||
void updateShadowsVisibility();
|
||||
object_ptr<TWidget> doTakeInnerWidget();
|
||||
|
||||
void draggingScrollTimerCallback();
|
||||
|
||||
BoxContentDelegate *_delegate = nullptr;
|
||||
|
||||
bool _preparing = false;
|
||||
|
|
@ -300,8 +299,7 @@ private:
|
|||
object_ptr<FadeShadow> _topShadow = { nullptr };
|
||||
object_ptr<FadeShadow> _bottomShadow = { nullptr };
|
||||
|
||||
std::unique_ptr<base::Timer> _draggingScrollTimer;
|
||||
int _draggingScrollDelta = 0;
|
||||
Ui::DraggingScrollManager _draggingScroll;
|
||||
|
||||
rpl::event_stream<> _boxClosingStream;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue