From 59e9a91a1e805b71662579185e1f0955e72fbff4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 14 Apr 2026 22:19:29 +0700 Subject: [PATCH] First text appearing animation duration floor. --- Telegram/SourceFiles/history/view/history_view_message.cpp | 7 ++++++- Telegram/SourceFiles/history/view/history_view_message.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 9539c1e794..f975a839c0 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -72,6 +72,7 @@ constexpr auto kFullLineAppearDuration = crl::time(300); constexpr auto kFullLineAppearFinalDuration = crl::time(120); constexpr auto kLineHeightAppearDuration = crl::time(100); constexpr auto kLineHeightAppearFinalDuration = crl::time(60); +constexpr auto kMinWidthAppearDuration = crl::time(160); void ApplyRevealGradient( not_null appearing, @@ -979,6 +980,7 @@ QSize Message::performCountOptimalSize() { } if (const auto appearing = Get()) { appearing->geometryValid = false; + appearing->startedForText = false; appearing->finalizing = item->isRegular(); } return QSize(maxWidth, minHeight); @@ -5454,11 +5456,14 @@ void Message::textAppearStartWidthAnimation( const auto lineDuration = appearing->finalizing ? kFullLineAppearFinalDuration : kFullLineAppearDuration; - const auto duration = (shown + 1 == lines) + const auto computed = (shown + 1 == lines) ? lineDuration : std::max( lineDuration * lineWidth / st::msgMaxWidth, crl::time(10)); + const auto duration = std::exchange(appearing->startedForText, true) + ? computed + : std::max(computed, kMinWidthAppearDuration); appearing->widthDuration = duration; const auto from = appearing->startLineWidth diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index 75e7fc2d9d..bb6d27e3f3 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -96,6 +96,7 @@ struct TextAppearing : RuntimeComponent { Ui::Animations::Simple widthAnimation; Ui::Animations::Simple heightAnimation; bool geometryValid = false; + bool startedForText = false; bool finalizing = false; bool use = false; mutable QImage lineCache;