diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 15ece8137e..f56ffa33ca 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -3996,7 +3996,7 @@ TextState Message::bottomInfoTextState( } int Message::infoWidth() const { - return _bottomInfo.optimalSize().width(); + return _bottomInfo.maxWidth(); } int Message::bottomInfoFirstLineWidth() const { @@ -5311,10 +5311,11 @@ bool Message::textAppearCheckLine(not_null appearing) { textAppearStartWidthAnimation(appearing); } } - if (appearing->targetHeight != line->bottom) { - if (!shown || appearing->shownHeight >= line->bottom) { + const auto targetHeight = textAppearTargetHeight(appearing); + if (appearing->targetHeight != targetHeight) { + if (!shown || appearing->shownHeight >= targetHeight) { appearing->heightAnimation.stop(); - appearing->shownHeight = appearing->targetHeight = line->bottom; + appearing->shownHeight = appearing->targetHeight = targetHeight; } else { const auto widthStart = appearing->startLineWidth; const auto widthTarget = appearing->targetLineWidth; @@ -5370,7 +5371,7 @@ void Message::textAppearStartHeightAnimation( const auto from = appearing->shownHeight; const auto to = appearing->targetHeight - = appearing->lines[appearing->shownLine].bottom; + = textAppearTargetHeight(appearing); const auto duration = appearing->finalizing ? kLineHeightAppearFinalDuration : kLineHeightAppearDuration; @@ -5379,6 +5380,24 @@ void Message::textAppearStartHeightAnimation( }, from, to, duration, anim::easeOutCubic); } +int Message::textAppearTargetHeight( + not_null appearing) const { + const auto shown = appearing->shownLine; + const auto lines = int(appearing->lines.size()); + if (shown + 1 >= lines) { + return appearing->lines.back().bottom; + } + const auto bottom = appearing->lines[shown].bottom; + const auto nextWidth = appearing->lines[shown + 1].width; + const auto available = std::max( + appearing->lines[shown].width, + appearing->shownWidth); + if (nextWidth + skipBlockWidth() <= available) { + return bottom; + } + return bottom + skipBlockHeight(); +} + void Message::textAppearWidthCallback() { const auto appearing = Get(); const auto now = int(base::SafeRound( diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index 88ad462005..e6a0aef743 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -397,6 +397,8 @@ private: void textAppearStartHeightAnimation(not_null appearing); void textAppearWidthCallback(); void textAppearHeightCallback(); + [[nodiscard]] int textAppearTargetHeight( + not_null appearing) const; void refreshRightBadge(); [[nodiscard]] int rightBadgeWidth() const;