From 3d2af9db8e53aa946bdb116c0aba5c2d1ab366b8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 3 Sep 2024 11:39:52 +0300 Subject: [PATCH] Improved distance of reply icon on left swipe. --- Telegram/SourceFiles/history/history_view_swipe.cpp | 2 +- .../SourceFiles/history/view/history_view_message.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/history_view_swipe.cpp b/Telegram/SourceFiles/history/history_view_swipe.cpp index a3bef4bd3..d83c3cda9 100644 --- a/Telegram/SourceFiles/history/history_view_swipe.cpp +++ b/Telegram/SourceFiles/history/history_view_swipe.cpp @@ -41,7 +41,7 @@ void SetupSwipeHandler( const auto state = widget->lifetime().make_state(); const auto updateRatio = [=](float64 ratio) { update({ - .ratio = std::clamp(ratio, 0., 1.), + .ratio = std::clamp(ratio, 0., 1.5), .reachRatio = state->animationReach.value(0.), .translation = (-std::clamp(ratio, 0., 1.5) * threshold), .msgBareId = state->finishByTopData.msgBareId, diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index fb6a5175b..86cdb4fcb 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1495,6 +1495,7 @@ void Message::draw(Painter &p, const PaintContext &context) const { constexpr auto kBouncePart = 0.25; constexpr auto kStrokeWidth = 2.; constexpr auto kWaveWidth = 10.; + const auto ratio = std::min(context.gestureHorizontal.ratio, 1.); const auto reachRatio = context.gestureHorizontal.reachRatio; const auto size = st::historyFastShareSize; const auto rect = QRectF( @@ -1503,8 +1504,7 @@ void Message::draw(Painter &p, const PaintContext &context) const { size, size); const auto center = rect::center(rect); - const auto spanAngle = context.gestureHorizontal.ratio - * arc::kFullLength; + const auto spanAngle = ratio * arc::kFullLength; const auto strokeWidth = style::ConvertFloatScale(kStrokeWidth); const auto reachScale = std::clamp( @@ -1523,7 +1523,7 @@ void Message::draw(Painter &p, const PaintContext &context) const { auto hq = PainterHighQualityEnabler(p); p.setPen(Qt::NoPen); p.setBrush(context.st->msgServiceBg()); - p.setOpacity(context.gestureHorizontal.ratio); + p.setOpacity(ratio); p.translate(center); if (reachScale) { p.scale(-(1. + 1. * reachScale), (1. + 1. * reachScale)); @@ -1546,7 +1546,7 @@ void Message::draw(Painter &p, const PaintContext &context) const { // p.drawArc(arcRect, arc::kQuarterLength, spanAngle); if (reachRatio) { const auto w = style::ConvertFloatScale(kWaveWidth); - p.setOpacity(context.gestureHorizontal.ratio - reachRatio); + p.setOpacity(ratio - reachRatio); p.drawArc( arcRect + Margins(reachRatio * reachRatio * w), arc::kQuarterLength,