Added creator badge to headers of owned custom emoji sets.

This commit is contained in:
23rd
2026-04-22 12:34:58 +03:00
parent 1fc7a6de95
commit 4c6f774553
@@ -1847,6 +1847,9 @@ void EmojiListWidget::paint(
&& !_searchRequestTimer.isActive()) { && !_searchRequestTimer.isActive()) {
paintEmptySearchResults(p); 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) { enumerateSections([&](const SectionInfo &info) {
if (clip.top() >= info.rowsBottom) { if (clip.top() >= info.rowsBottom) {
return true; return true;
@@ -1859,7 +1862,7 @@ void EmojiListWidget::paint(
const auto titleLeft = (info.premiumRequired const auto titleLeft = (info.premiumRequired
? st().headerLockedLeft ? st().headerLockedLeft
: st().headerLeft) - st().margin.left(); : st().headerLeft) - st().margin.left();
const auto widthForTitle = emojiRight() auto widthForTitle = emojiRight()
- titleLeft - titleLeft
- paintButtonGetWidth(p, info, buttonSelected, clip); - paintButtonGetWidth(p, info, buttonSelected, clip);
if (info.section > 0 && clip.top() < info.rowsTop) { if (info.section > 0 && clip.top() < info.rowsTop) {
@@ -1870,6 +1873,18 @@ void EmojiListWidget::paint(
: (info.section < _staticCount) : (info.section < _staticCount)
? ChatHelpers::EmojiCategoryTitle(info.section)(tr::now) ? ChatHelpers::EmojiCategoryTitle(info.section)(tr::now)
: _custom[info.section - _staticCount].title; : _custom[info.section - _staticCount].title;
const auto titleSet = (_searchMode && info.section > 0)
? searchSetBySection(info.section).set.get()
: (info.section >= _staticCount)
? _custom[info.section - _staticCount].set.get()
: nullptr;
const auto amCreator = titleSet
&& (titleSet->flags & Data::StickersSetFlag::AmCreator);
if (amCreator) {
widthForTitle -= badgeWidth
+ st::stickersFeaturedUnreadSkip
+ st::stickersHeaderBadgeFontSkip;
}
auto titleWidth = st::emojiPanHeaderFont->width(titleText); auto titleWidth = st::emojiPanHeaderFont->width(titleText);
if (titleWidth > widthForTitle) { if (titleWidth > widthForTitle) {
titleText = st::emojiPanHeaderFont->elided(titleText, widthForTitle); titleText = st::emojiPanHeaderFont->elided(titleText, widthForTitle);
@@ -1887,6 +1902,38 @@ void EmojiListWidget::paint(
p.setFont(st::emojiPanHeaderFont); p.setFont(st::emojiPanHeaderFont);
p.setPen(st().headerFg); p.setPen(st().headerFg);
p.drawText(titleLeft, textBaseline, titleText); p.drawText(titleLeft, textBaseline, titleText);
if (amCreator) {
const auto badgeLeft = titleLeft
+ 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) { if (clip.top() + clip.height() > info.rowsTop) {
ensureLoaded(info.section); ensureLoaded(info.section);