Fixed updating of message on bounce animation of swipe-on-reply icon.

This commit is contained in:
23rd 2024-09-04 15:35:19 +03:00 committed by John Preston
parent c589ee1ca5
commit 96b7755cde
3 changed files with 14 additions and 13 deletions

View file

@ -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(

View file

@ -33,6 +33,7 @@ void SetupSwipeHandler(
base::unique_qptr<QObject> filter;
Ui::Animations::Simple animationReach;
Ui::Animations::Simple animationEnd;
ChatPaintGestureHorizontalData data;
SwipeHandlerFinishData finishByTopData;
std::optional<Qt::Orientation> 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<Qt::Orientation> 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;

View file

@ -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(