Files
AyuGramDesktop/Telegram/SourceFiles/dialogs/ui/dialogs_pill.cpp
T
2026-07-02 17:49:01 +04:00

35 lines
1.0 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/ui/dialogs_pill.h"
#include "ui/painter.h"
#include "styles/style_dialogs.h"
namespace Dialogs {
void PaintPillTopSheen(QPainter &p, const QRect &pill, int radius) {
if (pill.isEmpty() || st::dialogsBg->c.lightness() >= 128) {
return;
}
auto top = QColor(255, 255, 255, 40);
auto mid = QColor(255, 255, 255, 0);
auto bottom = QColor(255, 255, 255, 20);
auto grad = QLinearGradient(0, pill.top(), 0, pill.bottom());
grad.setColorAt(0., top);
grad.setColorAt(0.5, mid);
grad.setColorAt(1., bottom);
p.setPen(QPen(QBrush(grad), st::lineWidth));
p.setBrush(Qt::NoBrush);
const auto half = 0.5 * st::lineWidth;
const auto stroke = QRectF(pill).adjusted(half, half, -half, -half);
p.drawRoundedRect(stroke, radius - half, radius - half);
}
} // namespace Dialogs