Added badge to header for owned sticker sets in stickers list.

This commit is contained in:
23rd 2024-07-31 13:05:29 +03:00
parent 6a167b33f5
commit 06f2b23687
5 changed files with 50 additions and 1 deletions

View file

@ -2935,6 +2935,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_stickers_context_delete_sure" = "Are you sure you want to delete the sticker from your sticker set?";
"lng_stickers_box_edit_name_title" = "Edit Sticker Set Name";
"lng_stickers_box_edit_name_about" = "Choose a name for your set.";
"lng_stickers_creator_badge" = "edit";
"lng_in_dlg_photo" = "Photo";
"lng_in_dlg_album" = "Album";

View file

@ -284,6 +284,10 @@ stickersTrendingSubheaderFont: normalFont;
stickersTrendingSubheaderFg: windowSubTextFg;
stickersTrendingSubheaderTop: 31px;
stickersHeaderBadgeFont: font(10px);
stickersHeaderBadgeFontTop: 12px;
stickersHeaderBadgeFontSkip: 12px;
emojiPanButtonRight: 7px;
emojiPanButtonTop: 8px;
emojiPanButton: RoundButton(defaultActiveButton) {

View file

@ -932,6 +932,9 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
if (sets.empty() && _section == Section::Search) {
paintEmptySearchResults(p);
}
const auto badgeText = tr::lng_stickers_creator_badge(tr::now);
const auto &badgeFont = st::stickersHeaderBadgeFont;
const auto badgeWidth = badgeFont->width(badgeText);
enumerateSections([&](const SectionInfo &info) {
if (clip.top() >= info.rowsBottom) {
return true;
@ -1050,6 +1053,12 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
widthForTitle -= remove.width();
}
const auto amCreator = (set.flags & Data::StickersSetFlag::AmCreator);
if (amCreator) {
widthForTitle -= badgeWidth
+ st::stickersFeaturedUnreadSkip
+ st::stickersHeaderBadgeFontSkip;
}
if (titleWidth > widthForTitle) {
titleText = st::stickersTrendingHeaderFont->elided(titleText, widthForTitle);
titleWidth = st::stickersTrendingHeaderFont->width(titleText);
@ -1057,6 +1066,39 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
p.setFont(st::emojiPanHeaderFont);
p.setPen(st().headerFg);
p.drawTextLeft(st().headerLeft - st().margin.left(), info.top + st().headerTop, width(), titleText, titleWidth);
if (amCreator) {
const auto badgeLeft = st().headerLeft
- st().margin.left()
+ titleWidth
+ st::stickersFeaturedUnreadSkip;
{
auto color = st().headerFg->c;
color.setAlphaF(st().headerFg->c.alphaF() * 0.15);
p.setPen(Qt::NoPen);
p.setBrush(color);
auto hq = PainterHighQualityEnabler(p);
p.drawRoundedRect(
style::rtlrect(
badgeLeft,
info.top + st::stickersHeaderBadgeFontTop,
badgeWidth + badgeFont->height,
badgeFont->height,
width()),
badgeFont->height / 2.,
badgeFont->height / 2.);
}
p.setPen(st().headerFg);
p.setBrush(Qt::NoBrush);
p.setFont(badgeFont);
p.drawText(
QRect(
badgeLeft + badgeFont->height / 2,
info.top + st::stickersHeaderBadgeFontTop,
badgeWidth,
badgeFont->height),
badgeText,
style::al_center);
}
}
if (clip.top() + clip.height() <= info.rowsTop) {
return true;

View file

@ -55,7 +55,8 @@ StickersSetFlags ParseStickersSetFlags(const MTPDstickerSet &data) {
| (data.vinstalled_date() ? Flag::Installed : Flag())
//| (data.is_videos() ? Flag::Webm : Flag())
| (data.is_text_color() ? Flag::TextColor : Flag())
| (data.is_channel_emoji_status() ? Flag::ChannelStatus : Flag());
| (data.is_channel_emoji_status() ? Flag::ChannelStatus : Flag())
| (data.is_creator() ? Flag::AmCreator : Flag());
}
StickersSet::StickersSet(

View file

@ -59,6 +59,7 @@ enum class StickersSetFlag : ushort {
Emoji = (1 << 9),
TextColor = (1 << 10),
ChannelStatus = (1 << 11),
AmCreator = (1 << 12),
};
inline constexpr bool is_flag_type(StickersSetFlag) { return true; };
using StickersSetFlags = base::flags<StickersSetFlag>;