Improve touchscreen chats list stories physics.
This commit is contained in:
parent
fba1b79252
commit
71e341237d
|
@ -479,6 +479,10 @@ rpl::producer<bool> InnerWidget::storiesExpandedRequests() const {
|
||||||
_storiesExpandedRequests.events());
|
_storiesExpandedRequests.events());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InnerWidget::setTouchScrollActive(bool active) {
|
||||||
|
_stories->setTouchScrollActive(active);
|
||||||
|
}
|
||||||
|
|
||||||
int InnerWidget::defaultScrollTop() const {
|
int InnerWidget::defaultScrollTop() const {
|
||||||
return storiesShown()
|
return storiesShown()
|
||||||
? std::max(_stories->height() - st::dialogsStories.height, 0)
|
? std::max(_stories->height() - st::dialogsStories.height, 0)
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
const QVector<MTPPeer> &my,
|
const QVector<MTPPeer> &my,
|
||||||
const QVector<MTPPeer> &result);
|
const QVector<MTPPeer> &result);
|
||||||
|
|
||||||
|
void setTouchScrollActive(bool active);
|
||||||
[[nodiscard]] rpl::producer<bool> storiesExpandedRequests() const;
|
[[nodiscard]] rpl::producer<bool> storiesExpandedRequests() const;
|
||||||
[[nodiscard]] int defaultScrollTop() const;
|
[[nodiscard]] int defaultScrollTop() const;
|
||||||
void setViewportHeight(int viewportHeight);
|
void setViewportHeight(int viewportHeight);
|
||||||
|
|
|
@ -327,6 +327,9 @@ Widget::Widget(
|
||||||
_scroll->setCustomWheelProcess([=](not_null<QWheelEvent*> e) {
|
_scroll->setCustomWheelProcess([=](not_null<QWheelEvent*> e) {
|
||||||
return customWheelProcess(e);
|
return customWheelProcess(e);
|
||||||
});
|
});
|
||||||
|
_scroll->setCustomTouchProcess([=](not_null<QTouchEvent*> e) {
|
||||||
|
return customTouchProcess(e);
|
||||||
|
});
|
||||||
|
|
||||||
session().data().chatsListChanges(
|
session().data().chatsListChanges(
|
||||||
) | rpl::filter([=](Data::Folder *folder) {
|
) | rpl::filter([=](Data::Folder *folder) {
|
||||||
|
@ -856,6 +859,7 @@ void Widget::changeOpenedSubsection(
|
||||||
}
|
}
|
||||||
oldContentCache = grabForFolderSlideAnimation();
|
oldContentCache = grabForFolderSlideAnimation();
|
||||||
}
|
}
|
||||||
|
_scroll->verticalScrollBar()->setMinimum(0);
|
||||||
_showAnimation = nullptr;
|
_showAnimation = nullptr;
|
||||||
destroyChildListCanvas();
|
destroyChildListCanvas();
|
||||||
change();
|
change();
|
||||||
|
@ -2394,6 +2398,27 @@ bool Widget::customWheelProcess(not_null<QWheelEvent*> e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::customTouchProcess(not_null<QTouchEvent*> e) {
|
||||||
|
const auto type = e->type();
|
||||||
|
const auto now = _scroll->scrollTop();
|
||||||
|
const auto def = _inner->defaultScrollTop();
|
||||||
|
const auto bar = _scroll->verticalScrollBar();
|
||||||
|
_allowStoriesExpandTimer.cancel();
|
||||||
|
if (type == QEvent::TouchBegin
|
||||||
|
|| type == QEvent::TouchUpdate) {
|
||||||
|
_inner->setTouchScrollActive(true);
|
||||||
|
bar->setMinimum(0);
|
||||||
|
} else if (type == QEvent::TouchEnd || type == QEvent::TouchCancel) {
|
||||||
|
_inner->setTouchScrollActive(false);
|
||||||
|
if (def > 0 && now >= def) {
|
||||||
|
bar->setMinimum(def);
|
||||||
|
} else {
|
||||||
|
bar->setMinimum(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::resizeEvent(QResizeEvent *e) {
|
void Widget::resizeEvent(QResizeEvent *e) {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ private:
|
||||||
void filterCursorMoved();
|
void filterCursorMoved();
|
||||||
void completeHashtag(QString tag);
|
void completeHashtag(QString tag);
|
||||||
bool customWheelProcess(not_null<QWheelEvent*> e);
|
bool customWheelProcess(not_null<QWheelEvent*> e);
|
||||||
|
bool customTouchProcess(not_null<QTouchEvent*> e);
|
||||||
|
|
||||||
[[nodiscard]] QString currentSearchQuery() const;
|
[[nodiscard]] QString currentSearchQuery() const;
|
||||||
void clearSearchField();
|
void clearSearchField();
|
||||||
|
|
|
@ -306,7 +306,7 @@ List::Layout List::computeLayout() {
|
||||||
_lastHeight = shownHeight;
|
_lastHeight = shownHeight;
|
||||||
if (_lastHeight == st.height || _lastHeight == full.height) {
|
if (_lastHeight == st.height || _lastHeight == full.height) {
|
||||||
_snapExpandedTimer.cancel();
|
_snapExpandedTimer.cancel();
|
||||||
} else {
|
} else if (!_touchScrollActive) {
|
||||||
_snapExpandedTimer.callOnce(kSnapExpandedTimeout);
|
_snapExpandedTimer.callOnce(kSnapExpandedTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,6 +831,17 @@ void List::setBgOverride(QBrush brush) {
|
||||||
_bgOverride = std::move(brush);
|
_bgOverride = std::move(brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void List::setTouchScrollActive(bool active) {
|
||||||
|
if (_touchScrollActive != active) {
|
||||||
|
_touchScrollActive = active;
|
||||||
|
if (active) {
|
||||||
|
_snapExpandedTimer.cancel();
|
||||||
|
} else {
|
||||||
|
requestExpanded(_expanded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void List::contextMenuEvent(QContextMenuEvent *e) {
|
void List::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
Fn<int()> shownHeight);
|
Fn<int()> shownHeight);
|
||||||
|
|
||||||
void setBgOverride(QBrush brush);
|
void setBgOverride(QBrush brush);
|
||||||
|
void setTouchScrollActive(bool active);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
||||||
[[nodiscard]] rpl::producer<uint64> showProfileRequests() const;
|
[[nodiscard]] rpl::producer<uint64> showProfileRequests() const;
|
||||||
|
@ -189,6 +190,7 @@ private:
|
||||||
float64 _lastRatio = 0.;
|
float64 _lastRatio = 0.;
|
||||||
int _lastHeight = 0;
|
int _lastHeight = 0;
|
||||||
bool _expanded = false;
|
bool _expanded = false;
|
||||||
|
bool _touchScrollActive = false;
|
||||||
|
|
||||||
int _selected = -1;
|
int _selected = -1;
|
||||||
int _pressed = -1;
|
int _pressed = -1;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8908c9b5c041f51176383a55e0b324588b28b68d
|
Subproject commit 6fe9e0838685b0a799057a9218c4beca0cd7c52e
|
Loading…
Reference in New Issue
Block a user