Slightly improved animation of top bar in premium settings.

This commit is contained in:
23rd 2022-05-24 07:02:32 +03:00
parent ee9a04393e
commit a73676b3ba
1 changed files with 26 additions and 26 deletions

View File

@ -270,20 +270,23 @@ void TopBar::paintEvent(QPaintEvent *e) {
p.setOpacity(bodyProgress); p.setOpacity(bodyProgress);
const auto &starSize = st::settingsPremiumStarSize; const auto starRect = [&](float64 topProgress, float64 sizeProgress) {
const auto starRect = QRectF( const auto starSize = st::settingsPremiumStarSize * sizeProgress;
QPointF( return QRectF(
(width() - starSize.width()) / 2, QPointF(
st::settingsPremiumStarTopSkip * topProgress), (width() - starSize.width()) / 2,
st::settingsPremiumStarSize); st::settingsPremiumStarTopSkip * topProgress),
_star.render(&p, starRect); starSize);
};
const auto currentStarRect = starRect(topProgress, bodyProgress);
_star.render(&p, currentStarRect);
p.setPen(st::premiumButtonFg); p.setPen(st::premiumButtonFg);
const auto &padding = st::boxRowPadding; const auto &padding = st::boxRowPadding;
const auto availableWidth = width() - padding.left() - padding.right(); const auto availableWidth = width() - padding.left() - padding.right();
const auto titleTop = starRect.top() const auto titleTop = currentStarRect.top()
+ starRect.height() + currentStarRect.height()
+ st::changePhoneTitlePadding.top(); + st::changePhoneTitlePadding.top();
const auto aboutTop = titleTop const auto aboutTop = titleTop
+ _title.countHeight(availableWidth) + _title.countHeight(availableWidth)
@ -292,25 +295,22 @@ void TopBar::paintEvent(QPaintEvent *e) {
p.setFont(st::aboutLabel.style.font); p.setFont(st::aboutLabel.style.font);
_about.draw(p, padding.left(), aboutTop, availableWidth, style::al_top); _about.draw(p, padding.left(), aboutTop, availableWidth, style::al_top);
// Subtitle.
p.setFont(st::boxTitle.style.font);
_title.draw(p, padding.left(), titleTop, availableWidth, style::al_top);
// Title. // Title.
const auto titleProgress = p.setOpacity(1.);
std::clamp( p.setFont(st::boxTitle.style.font);
(kTitleAnimationPart - progress) / kTitleAnimationPart, const auto titleProgress = 1. - progress;
0., const auto fullStarRect = starRect(1., 1.);
1.); const auto fullTitleTop = fullStarRect.top()
if (titleProgress > 0.) { + fullStarRect.height()
p.setOpacity(titleProgress); + st::changePhoneTitlePadding.top();
const auto availableWidth = width() - _titlePosition.x() * 2; _title.draw(
_title.drawElided( p,
p, anim::interpolate(
(width() - _title.countWidth(availableWidth)) / 2,
_titlePosition.x(), _titlePosition.x(),
_titlePosition.y(), titleProgress),
availableWidth); anim::interpolate(fullTitleTop, _titlePosition.y(), titleProgress),
} availableWidth);
} }
class Premium : public Section<Premium> { class Premium : public Section<Premium> {