diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 16f130f6c..9cd83916e 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5394,7 +5394,7 @@ void HistoryWidget::startMessageSendingAnimation( Assert(item->mainView() != nullptr); Assert(item->mainView()->media() != nullptr); - auto globalEndGeometry = rpl::merge( + auto globalEndTopLeft = rpl::merge( _scroll->innerResizes() | rpl::to_empty, session().data().newItemAdded() | rpl::to_empty, geometryValue() | rpl::to_empty, @@ -5405,13 +5405,13 @@ void HistoryWidget::startMessageSendingAnimation( const auto additional = (_list->height() == _scroll->height()) ? view->height() : 0; - return _list->mapToGlobal(view->innerGeometry().translated( + return _list->mapToGlobal(QPoint( 0, _list->itemTop(view) - additional)); }); sendingAnimation.startAnimation({ - .globalEndGeometry = std::move(globalEndGeometry), + .globalEndTopLeft = std::move(globalEndTopLeft), .view = [=] { return item->mainView(); }, .paintContext = [=] { return _list->preparePaintContext({}); }, }); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 6ddff5ee2..1a122b8d0 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1582,18 +1582,17 @@ void ListWidget::startMessageSendingAnimation( return; } - auto globalEndGeometry = rpl::merge( + auto globalEndTopLeft = 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)); + return mapToGlobal(QPoint(0, itemTop(view) - additional)); }); sendingAnimation.startAnimation({ - .globalEndGeometry = std::move(globalEndGeometry), + .globalEndTopLeft = std::move(globalEndTopLeft), .view = [=] { return viewForItem(item); }, .paintContext = [=] { return preparePaintContext({}); }, }); diff --git a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp index 242a756b8..398fdcfb0 100644 --- a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp +++ b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.cpp @@ -53,7 +53,7 @@ private: const not_null _controller; MessageSendingAnimationController::SendingInfoTo _toInfo; QRect _from; - QRect _to; + QPoint _to; QRect _innerContentRect; Animations::Simple _animation; @@ -74,7 +74,8 @@ Content::Content( , _controller(controller) , _toInfo(std::move(to)) , _from(parent->mapFromGlobal(globalGeometryFrom)) -, _innerContentRect(view()->media()->contentRectForReactions()) { +, _innerContentRect(view()->media()->contentRectForReactions()) +, _minScale(float64(_from.height()) / _innerContentRect.height()) { Expects(_toInfo.view != nullptr); Expects(_toInfo.paintContext != nullptr); @@ -83,11 +84,10 @@ Content::Content( raise(); base::take( - _toInfo.globalEndGeometry + _toInfo.globalEndTopLeft ) | rpl::distinct_until_changed( - ) | rpl::start_with_next([=](const QRect &r) { - _to = parent->mapFromGlobal(r); - _minScale = float64(_from.height()) / _to.height(); + ) | rpl::start_with_next([=](const QPoint &p) { + _to = parent->mapFromGlobal(p); }, lifetime()); _controller->session().downloaderTaskFinished( @@ -97,11 +97,15 @@ Content::Content( resize(_innerContentRect.size()); + const auto innerGeometry = view()->innerGeometry(); + auto animationCallback = [=](float64 value) { auto resultFrom = rect(); resultFrom.moveCenter(_from.center()); - const auto resultTo = _to.topLeft() + _innerContentRect.topLeft(); + const auto resultTo = _to + + innerGeometry.topLeft() + + _innerContentRect.topLeft(); const auto x = anim::interpolate(resultFrom.x(), resultTo.x(), value); const auto y = anim::interpolate(resultFrom.y(), resultTo.y(), value); moveToLeft(x, y); diff --git a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h index 97f937f80..541d3f6b2 100644 --- a/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h +++ b/Telegram/SourceFiles/ui/effects/message_sending_animation_controller.h @@ -29,7 +29,7 @@ public: not_null controller); struct SendingInfoTo { - rpl::producer globalEndGeometry; + rpl::producer globalEndTopLeft; Fn()> view; Fn paintContext; };