diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index b8b955c3d9..a1719702d8 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -326,6 +326,11 @@ ListWidget::ListWidget( ) | rpl::start_with_next([=](bool wide) { _isChatWide = wide; }, lifetime()); + + _selectScroll.scrolls( + ) | rpl::start_with_next([=](int d) { + delegate->listScrollTo(_visibleTop + d); + }, lifetime()); } Main::Session &ListWidget::session() const { @@ -2326,7 +2331,7 @@ void ListWidget::mouseActionCancel() { _mouseAction = MouseAction::None; clearDragSelection(); _wasSelectedText = false; - //_widget->noSelectingScroll(); // #TODO select scroll + _selectScroll.cancel(); } void ListWidget::mouseActionFinish( @@ -2410,7 +2415,7 @@ void ListWidget::mouseActionFinish( } _mouseAction = MouseAction::None; _mouseSelectType = TextSelectType::Letters; - //_widget->noSelectingScroll(); // #TODO select scroll + _selectScroll.cancel(); if (QGuiApplication::clipboard()->supportsSelection() && _selectedTextItem @@ -2605,11 +2610,14 @@ void ListWidget::mouseActionUpdate() { } } - //if (_mouseAction == MouseAction::Selecting) { - // _widget->checkSelectingScroll(mousePos); - //} else { - // _widget->noSelectingScroll(); - //} // #TODO select scroll + if (_mouseAction == MouseAction::Selecting) { + _selectScroll.checkDeltaScroll( + mousePosition, + _visibleTop, + _visibleBottom); + } else { + _selectScroll.cancel(); + } } style::cursor ListWidget::computeMouseCursor() const { @@ -2652,7 +2660,7 @@ std::unique_ptr ListWidget::prepareDrag() { }(); if (auto mimeData = TextUtilities::MimeDataFromText(selectedText)) { clearDragSelection(); -// _widget->noSelectingScroll(); #TODO scroll + _selectScroll.cancel(); if (!urls.isEmpty()) { mimeData->setUrls(urls); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index d690b274a2..7d52f1f062 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "ui/effects/animations.h" +#include "ui/chat/select_scroll_manager.h" // Has base/timer.h. #include "ui/widgets/tooltip.h" #include "mtproto/sender.h" -#include "base/timer.h" #include "data/data_messages.h" #include "history/view/history_view_element.h" @@ -590,6 +590,8 @@ private: FullMsgId _highlightedMessageId; base::Timer _highlightTimer; + Ui::SelectScrollManager _selectScroll; + rpl::event_stream _requestedToEditMessage; rpl::event_stream _requestedToReplyToMessage; rpl::event_stream _requestedToReadMessage;