From 96b7755cde53aae73d5996c2800e4d50b7b9113a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 4 Sep 2024 15:35:19 +0300 Subject: [PATCH] Fixed updating of message on bounce animation of swipe-on-reply icon. --- .../history/history_inner_widget.cpp | 3 ++- .../history/history_view_swipe.cpp | 21 +++++++++---------- .../view/history_view_replies_section.cpp | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index c38ad8e0e..a8911f2b3 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -582,7 +582,8 @@ void HistoryInner::setupSwipeReply() { HistoryView::SetupSwipeHandler(this, _scroll, [=, history = _history]( HistoryView::ChatPaintGestureHorizontalData data) { const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId) - || (_gestureHorizontal.translation != data.translation); + || (_gestureHorizontal.translation != data.translation) + || (_gestureHorizontal.reachRatio != data.reachRatio); _gestureHorizontal = data; if (changed) { const auto item = history->peer->owner().message( diff --git a/Telegram/SourceFiles/history/history_view_swipe.cpp b/Telegram/SourceFiles/history/history_view_swipe.cpp index 8d7648673..64a6f811f 100644 --- a/Telegram/SourceFiles/history/history_view_swipe.cpp +++ b/Telegram/SourceFiles/history/history_view_swipe.cpp @@ -33,6 +33,7 @@ void SetupSwipeHandler( base::unique_qptr filter; Ui::Animations::Simple animationReach; Ui::Animations::Simple animationEnd; + ChatPaintGestureHorizontalData data; SwipeHandlerFinishData finishByTopData; std::optional orientation; QPointF startAt; @@ -53,14 +54,12 @@ void SetupSwipeHandler( }, state->lifetime); const auto updateRatio = [=](float64 ratio) { - update({ - .ratio = std::clamp(ratio, 0., 1.5), - .reachRatio = state->animationReach.value(0.), - .msgBareId = state->finishByTopData.msgBareId, - .translation = int( - base::SafeRound(-std::clamp(ratio, 0., 1.5) * threshold)), - .cursorTop = state->cursorTop, - }); + state->data.ratio = std::clamp(ratio, 0., 1.5), + state->data.msgBareId = state->finishByTopData.msgBareId; + state->data.translation = int( + base::SafeRound(-std::clamp(ratio, 0., 1.5) * threshold)); + state->data.cursorTop = state->cursorTop; + update(state->data); }; const auto setOrientation = [=](std::optional o) { state->orientation = o; @@ -78,7 +77,6 @@ void SetupSwipeHandler( widget, state->finishByTopData.callback); } - state->animationReach.stop(); state->animationEnd.stop(); state->animationEnd.start( updateRatio, @@ -95,8 +93,9 @@ void SetupSwipeHandler( processEnd(); } }, state->lifetime); - const auto animationReachCallback = [=] { - updateRatio(state->delta.x() / threshold); + const auto animationReachCallback = [=](float64 value) { + state->data.reachRatio = value; + update(state->data); }; struct UpdateArgs { QPoint globalCursor; diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index e54af4e2e..69e60a5f3 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -883,7 +883,8 @@ void RepliesWidget::setupSwipeReply() { HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=]( HistoryView::ChatPaintGestureHorizontalData data) { const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId) - || (_gestureHorizontal.translation != data.translation); + || (_gestureHorizontal.translation != data.translation) + || (_gestureHorizontal.reachRatio != data.reachRatio); _gestureHorizontal = data; if (changed) { const auto item = _history->peer->owner().message(