Fix text appearing height animation.

This commit is contained in:
John Preston
2026-04-21 16:26:32 +07:00
parent 4f89780cfe
commit f34e62f24a
2 changed files with 9 additions and 8 deletions
@@ -5153,7 +5153,7 @@ int Message::resizeContentGetHeight(int newWidth) {
} }
if (!mediaDisplayed && bubble && hasVisibleText()) { if (!mediaDisplayed && bubble && hasVisibleText()) {
const auto probeTextWidth = bubbleTextWidth(contentWidth); const auto probeTextWidth = bubbleTextWidth(contentWidth);
[[maybe_unused]] const auto probeHeight = textHeightFor(probeTextWidth); [[maybe_unused]] const auto probe = textHeightFor(probeTextWidth);
if (!Get<TextAppearing>()) { if (!Get<TextAppearing>()) {
const auto use = textRealWidth(); const auto use = textRealWidth();
if (use > 0) { if (use > 0) {
@@ -5439,7 +5439,7 @@ bool Message::textAppearCheckLine(not_null<TextAppearing*> appearing) {
if (appearing->heightAnimation.animating() if (appearing->heightAnimation.animating()
|| !appearing->widthAnimation.animating() || !appearing->widthAnimation.animating()
|| left <= duration) { || left <= duration) {
textAppearStartHeightAnimation(appearing); textAppearStartHeightAnimation(appearing, targetHeight);
} }
} }
} }
@@ -5477,13 +5477,12 @@ void Message::textAppearStartWidthAnimation(
} }
void Message::textAppearStartHeightAnimation( void Message::textAppearStartHeightAnimation(
not_null<TextAppearing*> appearing) { not_null<TextAppearing*> appearing,
int targetHeight) {
Expects(appearing->use); Expects(appearing->use);
const auto from = appearing->shownHeight; const auto from = appearing->shownHeight;
const auto to const auto to = appearing->targetHeight = targetHeight;
= appearing->targetHeight
= textAppearTargetHeight(appearing);
const auto duration = appearing->finalizing const auto duration = appearing->finalizing
? kLineHeightAppearFinalDuration ? kLineHeightAppearFinalDuration
: kLineHeightAppearDuration; : kLineHeightAppearDuration;
@@ -5496,7 +5495,7 @@ int Message::textAppearTargetHeight(
not_null<TextAppearing*> appearing) const { not_null<TextAppearing*> appearing) const {
const auto next = appearing->shownLine + 1; const auto next = appearing->shownLine + 1;
const auto lines = int(appearing->lines.size()); const auto lines = int(appearing->lines.size());
if (next >= lines) { if (next + 1 >= lines) {
return appearing->lines.back().bottom; return appearing->lines.back().bottom;
} }
const auto &line = appearing->lines[next]; const auto &line = appearing->lines[next];
@@ -397,7 +397,9 @@ private:
bool textAppearValidate(not_null<TextAppearing*> appearing); bool textAppearValidate(not_null<TextAppearing*> appearing);
bool textAppearCheckLine(not_null<TextAppearing*> appearing); bool textAppearCheckLine(not_null<TextAppearing*> appearing);
void textAppearStartWidthAnimation(not_null<TextAppearing*> appearing); void textAppearStartWidthAnimation(not_null<TextAppearing*> appearing);
void textAppearStartHeightAnimation(not_null<TextAppearing*> appearing); void textAppearStartHeightAnimation(
not_null<TextAppearing*> appearing,
int targetHeight);
void textAppearWidthCallback(); void textAppearWidthCallback();
void textAppearHeightCallback(); void textAppearHeightCallback();
[[nodiscard]] int textAppearTargetHeight( [[nodiscard]] int textAppearTargetHeight(