feat: replace unread bar to pill

This commit is contained in:
bleizix 2025-08-16 02:45:23 +05:00
parent 61559a979a
commit be61316672

View file

@ -426,6 +426,9 @@ void UnreadBar::paint(
int y, int y,
int w, int w,
ElementChatMode mode) const { ElementChatMode mode) const {
// AyuGram changed:
// draw pills instead of full-width bar
if (AyuFeatures::MessageShot::isTakingShot()) { if (AyuFeatures::MessageShot::isTakingShot()) {
return; return;
} }
@ -434,22 +437,23 @@ void UnreadBar::paint(
p.translate(-previousTranslation, 0); p.translate(-previousTranslation, 0);
} }
const auto st = context.st; const auto st = context.st;
const auto bottom = y + height(); // const auto bottom = y + height();
y += marginTop(); // y += marginTop();
p.fillRect( // p.fillRect(
0, // 0,
y, // y,
w, // w,
height() - marginTop() - st::lineWidth, // height() - marginTop() - st::lineWidth,
st->historyUnreadBarBg()); // st->historyUnreadBarBg());
p.fillRect( // p.fillRect(
0, // 0,
bottom - st::lineWidth, // bottom - st::lineWidth,
w, // w,
st::lineWidth, // st::lineWidth,
st->historyUnreadBarBorder()); // st->historyUnreadBarBorder());
p.setFont(st::historyUnreadBarFont); p.setFont(st::historyUnreadBarFont);
p.setPen(st->historyUnreadBarFg()); p.setPen(st->historyUnreadBarFg());
p.setRenderHint(QPainter::Antialiasing);
int maxwidth = w; int maxwidth = w;
if (mode == ElementChatMode::Wide) { if (mode == ElementChatMode::Wide) {
@ -461,13 +465,29 @@ void UnreadBar::paint(
} }
w = maxwidth; w = maxwidth;
const auto skip = st::historyUnreadBarHeight constexpr auto padding = 20;
- 2 * st::lineWidth
- st::historyUnreadBarFont->height; // `width` - width of the text
p.drawText( const auto pillWidth = width + 2 * padding;
(w - width) / 2, const auto pillHeight = height() - marginTop();
y + (skip / 2) + st::historyUnreadBarFont->ascent, const auto pillX = (w - pillWidth) / 2;
text); const auto pillY = y + marginTop();
QPainterPath path;
path.addRoundedRect(pillX,
pillY,
pillWidth,
pillHeight,
static_cast<double>(pillHeight) / 2,
static_cast<double>(pillHeight) / 2);
p.fillPath(path, st->historyUnreadBarBg());
const auto textY = pillY
+ (pillHeight - st::historyUnreadBarFont->height) / 2
+ st::historyUnreadBarFont->ascent;
p.drawText((w - width) / 2, textY, text);
if (previousTranslation != 0) { if (previousTranslation != 0) {
p.translate(previousTranslation, 0); p.translate(previousTranslation, 0);
} }