mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 06:55:58 +00:00
Added support of lottie icon to premium top bar.
This commit is contained in:
@@ -42,7 +42,9 @@ MiniStars::MiniStars(
|
|||||||
, _appearProgressTill((type != Type::SlowStars) ? 0.2 : 0.01)
|
, _appearProgressTill((type != Type::SlowStars) ? 0.2 : 0.01)
|
||||||
, _disappearProgressAfter(0.8)
|
, _disappearProgressAfter(0.8)
|
||||||
, _distanceProgressStart(0.5)
|
, _distanceProgressStart(0.5)
|
||||||
, _sprite(u":/gui/icons/settings/starmini.svg"_q)
|
, _sprite((type == Type::DiamondStars)
|
||||||
|
? u":/gui/icons/settings/starmini.svg"_q
|
||||||
|
: u":/gui/icons/settings/star.svg"_q)
|
||||||
, _animation([=](crl::time now) {
|
, _animation([=](crl::time now) {
|
||||||
if (now > _nextBirthTime && !_paused) {
|
if (now > _nextBirthTime && !_paused) {
|
||||||
createStar(now);
|
createStar(now);
|
||||||
|
@@ -20,6 +20,7 @@ public:
|
|||||||
MonoStars,
|
MonoStars,
|
||||||
BiStars,
|
BiStars,
|
||||||
SlowStars,
|
SlowStars,
|
||||||
|
DiamondStars,
|
||||||
};
|
};
|
||||||
|
|
||||||
MiniStars(
|
MiniStars(
|
||||||
|
@@ -7,14 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#include "ui/effects/premium_top_bar.h"
|
#include "ui/effects/premium_top_bar.h"
|
||||||
|
|
||||||
|
#include "lottie/lottie_icon.h"
|
||||||
#include "ui/color_contrast.h"
|
#include "ui/color_contrast.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/wrap/fade_wrap.h"
|
#include "ui/wrap/fade_wrap.h"
|
||||||
|
#include "ui/rect.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_premium.h"
|
#include "styles/style_premium.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
namespace Ui::Premium {
|
namespace Ui::Premium {
|
||||||
namespace {
|
namespace {
|
||||||
@@ -109,7 +112,12 @@ TopBar::TopBar(
|
|||||||
, _titlePadding(st.titlePadding)
|
, _titlePadding(st.titlePadding)
|
||||||
, _aboutMaxWidth(st.aboutMaxWidth)
|
, _aboutMaxWidth(st.aboutMaxWidth)
|
||||||
, _about(this, std::move(descriptor.about), st.about)
|
, _about(this, std::move(descriptor.about), st.about)
|
||||||
, _ministars(this, descriptor.optimizeMinistars, MiniStars::Type::BiStars) {
|
, _ministars(
|
||||||
|
this,
|
||||||
|
descriptor.optimizeMinistars,
|
||||||
|
(_logo == u"diamond"_q)
|
||||||
|
? MiniStars::Type::DiamondStars
|
||||||
|
: MiniStars::Type::BiStars) {
|
||||||
std::move(
|
std::move(
|
||||||
descriptor.title
|
descriptor.title
|
||||||
) | rpl::start_with_next([=](QString text) {
|
) | rpl::start_with_next([=](QString text) {
|
||||||
@@ -132,7 +140,7 @@ TopBar::TopBar(
|
|||||||
|
|
||||||
rpl::single() | rpl::then(
|
rpl::single() | rpl::then(
|
||||||
style::PaletteChanged()
|
style::PaletteChanged()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=, starSize = st.starSize] {
|
||||||
TopBarAbstract::computeIsDark();
|
TopBarAbstract::computeIsDark();
|
||||||
|
|
||||||
if (_logo == u"dollar"_q) {
|
if (_logo == u"dollar"_q) {
|
||||||
@@ -142,6 +150,17 @@ TopBar::TopBar(
|
|||||||
} else if (_logo == u"affiliate"_q) {
|
} else if (_logo == u"affiliate"_q) {
|
||||||
_dollar = ScaleTo(QImage(u":/gui/art/affiliate_logo.png"_q));
|
_dollar = ScaleTo(QImage(u":/gui/art/affiliate_logo.png"_q));
|
||||||
_ministars.setColorOverride(descriptor.gradientStops);
|
_ministars.setColorOverride(descriptor.gradientStops);
|
||||||
|
} else if (_logo == u"diamond"_q) {
|
||||||
|
_lottie = Lottie::MakeIcon({
|
||||||
|
.name = u"diamond"_q,
|
||||||
|
.sizeOverride = starSize,
|
||||||
|
});
|
||||||
|
_lottie->animate(
|
||||||
|
[=] { update(_starRect.toRect() + Margins(st::lineWidth)); },
|
||||||
|
0,
|
||||||
|
_lottie->framesCount() - 1);
|
||||||
|
_ministars.setColorOverride(
|
||||||
|
QGradientStops{{ 0, st::windowActiveTextFg->c }});
|
||||||
} else if (!_light && !TopBarAbstract::isDark()) {
|
} else if (!_light && !TopBarAbstract::isDark()) {
|
||||||
_star.load(Svg());
|
_star.load(Svg());
|
||||||
_ministars.setColorOverride(
|
_ministars.setColorOverride(
|
||||||
@@ -247,8 +266,23 @@ void TopBar::paintEvent(QPaintEvent *e) {
|
|||||||
if (_progress.top) {
|
if (_progress.top) {
|
||||||
_ministars.paint(p);
|
_ministars.paint(p);
|
||||||
}
|
}
|
||||||
|
if (_lottie) {
|
||||||
|
_lottie->paint(
|
||||||
|
p,
|
||||||
|
_starRect.left()
|
||||||
|
+ (_starRect.width() - _lottie->width()) / 2
|
||||||
|
- st::lineWidth * 6,
|
||||||
|
_starRect.top());
|
||||||
|
if (!_lottie->animating() && _lottie->frameIndex() > 0) {
|
||||||
|
_lottie->animate(
|
||||||
|
[=] { update(_starRect.toRect() + Margins(st::lineWidth)); },
|
||||||
|
0,
|
||||||
|
_lottie->framesCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
p.resetTransform();
|
p.resetTransform();
|
||||||
|
|
||||||
|
|
||||||
if (!_dollar.isNull()) {
|
if (!_dollar.isNull()) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.drawImage(_starRect, _dollar);
|
p.drawImage(_starRect, _dollar);
|
||||||
|
@@ -23,6 +23,10 @@ namespace Ui {
|
|||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Lottie {
|
||||||
|
class Icon;
|
||||||
|
} // namespace Lottie
|
||||||
|
|
||||||
namespace Ui::Premium {
|
namespace Ui::Premium {
|
||||||
|
|
||||||
class TopBarAbstract : public RpWidget {
|
class TopBarAbstract : public RpWidget {
|
||||||
@@ -97,6 +101,7 @@ private:
|
|||||||
ColoredMiniStars _ministars;
|
ColoredMiniStars _ministars;
|
||||||
QSvgRenderer _star;
|
QSvgRenderer _star;
|
||||||
QImage _dollar;
|
QImage _dollar;
|
||||||
|
std::unique_ptr<Lottie::Icon> _lottie;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
float64 top = 0.;
|
float64 top = 0.;
|
||||||
|
Reference in New Issue
Block a user