Moved Ui::SelectScrollManager to lib_ui.
This commit is contained in:
parent
c7826b8dff
commit
6e6ba5a149
3 changed files with 86 additions and 0 deletions
|
|
@ -219,6 +219,8 @@ PRIVATE
|
||||||
ui/click_handler.h
|
ui/click_handler.h
|
||||||
ui/delayed_activation.cpp
|
ui/delayed_activation.cpp
|
||||||
ui/delayed_activation.h
|
ui/delayed_activation.h
|
||||||
|
ui/dragging_scroll_manager.cpp
|
||||||
|
ui/dragging_scroll_manager.h
|
||||||
ui/emoji_config.cpp
|
ui/emoji_config.cpp
|
||||||
ui/emoji_config.h
|
ui/emoji_config.h
|
||||||
ui/focus_persister.h
|
ui/focus_persister.h
|
||||||
|
|
|
||||||
50
ui/dragging_scroll_manager.cpp
Normal file
50
ui/dragging_scroll_manager.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "ui/dragging_scroll_manager.h"
|
||||||
|
|
||||||
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
DraggingScrollManager::DraggingScrollManager()
|
||||||
|
: _timer([=] { scrollByTimer(); }) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DraggingScrollManager::scrollByTimer() {
|
||||||
|
const auto d = (_delta > 0)
|
||||||
|
? std::min(_delta * 3 / 20 + 1, kMaxScrollSpeed)
|
||||||
|
: std::max(_delta * 3 / 20 - 1, -kMaxScrollSpeed);
|
||||||
|
_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;
|
||||||
|
if (_delta) {
|
||||||
|
_timer.callEach(15);
|
||||||
|
} else {
|
||||||
|
_timer.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DraggingScrollManager::cancel() {
|
||||||
|
_timer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<int> DraggingScrollManager::scrolls() {
|
||||||
|
return _scrolls.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Ui
|
||||||
34
ui/dragging_scroll_manager.h
Normal file
34
ui/dragging_scroll_manager.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/timer.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
class ScrollArea;
|
||||||
|
|
||||||
|
class DraggingScrollManager final {
|
||||||
|
public:
|
||||||
|
DraggingScrollManager();
|
||||||
|
|
||||||
|
void checkDeltaScroll(const QPoint &point, int top, int bottom);
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
rpl::producer<int> scrolls();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void scrollByTimer();
|
||||||
|
|
||||||
|
base::Timer _timer;
|
||||||
|
int _delta = 0;
|
||||||
|
rpl::event_stream<int> _scrolls;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Ui
|
||||||
Loading…
Add table
Reference in a new issue