diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index e6c4cd2c7e..4ceff1d21f 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/toasts/common_toasts.h" #include "ui/inactive_press.h" +#include "ui/effects/message_sending_animation_controller.h" #include "ui/effects/path_shift_gradient.h" #include "ui/chat/chat_theme.h" #include "ui/chat/chat_style.h" @@ -1555,6 +1556,7 @@ void ListWidget::resizeToWidth(int newWidth, int minHeight) { void ListWidget::startItemRevealAnimations() { for (const auto &view : base::take(_itemRevealPending)) { if (const auto height = view->height()) { + startMessageSendingAnimation(view->data()); if (!_itemRevealAnimations.contains(view)) { auto &animation = _itemRevealAnimations[view]; animation.startHeight = height; @@ -1573,6 +1575,30 @@ void ListWidget::startItemRevealAnimations() { } } +void ListWidget::startMessageSendingAnimation( + not_null item) { + auto &sendingAnimation = controller()->sendingAnimation(); + if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) { + return; + } + + auto globalEndGeometry = rpl::merge( + session().data().newItemAdded() | rpl::to_empty, + geometryValue() | rpl::to_empty + ) | rpl::map([=] { + const auto view = viewForItem(item); + const auto additional = !_visibleTop ? view->height() : 0; + return mapToGlobal( + view->innerGeometry().translated(0, itemTop(view) - additional)); + }); + + sendingAnimation.startAnimation({ + .globalEndGeometry = std::move(globalEndGeometry), + .view = [=] { return viewForItem(item); }, + .theme = _delegate->listChatTheme(), + }); +} + void ListWidget::revealItemsCallback() { auto revealHeight = 0; for (auto i = begin(_itemRevealAnimations) @@ -1744,13 +1770,16 @@ void ListWidget::paintEvent(QPaintEvent *e) { .clip = clip, }).translated(0, -top); p.translate(0, top); + const auto &sendingAnimation = _controller->sendingAnimation(); for (auto i = from; i != to; ++i) { const auto view = *i; - context.reactionInfo - = _reactionsManager->currentReactionPaintInfo(); - context.outbg = view->hasOutLayout(); - context.selection = itemRenderSelection(view); - view->draw(p, context); + if (!sendingAnimation.hasAnimatedMessage(view->data())) { + context.reactionInfo + = _reactionsManager->currentReactionPaintInfo(); + context.outbg = view->hasOutLayout(); + context.selection = itemRenderSelection(view); + view->draw(p, context); + } _reactionsManager->recordCurrentReactionEffect( view->data()->fullId(), QPoint(0, top)); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index 2719cbb0d2..17ae06dd96 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -504,6 +504,8 @@ private: void startItemRevealAnimations(); void revealItemsCallback(); + void startMessageSendingAnimation(not_null item); + void updateHighlightedMessage(); void clearHighlightedMessage(); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index c98da84eca..c8356bbc61 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_utilities.h" #include "ui/chat/attach/attach_prepare.h" #include "ui/chat/attach/attach_send_files_way.h" +#include "ui/effects/message_sending_animation_controller.h" #include "ui/special_buttons.h" #include "ui/ui_utility.h" #include "ui/toasts/common_toasts.h" @@ -546,7 +547,12 @@ void RepliesWidget::setupComposeControls() { _composeControls->fileChosen( ) | rpl::start_with_next([=](Selector::FileChosen chosen) { - sendExistingDocument(chosen.document, chosen.options); + controller()->sendingAnimation().appendSending( + chosen.messageSendingFrom); + sendExistingDocument( + chosen.document, + chosen.options, + chosen.messageSendingFrom.localId); }, lifetime()); _composeControls->photoChosen( @@ -1060,7 +1066,7 @@ void RepliesWidget::edit( void RepliesWidget::sendExistingDocument( not_null document) { - sendExistingDocument(document, {}); + sendExistingDocument(document, {}, std::nullopt); // #TODO replies schedule //const auto callback = [=](Api::SendOptions options) { // sendExistingDocument(document, options); @@ -1072,7 +1078,8 @@ void RepliesWidget::sendExistingDocument( bool RepliesWidget::sendExistingDocument( not_null document, - Api::SendOptions options) { + Api::SendOptions options, + std::optional localId) { const auto error = Data::RestrictionError( _history->peer, ChatRestriction::SendStickers); @@ -1087,7 +1094,8 @@ bool RepliesWidget::sendExistingDocument( Api::SendExistingDocument( Api::MessageToSend(prepareSendAction(options)), - document); + document, + localId); _composeControls->cancelReplyMessage(); finishSending(); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 35511a2bd9..4102c4622a 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -245,7 +245,8 @@ private: void sendExistingDocument(not_null document); bool sendExistingDocument( not_null document, - Api::SendOptions options); + Api::SendOptions options, + std::optional localId); void sendExistingPhoto(not_null photo); bool sendExistingPhoto( not_null photo,