mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-21 05:02:50 +02:00
Added support of lottie icon to premium top bar.
This commit is contained in:
parent
8f7a66a21a
commit
70d3061d59
4 changed files with 45 additions and 3 deletions
|
@ -42,7 +42,9 @@ MiniStars::MiniStars(
|
|||
, _appearProgressTill((type != Type::SlowStars) ? 0.2 : 0.01)
|
||||
, _disappearProgressAfter(0.8)
|
||||
, _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) {
|
||||
if (now > _nextBirthTime && !_paused) {
|
||||
createStar(now);
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
MonoStars,
|
||||
BiStars,
|
||||
SlowStars,
|
||||
DiamondStars,
|
||||
};
|
||||
|
||||
MiniStars(
|
||||
|
|
|
@ -7,14 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "ui/effects/premium_top_bar.h"
|
||||
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "ui/color_contrast.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/rect.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_premium.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace Ui::Premium {
|
||||
namespace {
|
||||
|
@ -109,7 +112,12 @@ TopBar::TopBar(
|
|||
, _titlePadding(st.titlePadding)
|
||||
, _aboutMaxWidth(st.aboutMaxWidth)
|
||||
, _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(
|
||||
descriptor.title
|
||||
) | rpl::start_with_next([=](QString text) {
|
||||
|
@ -132,7 +140,7 @@ TopBar::TopBar(
|
|||
|
||||
rpl::single() | rpl::then(
|
||||
style::PaletteChanged()
|
||||
) | rpl::start_with_next([=] {
|
||||
) | rpl::start_with_next([=, starSize = st.starSize] {
|
||||
TopBarAbstract::computeIsDark();
|
||||
|
||||
if (_logo == u"dollar"_q) {
|
||||
|
@ -142,6 +150,17 @@ TopBar::TopBar(
|
|||
} else if (_logo == u"affiliate"_q) {
|
||||
_dollar = ScaleTo(QImage(u":/gui/art/affiliate_logo.png"_q));
|
||||
_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()) {
|
||||
_star.load(Svg());
|
||||
_ministars.setColorOverride(
|
||||
|
@ -247,8 +266,23 @@ void TopBar::paintEvent(QPaintEvent *e) {
|
|||
if (_progress.top) {
|
||||
_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();
|
||||
|
||||
|
||||
if (!_dollar.isNull()) {
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.drawImage(_starRect, _dollar);
|
||||
|
|
|
@ -23,6 +23,10 @@ namespace Ui {
|
|||
class FlatLabel;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Lottie {
|
||||
class Icon;
|
||||
} // namespace Lottie
|
||||
|
||||
namespace Ui::Premium {
|
||||
|
||||
class TopBarAbstract : public RpWidget {
|
||||
|
@ -97,6 +101,7 @@ private:
|
|||
ColoredMiniStars _ministars;
|
||||
QSvgRenderer _star;
|
||||
QImage _dollar;
|
||||
std::unique_ptr<Lottie::Icon> _lottie;
|
||||
|
||||
struct {
|
||||
float64 top = 0.;
|
||||
|
|
Loading…
Add table
Reference in a new issue