diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 8c10c2f80..aaad3e63e 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -895,31 +895,34 @@ void HistoryWidget::scrollToAnimationCallback( void HistoryWidget::enqueueMessageHighlight( not_null view) { + const auto originalItem = view->data(); if (const auto group = session().data().groups().find(view->data())) { if (const auto leader = group->items.back()->mainView()) { view = leader; } } - auto enqueueMessageId = [this](MsgId universalId) { + auto enqueueMessageId = [this](MsgId universalId, MsgId originalId) { if (_highlightQueue.empty() && !_highlightTimer.isActive()) { - highlightMessage(universalId); + highlightMessage(universalId, originalId); } else if (_highlightedMessageId != universalId && !base::contains(_highlightQueue, universalId)) { _highlightQueue.push_back(universalId); + _highlightOriginalQueue.push_back(originalId); checkNextHighlight(); } }; const auto item = view->data(); if (item->history() == _history) { - enqueueMessageId(item->id); + enqueueMessageId(item->id, originalItem->id); } else if (item->history() == _migrated) { - enqueueMessageId(-item->id); + enqueueMessageId(-item->id, -originalItem->id); } } -void HistoryWidget::highlightMessage(MsgId universalMessageId) { +void HistoryWidget::highlightMessage(MsgId universalMessageId, MsgId originalMessageId) { _highlightStart = crl::now(); _highlightedMessageId = universalMessageId; + _highlightedOriginalMessageId = originalMessageId; _highlightTimer.callEach(AnimationTimerDelta); } @@ -938,10 +941,21 @@ void HistoryWidget::checkNextHighlight() { } return 0; }(); - if (!nextHighlight) { + auto nextOriginalHighlight = [this] { + while (!_highlightOriginalQueue.empty()) { + auto msgId = _highlightOriginalQueue.front(); + _highlightOriginalQueue.pop_front(); + auto item = getItemFromHistoryOrMigrated(msgId); + if (item && item->mainView()) { + return msgId; + } + } + return 0; + }(); + if (!nextHighlight || !nextOriginalHighlight) { return; } - highlightMessage(nextHighlight); + highlightMessage(nextHighlight, nextOriginalHighlight); } void HistoryWidget::updateHighlightedMessage() { @@ -975,11 +989,13 @@ crl::time HistoryWidget::highlightStartTime(not_null item) c void HistoryWidget::stopMessageHighlight() { _highlightTimer.cancel(); _highlightedMessageId = 0; + _highlightedOriginalMessageId = 0; checkNextHighlight(); } void HistoryWidget::clearHighlightMessages() { _highlightQueue.clear(); + _highlightOriginalQueue.clear(); stopMessageHighlight(); } @@ -3145,6 +3161,11 @@ MsgId HistoryWidget::msgId() const { return _showAtMsgId; } +MsgId HistoryWidget::highlightOrigId() const { + return _highlightedOriginalMessageId; +} + + void HistoryWidget::showAnimated( Window::SlideDirection direction, const Window::SectionSlideParams ¶ms) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 5fc23a1ce..f62bc9c56 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -147,6 +147,7 @@ public: PeerData *peer() const; void setMsgId(MsgId showAtMsgId); MsgId msgId() const; + MsgId highlightOrigId() const; bool hasTopBarShadow() const { return peer() != nullptr; @@ -402,7 +403,7 @@ private: void supportInsertText(const QString &text); void supportShareContact(Support::Contact contact); - void highlightMessage(MsgId universalMessageId); + void highlightMessage(MsgId universalMessageId, MsgId originalMessageId); void checkNextHighlight(); void updateHighlightedMessage(); void clearHighlightMessages(); @@ -791,6 +792,8 @@ private: MsgId _highlightedMessageId = 0; std::deque _highlightQueue; + MsgId _highlightedOriginalMessageId = 0; + std::deque _highlightOriginalQueue; base::Timer _highlightTimer; crl::time _highlightStart = 0; diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 9d7e1b6d4..8a527da80 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_photo.h" #include "data/data_file_origin.h" +#include "mainwidget.h" #include "app.h" #include "styles/style_history.h" @@ -368,7 +369,25 @@ void Photo::drawGrouped( if (!bubble) { // App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); } - p.drawPixmap(geometry.topLeft(), *cache); + const auto animms = _parent->delegate()->elementHighlightTime(_parent); + const auto realId = _realParent->id; + const auto mainWidget = App::main(); + const auto highlightedRealId = mainWidget->highlightedOriginalId(); + if (realId != highlightedRealId + && animms + && animms < st::activeFadeInDuration + st::activeFadeOutDuration) { + const auto dt = (animms <= st::activeFadeInDuration) + ? ((animms / float64(st::activeFadeInDuration))) + : (1. - (animms - st::activeFadeInDuration) + / float64(st::activeFadeOutDuration)); + const auto o = p.opacity(); + p.setOpacity(o - dt * 0.8); + p.drawPixmap(geometry.topLeft(), *cache); + p.setOpacity(o); + } else { + p.drawPixmap(geometry.topLeft(), *cache); + } + if (selected) { const auto roundRadius = ImageRoundRadius::Large; App::complexOverlayRect(p, geometry, roundRadius, corners); diff --git a/Telegram/SourceFiles/history/view/media/history_view_video.cpp b/Telegram/SourceFiles/history/view/media/history_view_video.cpp index 12ef0cb56..f8a6f3552 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_video.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_video.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_document.h" #include "data/data_file_origin.h" +#include "mainwidget.h" #include "app.h" #include "styles/style_history.h" @@ -410,7 +411,24 @@ void Video::drawGrouped( if (!bubble) { // App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); } - p.drawPixmap(geometry.topLeft(), *cache); + const auto animms = _parent->delegate()->elementHighlightTime(_parent); + const auto realId = _realParent->id; + const auto mainWidget = App::main(); + const auto highlightedRealId = mainWidget->highlightedOriginalId(); + if (realId != highlightedRealId + && animms + && animms < st::activeFadeInDuration + st::activeFadeOutDuration) { + const auto dt = (animms <= st::activeFadeInDuration) + ? ((animms / float64(st::activeFadeInDuration))) + : (1. - (animms - st::activeFadeInDuration) + / float64(st::activeFadeOutDuration)); + const auto o = p.opacity(); + p.setOpacity(o - dt * 0.8); + p.drawPixmap(geometry.topLeft(), *cache); + p.setOpacity(o); + } else { + p.drawPixmap(geometry.topLeft(), *cache); + } if (selected) { const auto roundRadius = ImageRoundRadius::Large; App::complexOverlayRect(p, geometry, roundRadius, corners); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 9f4c67059..ac31b319e 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -778,6 +778,10 @@ void MainWidget::notify_historyMuteUpdated(History *history) { _dialogs->notify_historyMuteUpdated(history); } +MsgId MainWidget::highlightedOriginalId() const { + return _history->highlightOrigId(); +} + void MainWidget::clearHider(not_null instance) { if (_hider != instance) { return; diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index d614658b3..304a97dcf 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -292,6 +292,8 @@ public: void notify_showScheduledButtonChanged(); void notify_historyMuteUpdated(History *history); + MsgId highlightedOriginalId() const; + void closeBothPlayers(); bool isQuitPrevent();