mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved style of text from custom top bar in premium settings.
This commit is contained in:
parent
d2abcdacee
commit
8fbdd36ca0
2 changed files with 40 additions and 17 deletions
|
@ -449,3 +449,9 @@ settingsPremiumTopBarClose: IconButton(infoTopBarClose) {
|
||||||
}
|
}
|
||||||
settingsPremiumRowTitlePadding: margins(60px, 5px, 46px, 3px);
|
settingsPremiumRowTitlePadding: margins(60px, 5px, 46px, 3px);
|
||||||
settingsPremiumRowAboutPadding: margins(60px, 0px, 46px, 6px);
|
settingsPremiumRowAboutPadding: margins(60px, 0px, 46px, 6px);
|
||||||
|
|
||||||
|
settingsPremiumTitlePadding: margins(0px, 20px, 0px, 16px);
|
||||||
|
settingsPremiumAboutTextStyle: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(12px);
|
||||||
|
lineHeight: 18px;
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ using SectionCustomTopBarData = Info::Settings::SectionCustomTopBarData;
|
||||||
constexpr auto kBodyAnimationPart = 0.90;
|
constexpr auto kBodyAnimationPart = 0.90;
|
||||||
constexpr auto kTitleAnimationPart = 0.15;
|
constexpr auto kTitleAnimationPart = 0.15;
|
||||||
|
|
||||||
|
constexpr auto kTitleAdditionalScale = 0.15;
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
const style::icon *icon;
|
const style::icon *icon;
|
||||||
rpl::producer<QString> title;
|
rpl::producer<QString> title;
|
||||||
|
@ -230,8 +232,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Interval {
|
struct Interval {
|
||||||
int from;
|
int from = 0;
|
||||||
int length;
|
int length = 0;
|
||||||
};
|
};
|
||||||
const std::vector<Interval> _availableAngles;
|
const std::vector<Interval> _availableAngles;
|
||||||
const Interval _lifeLength;
|
const Interval _lifeLength;
|
||||||
|
@ -356,23 +358,33 @@ protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const style::font &_titleFont;
|
||||||
|
const style::margins &_titlePadding;
|
||||||
|
const style::TextStyle &_aboutSt;
|
||||||
MiniStars _ministars;
|
MiniStars _ministars;
|
||||||
QSvgRenderer _star;
|
QSvgRenderer _star;
|
||||||
Ui::Text::String _title;
|
|
||||||
Ui::Text::String _about;
|
Ui::Text::String _about;
|
||||||
|
|
||||||
QPoint _titlePosition;
|
QPoint _titlePosition;
|
||||||
|
QPainterPath _titlePath;
|
||||||
bool _roundEdges = true;
|
bool _roundEdges = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TopBar::TopBar(not_null<QWidget*> parent)
|
TopBar::TopBar(not_null<QWidget*> parent)
|
||||||
: Ui::RpWidget(parent)
|
: Ui::RpWidget(parent)
|
||||||
|
, _titleFont(st::boxTitle.style.font)
|
||||||
|
, _titlePadding(st::settingsPremiumTitlePadding)
|
||||||
|
, _aboutSt(st::settingsPremiumAboutTextStyle)
|
||||||
, _ministars([=] { update(); })
|
, _ministars([=] { update(); })
|
||||||
, _star(u":/gui/icons/settings/star.svg"_q)
|
, _star(u":/gui/icons/settings/star.svg"_q) {
|
||||||
, _title(st::boxTitle.style, tr::lng_premium_summary_title(tr::now)) {
|
_titlePath.addText(
|
||||||
|
0,
|
||||||
|
_titleFont->ascent,
|
||||||
|
_titleFont,
|
||||||
|
tr::lng_premium_summary_title(tr::now));
|
||||||
_about.setMarkedText(
|
_about.setMarkedText(
|
||||||
st::aboutLabel.style,
|
_aboutSt,
|
||||||
tr::lng_premium_summary_top_about(tr::now, Ui::Text::RichLangValue));
|
tr::lng_premium_summary_top_about(tr::now, Ui::Text::RichLangValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,30 +461,35 @@ void TopBar::paintEvent(QPaintEvent *e) {
|
||||||
const auto availableWidth = width() - padding.left() - padding.right();
|
const auto availableWidth = width() - padding.left() - padding.right();
|
||||||
const auto titleTop = currentStarRect.top()
|
const auto titleTop = currentStarRect.top()
|
||||||
+ currentStarRect.height()
|
+ currentStarRect.height()
|
||||||
+ st::changePhoneTitlePadding.top();
|
+ _titlePadding.top();
|
||||||
|
const auto titlePathRect = _titlePath.boundingRect();
|
||||||
const auto aboutTop = titleTop
|
const auto aboutTop = titleTop
|
||||||
+ _title.countHeight(availableWidth)
|
+ titlePathRect.height()
|
||||||
+ st::changePhoneTitlePadding.bottom();
|
+ _titlePadding.bottom();
|
||||||
|
|
||||||
p.setFont(st::aboutLabel.style.font);
|
p.setFont(_aboutSt.font);
|
||||||
_about.draw(p, padding.left(), aboutTop, availableWidth, style::al_top);
|
_about.draw(p, padding.left(), aboutTop, availableWidth, style::al_top);
|
||||||
|
|
||||||
// Title.
|
// Title.
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
p.setFont(st::boxTitle.style.font);
|
p.setFont(_titleFont);
|
||||||
const auto titleProgress = 1. - progress;
|
const auto titleProgress = 1. - progress;
|
||||||
const auto fullStarRect = starRect(1., 1.);
|
const auto fullStarRect = starRect(1., 1.);
|
||||||
const auto fullTitleTop = fullStarRect.top()
|
const auto fullTitleTop = fullStarRect.top()
|
||||||
+ fullStarRect.height()
|
+ fullStarRect.height()
|
||||||
+ st::changePhoneTitlePadding.top();
|
+ _titlePadding.top();
|
||||||
_title.draw(
|
p.translate(
|
||||||
p,
|
|
||||||
anim::interpolate(
|
anim::interpolate(
|
||||||
(width() - _title.countWidth(availableWidth)) / 2,
|
(width() - titlePathRect.width()) / 2,
|
||||||
_titlePosition.x(),
|
_titlePosition.x(),
|
||||||
titleProgress),
|
titleProgress),
|
||||||
anim::interpolate(fullTitleTop, _titlePosition.y(), titleProgress),
|
anim::interpolate(fullTitleTop, _titlePosition.y(), titleProgress));
|
||||||
availableWidth);
|
|
||||||
|
const auto scale = 1. + kTitleAdditionalScale * (1. - titleProgress);
|
||||||
|
p.translate(titlePathRect.center());
|
||||||
|
p.scale(scale, scale);
|
||||||
|
p.translate(-titlePathRect.center());
|
||||||
|
p.fillPath(_titlePath, st::premiumButtonFg);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Premium : public Section<Premium> {
|
class Premium : public Section<Premium> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue