Fixed width of very long go-to-forum button in profile top bar.

This commit is contained in:
23rd
2025-11-19 11:29:39 +03:00
committed by John Preston
parent 5054d0615e
commit f1fe5f6a71
2 changed files with 27 additions and 8 deletions
@@ -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);
@@ -183,6 +183,7 @@ private:
void updateStoryOutline(std::optional<QColor> 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(