mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-29 08:53:03 +02:00
Replaced timer for dragging scroll in Dialogs::Widget with manager.
This commit is contained in:
parent
6793d2cc7c
commit
72ecc286dc
5 changed files with 19 additions and 34 deletions
|
@ -1130,7 +1130,7 @@ void InnerWidget::finishReorderPinned() {
|
||||||
_aboveIndex = -1;
|
_aboveIndex = -1;
|
||||||
}
|
}
|
||||||
if (wasDragging) {
|
if (wasDragging) {
|
||||||
draggingScrollDelta(0);
|
_draggingScroll.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,7 +1220,7 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
|
||||||
return 0;
|
return 0;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
draggingScrollDelta(delta);
|
_draggingScroll.checkDeltaScroll(delta);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1930,6 +1930,10 @@ rpl::producer<> InnerWidget::updated() const {
|
||||||
return _updated.events();
|
return _updated.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<int> InnerWidget::scrollByDeltaRequests() const {
|
||||||
|
return _draggingScroll.scrolls();
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<> InnerWidget::listBottomReached() const {
|
rpl::producer<> InnerWidget::listBottomReached() const {
|
||||||
return _listBottomReached.events();
|
return _listBottomReached.events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
#include "data/data_messages.h"
|
#include "data/data_messages.h"
|
||||||
|
#include "ui/dragging_scroll_manager.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "base/flags.h"
|
#include "base/flags.h"
|
||||||
|
@ -125,6 +126,8 @@ public:
|
||||||
[[nodiscard]] rpl::producer<ChosenRow> chosenRow() const;
|
[[nodiscard]] rpl::producer<ChosenRow> chosenRow() const;
|
||||||
[[nodiscard]] rpl::producer<> updated() const;
|
[[nodiscard]] rpl::producer<> updated() const;
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<int> scrollByDeltaRequests() const;
|
||||||
|
|
||||||
[[nodiscard]] RowDescriptor resolveChatNext(RowDescriptor from = {}) const;
|
[[nodiscard]] RowDescriptor resolveChatNext(RowDescriptor from = {}) const;
|
||||||
[[nodiscard]] RowDescriptor resolveChatPrevious(RowDescriptor from = {}) const;
|
[[nodiscard]] RowDescriptor resolveChatPrevious(RowDescriptor from = {}) const;
|
||||||
|
|
||||||
|
@ -134,7 +137,6 @@ public Q_SLOTS:
|
||||||
void onParentGeometryChanged();
|
void onParentGeometryChanged();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void draggingScrollDelta(int delta);
|
|
||||||
void mustScrollTo(int scrollToTop, int scrollToBottom);
|
void mustScrollTo(int scrollToTop, int scrollToBottom);
|
||||||
void dialogMoved(int movedFrom, int movedTo);
|
void dialogMoved(int movedFrom, int movedTo);
|
||||||
void searchMessages();
|
void searchMessages();
|
||||||
|
@ -401,6 +403,8 @@ private:
|
||||||
object_ptr<Ui::IconButton> _cancelSearchInChat;
|
object_ptr<Ui::IconButton> _cancelSearchInChat;
|
||||||
object_ptr<Ui::IconButton> _cancelSearchFromUser;
|
object_ptr<Ui::IconButton> _cancelSearchFromUser;
|
||||||
|
|
||||||
|
Ui::DraggingScrollManager _draggingScroll;
|
||||||
|
|
||||||
Key _searchInChat;
|
Key _searchInChat;
|
||||||
History *_searchInMigrated = nullptr;
|
History *_searchInMigrated = nullptr;
|
||||||
PeerData *_searchFromPeer = nullptr;
|
PeerData *_searchFromPeer = nullptr;
|
||||||
|
|
|
@ -209,7 +209,13 @@ Widget::Widget(
|
||||||
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
||||||
) | rpl::to_empty);
|
) | rpl::to_empty);
|
||||||
|
|
||||||
connect(_inner, SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int)));
|
_inner->scrollByDeltaRequests(
|
||||||
|
) | rpl::start_with_next([=](int delta) {
|
||||||
|
if (_scroll) {
|
||||||
|
_scroll->scrollToY(_scroll->scrollTop() + delta);
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
connect(_inner, &InnerWidget::mustScrollTo, [=](int top, int bottom) {
|
connect(_inner, &InnerWidget::mustScrollTo, [=](int top, int bottom) {
|
||||||
if (_scroll) {
|
if (_scroll) {
|
||||||
_scroll->scrollToY(top, bottom);
|
_scroll->scrollToY(top, bottom);
|
||||||
|
@ -866,27 +872,6 @@ void Widget::loadMoreBlockedByDate() {
|
||||||
session().api().requestMoreBlockedByDateDialogs();
|
session().api().requestMoreBlockedByDateDialogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onDraggingScrollDelta(int delta) {
|
|
||||||
_draggingScrollDelta = _scroll ? delta : 0;
|
|
||||||
if (_draggingScrollDelta) {
|
|
||||||
if (!_draggingScrollTimer) {
|
|
||||||
_draggingScrollTimer.create(this);
|
|
||||||
_draggingScrollTimer->setSingleShot(false);
|
|
||||||
connect(_draggingScrollTimer, SIGNAL(timeout()), this, SLOT(onDraggingScrollTimer()));
|
|
||||||
}
|
|
||||||
_draggingScrollTimer->start(15);
|
|
||||||
} else {
|
|
||||||
_draggingScrollTimer.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::onDraggingScrollTimer() {
|
|
||||||
const auto delta = (_draggingScrollDelta > 0)
|
|
||||||
? qMin(_draggingScrollDelta * 3 / 20 + 1, Ui::kMaxScrollSpeed)
|
|
||||||
: qMax(_draggingScrollDelta * 3 / 20 - 1, -Ui::kMaxScrollSpeed);
|
|
||||||
_scroll->scrollToY(_scroll->scrollTop() + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Widget::onSearchMessages(bool searchCache) {
|
bool Widget::onSearchMessages(bool searchCache) {
|
||||||
auto result = false;
|
auto result = false;
|
||||||
auto q = _filter->getLastText().trimmed();
|
auto q = _filter->getLastText().trimmed();
|
||||||
|
|
|
@ -102,8 +102,6 @@ public:
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onDraggingScrollDelta(int delta);
|
|
||||||
|
|
||||||
void onListScroll();
|
void onListScroll();
|
||||||
bool onCancelSearch();
|
bool onCancelSearch();
|
||||||
void onCancelSearchInChat();
|
void onCancelSearchInChat();
|
||||||
|
@ -117,9 +115,6 @@ public Q_SLOTS:
|
||||||
|
|
||||||
void onChooseByDrag();
|
void onChooseByDrag();
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onDraggingScrollTimer();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
|
@ -247,9 +242,6 @@ private:
|
||||||
|
|
||||||
QPixmap _widthAnimationCache;
|
QPixmap _widthAnimationCache;
|
||||||
|
|
||||||
object_ptr<QTimer> _draggingScrollTimer = { nullptr };
|
|
||||||
int _draggingScrollDelta = 0;
|
|
||||||
|
|
||||||
int _topDelta = 0;
|
int _topDelta = 0;
|
||||||
|
|
||||||
rpl::event_stream<> _closeForwardBarRequests;
|
rpl::event_stream<> _closeForwardBarRequests;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d27e4803a130a262b84a54c915fc83f8c9bbe2f4
|
Subproject commit ba40979470132db759fe8b8e7ff8ca70845f92c1
|
Loading…
Add table
Reference in a new issue