Add premium sticker packs icon.

This commit is contained in:
John Preston 2022-05-19 17:25:59 +04:00
parent 22613fc204
commit b02a965778
12 changed files with 43 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 765 B

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 936 B

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -94,9 +94,9 @@ stickersTrendingUnread: icon {
{ "emoji/stickers_add_unread", emojiIconFg }, { "emoji/stickers_add_unread", emojiIconFg },
{ "emoji/stickers_add_dot", dialogsUnreadBg } { "emoji/stickers_add_dot", dialogsUnreadBg }
}; };
stickersRecent: icon {{ "emoji/stickers_recent", emojiIconFg }}; stickersRecent: icon {{ "emoji/emoji_recent", emojiIconFg }};
stickersSearch: icon {{ "emoji/stickers_search", emojiIconFg }}; stickersSearch: icon {{ "emoji/stickers_search", emojiIconFg }};
stickersPremium: icon {{ "emoji/stickers_search", emojiIconFg }}; stickersPremium: icon {{ "emoji/stickers_premium", emojiIconFg }};
stickersSettingsUnreadSize: 6px; stickersSettingsUnreadSize: 6px;
stickersSettingsUnreadPosition: point(6px, 10px); stickersSettingsUnreadPosition: point(6px, 10px);

View file

@ -184,6 +184,7 @@ private:
bool paused) const; bool paused) const;
void paintSelectionBar(Painter &p) const; void paintSelectionBar(Painter &p) const;
void paintLeftRightFading(Painter &p) const; void paintLeftRightFading(Painter &p) const;
void validatePremiumIcon() const;
void initSearch(); void initSearch();
void toggleSearch(bool visible); void toggleSearch(bool visible);
@ -204,6 +205,7 @@ private:
bool _iconsDragging = false; bool _iconsDragging = false;
Ui::Animations::Basic _iconsAnimation; Ui::Animations::Basic _iconsAnimation;
QPoint _iconsMousePos, _iconsMouseDown; QPoint _iconsMousePos, _iconsMouseDown;
mutable QImage _premiumIcon;
int _iconsLeft = 0; int _iconsLeft = 0;
int _iconsRight = 0; int _iconsRight = 0;
int _iconsTop = 0; int _iconsTop = 0;
@ -327,6 +329,36 @@ StickersListWidget::Footer::Footer(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
update(); update();
}, lifetime()); }, lifetime());
style::PaletteChanged(
) | rpl::start_with_next([=] {
_premiumIcon = QImage();
}, lifetime());
}
void StickersListWidget::Footer::validatePremiumIcon() const {
if (!_premiumIcon.isNull()) {
return;
}
const auto size = st::stickersPremium.size();
const auto mask = st::stickersPremium.instance(Qt::white);
const auto factor = style::DevicePixelRatio();
_premiumIcon = QImage(
size * factor,
QImage::Format_ARGB32_Premultiplied);
_premiumIcon.setDevicePixelRatio(factor);
QPainter p(&_premiumIcon);
auto gradient = QLinearGradient(
QPoint(0, size.height()),
QPoint(size.width(), 0));
gradient.setStops({
{ 0., st::stickerPanPremium1->c },
{ 1., st::stickerPanPremium2->c },
});
p.fillRect(QRect(QPoint(), size), gradient);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.drawImage(QRect(QPoint(), size), mask);
} }
void StickersListWidget::Footer::clearHeavyData() { void StickersListWidget::Footer::clearHeavyData() {
@ -1037,6 +1069,13 @@ void StickersListWidget::Footer::paintSetIcon(
_iconsTop + (st::emojiFooterHeight - size) / 2, _iconsTop + (st::emojiFooterHeight - size) / 2,
width(), width(),
st::stickerGroupCategorySize); st::stickerGroupCategorySize);
} else if (icon.setId == Data::Stickers::PremiumSetId) {
validatePremiumIcon();
const auto size = st::stickersPremium.size();
p.drawImage(
info.left + (st::stickerIconWidth - size.width()) / 2,
_iconsTop + (st::emojiFooterHeight - size.height()) / 2,
_premiumIcon);
} else { } else {
const auto paintedIcon = [&] { const auto paintedIcon = [&] {
if (icon.setId == Data::Stickers::FeaturedSetId) { if (icon.setId == Data::Stickers::FeaturedSetId) {
@ -1044,12 +1083,10 @@ void StickersListWidget::Footer::paintSetIcon(
return session->data().stickers().featuredSetsUnreadCount() return session->data().stickers().featuredSetsUnreadCount()
? &st::stickersTrendingUnread ? &st::stickersTrendingUnread
: &st::stickersTrending; : &st::stickersTrending;
} else if (icon.setId == Data::Stickers::PremiumSetId) {
return &st::stickersPremium;
//} else if (setId == Stickers::FavedSetId) { //} else if (setId == Stickers::FavedSetId) {
// return &st::stickersFaved; // return &st::stickersFaved;
} }
return &st::stickersRecent; return &st::emojiRecent;
}(); }();
paintedIcon->paint( paintedIcon->paint(
p, p,

@ -1 +1 @@
Subproject commit 21a7adc03c0bb256b1dac8281fe1ca76c4296aa7 Subproject commit 9c09b1fad07d5048b55a1dfcb27c7d1a585bba55