diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index e982f5b714..644c26a797 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -321,7 +321,8 @@ HistoryInner::HistoryInner( , _history(history) , _elementDelegate(_history->delegateMixin()->delegate()) , _emojiInteractions(std::make_unique( - &controller->session())) + &controller->session(), + [=](not_null view) { return itemTop(view); })) , _migrated(history->migrateFrom()) , _pathGradient( HistoryView::MakePathShiftGradient( @@ -375,7 +376,7 @@ HistoryInner::HistoryInner( }, lifetime()); _emojiInteractions->updateRequests( ) | rpl::start_with_next([=](QRect rect) { - update(rect.translated(0, _historyPaddingTop)); + update(rect); }, lifetime()); _emojiInteractions->playStarted( ) | rpl::start_with_next([=](QString &&emoji) { @@ -1173,8 +1174,6 @@ void HistoryInner::paintEvent(QPaintEvent *e) { p.setOpacity(1.); _reactionsManager->paint(p, context); - - p.translate(0, _historyPaddingTop); _emojiInteractions->paint(p); } @@ -2831,8 +2830,8 @@ void HistoryInner::visibleAreaUpdated(int top, int bottom) { checkHistoryActivation(); _emojiInteractions->visibleAreaUpdated( - _visibleAreaTop - _historyPaddingTop, - _visibleAreaBottom - _historyPaddingTop); + _visibleAreaTop, + _visibleAreaBottom); } bool HistoryInner::displayScrollDate() const { diff --git a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp index 2ce4f9c79e..70cc94fac4 100644 --- a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp +++ b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp @@ -44,8 +44,11 @@ constexpr auto kDropDelayedAfterDelay = crl::time(2000); } // namespace -EmojiInteractions::EmojiInteractions(not_null session) -: _session(session) { +EmojiInteractions::EmojiInteractions( + not_null session, + Fn)> itemTop) +: _session(session) +, _itemTop(std::move(itemTop)) { _session->data().viewRemoved( ) | rpl::filter([=] { return !_plays.empty() || !_delayed.empty(); @@ -241,7 +244,10 @@ QRect EmojiInteractions::computeRect( const auto left = rightAligned ? (fullWidth - skip + shift - size.width()) : (skip - shift); - const auto viewTop = view->block()->y() + view->y() + view->marginTop(); + const auto viewTop = _itemTop(view) + view->marginTop(); + if (viewTop < 0) { + return QRect(); + } const auto top = viewTop + (sticker.height() - size.height()) / 2; return QRect(QPoint(left, top), size); } diff --git a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.h b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.h index e3871b54d1..83414a9ae0 100644 --- a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.h +++ b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.h @@ -30,7 +30,9 @@ class Element; class EmojiInteractions final { public: - explicit EmojiInteractions(not_null session); + EmojiInteractions( + not_null session, + Fn)> itemTop); ~EmojiInteractions(); void play( @@ -90,6 +92,7 @@ private: bool premium); const not_null _session; + const Fn)> _itemTop; int _visibleTop = 0; int _visibleBottom = 0;