From f1fe5f6a7167b4e5aa66095041295decebb5c012 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 19 Nov 2025 11:29:39 +0300 Subject: [PATCH] Fixed width of very long go-to-forum button in profile top bar. --- .../info/profile/info_profile_top_bar.cpp | 34 ++++++++++++++----- .../info/profile/info_profile_top_bar.h | 1 + 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index 30290fe3a6..4fbace0419 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -1396,6 +1396,17 @@ int TopBar::statusMostLeft() const { : _st.subtitlePosition.x(); } +int TopBar::calculateRightButtonsWidth() const { + auto width = 0; + if (_close) { + width += _close->width(); + } + if (_topBarButton) { + width += _topBarButton->width(); + } + return width; +} + void TopBar::updateLabelsPosition() { _progress = [&] { const auto max = QWidget::maximumHeight(); @@ -1407,13 +1418,7 @@ void TopBar::updateLabelsPosition() { }(); const auto progressCurrent = _progress.current(); - auto rightButtonsWidth = 0; - if (_close) { - rightButtonsWidth += _close->width(); - } - if (_topBarButton) { - rightButtonsWidth += _topBarButton->width(); - } + const auto rightButtonsWidth = calculateRightButtonsWidth(); const auto reservedRight = anim::interpolate( 0, @@ -1520,8 +1525,21 @@ void TopBar::updateStatusPosition(float64 progressCurrent) { _st.subtitlePosition.y(), st::infoProfileTopBarStatusTop, progressCurrent); + const auto mostLeft = statusMostLeft(); + const auto buttonMostLeft = anim::interpolate( + mostLeft, + st::infoProfileTopBarActionButtonsPadding.left(), + progressCurrent); + const auto buttonMostRight = anim::interpolate( + calculateRightButtonsWidth(), + st::infoProfileTopBarActionButtonsPadding.right(), + progressCurrent); + const auto maxWidth = width() - buttonMostLeft - buttonMostRight; + if (maxWidth > 0) { + _forumButton->setFullWidth(maxWidth); + } const auto buttonLeft = anim::interpolate( - statusMostLeft(), + mostLeft, (width() - _forumButton->width()) / 2, progressCurrent); _forumButton->moveToLeft(buttonLeft, buttonTop); diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index 24b778ba03..1714710c75 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -183,6 +183,7 @@ private: void updateStoryOutline(std::optional edgeColor); void paintStoryOutline(QPainter &p, const QRect &geometry); void updateStatusPosition(float64 progressCurrent); + [[nodiscard]] int calculateRightButtonsWidth() const; [[nodiscard]] const style::FlatLabel &statusStyle() const; void setupStatusWithRating(); [[nodiscard]] TopBarActionButtonStyle mapActionStyle(