Try ElasticScroll in Dialogs::Widget.

This commit is contained in:
John Preston 2023-07-07 22:49:30 +04:00
parent 08ee386b28
commit dc806d4286
4 changed files with 23 additions and 14 deletions

View File

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/scroll_area.h"
#include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/painter.h"

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_group_call_bar.h"
#include "boxes/peers/edit_peer_requests_box.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/elastic_scroll.h"
#include "ui/widgets/input_fields.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/effects/radial_animation.h"
@ -211,7 +212,7 @@ Widget::Widget(
, _lockUnlock(_searchControls, st::dialogsLock)
, _scroll(this)
, _allowStoriesExpandTimer([=] {
_scroll->verticalScrollBar()->setMinimum(0);
//_scroll->verticalScrollBar()->setMinimum(0);
})
, _scrollToTop(_scroll, st::dialogsToUp)
, _searchTimer([=] { searchMessages(); })
@ -269,7 +270,9 @@ Widget::Widget(
_inner->storiesExpandedRequests(
) | rpl::start_with_next([=](bool expanded) {
if (expanded || _scroll->scrollTop() < _inner->defaultScrollTop()) {
scrollToDefaultChecked(expanded);
if (_scroll->scrollTop() > 0) {
scrollToDefaultChecked(expanded);
}
}
}, lifetime());
@ -427,6 +430,7 @@ Widget::Widget(
setupSupportMode();
setupScrollUpButton();
_scroll->setOverscrollBg(st::dialogsBg->c);
if (_layout != Layout::Child) {
setupConnectingWidget();
@ -449,7 +453,11 @@ Widget::Widget(
}, lifetime());
_childListShown.changes(
) | rpl::start_with_next([=] {
) | rpl::start_with_next([=](float64 value) {
_scroll->setOverscrollBg(anim::color(
st::dialogsBg,
st::dialogsBgOver,
value));
updateControlsGeometry();
}, lifetime());
@ -867,7 +875,7 @@ void Widget::changeOpenedSubsection(
}
oldContentCache = grabForFolderSlideAnimation();
}
_scroll->verticalScrollBar()->setMinimum(0);
//_scroll->verticalScrollBar()->setMinimum(0);
_showAnimation = nullptr;
destroyChildListCanvas();
change();
@ -1143,7 +1151,7 @@ void Widget::jumpToTop(bool belowPinned) {
void Widget::scrollToDefault(bool verytop) {
if (verytop) {
_scroll->verticalScrollBar()->setMinimum(0);
//_scroll->verticalScrollBar()->setMinimum(0);
}
_scrollToAnimation.stop();
auto scrollTop = _scroll->scrollTop();
@ -2397,28 +2405,28 @@ bool Widget::customWheelProcess(not_null<QWheelEvent*> e) {
void Widget::customScrollProcess(Qt::ScrollPhase phase) {
const auto now = _scroll->scrollTop();
const auto def = _inner->defaultScrollTop();
const auto bar = _scroll->verticalScrollBar();
//const auto bar = _scroll->verticalScrollBar();
if (phase == Qt::ScrollBegin || phase == Qt::ScrollUpdate) {
_allowStoriesExpandTimer.cancel();
_inner->setTouchScrollActive(true);
bar->setMinimum(0);
//bar->setMinimum(0);
} else if (phase == Qt::ScrollEnd || phase == Qt::ScrollMomentum) {
_allowStoriesExpandTimer.cancel();
_inner->setTouchScrollActive(false);
if (def > 0 && now >= def) {
bar->setMinimum(def);
//bar->setMinimum(def);
} else {
bar->setMinimum(0);
//bar->setMinimum(0);
}
} else {
const auto allow = (def <= 0)
|| (now < def)
|| (now == def && !_allowStoriesExpandTimer.isActive());
if (allow) {
_scroll->verticalScrollBar()->setMinimum(0);
//_scroll->verticalScrollBar()->setMinimum(0);
_allowStoriesExpandTimer.cancel();
} else {
bar->setMinimum(def);
//bar->setMinimum(def);
_allowStoriesExpandTimer.callOnce(kWaitTillAllowStoriesExpand);
}
}

View File

@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_key.h"
#include "window/section_widget.h"
#include "ui/effects/animations.h"
#include "ui/widgets/scroll_area.h"
#include "mtproto/sender.h"
#include "api/api_single_message_search.h"
@ -46,6 +45,7 @@ class GroupCallBar;
class RequestsBar;
class MoreChatsBar;
class JumpDownButton;
class ElasticScroll;
template <typename Widget>
class FadeWrapScaled;
} // namespace Ui
@ -247,7 +247,7 @@ private:
std::unique_ptr<Ui::RequestsBar> _forumRequestsBar;
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
object_ptr<Ui::ScrollArea> _scroll;
object_ptr<Ui::ElasticScroll> _scroll;
base::Timer _allowStoriesExpandTimer;
QPointer<InnerWidget> _inner;
class BottomButton;

@ -1 +1 @@
Subproject commit d431d803c8b347c192d1bc9b6a206d2622a10748
Subproject commit 7135f3ed87ee1a6d89cebe6510a2250ffedfb1a9