mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added badge corner to voice messages with ttl.
This commit is contained in:
parent
22f68b430d
commit
d2565dc944
1 changed files with 48 additions and 0 deletions
|
@ -44,12 +44,56 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_transcribes.h"
|
||||
#include "apiwrap.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
|
||||
|
||||
void DrawCornerBadgeTTL(
|
||||
QPainter &p,
|
||||
const style::color &color,
|
||||
const QRect &circleRect) {
|
||||
p.save();
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto partRect = QRect(
|
||||
circleRect.left() + circleRect.width() - st::dialogsTTLBadgeSize * 0.85,
|
||||
circleRect.top() + circleRect.height() - st::dialogsTTLBadgeSize * 0.85,
|
||||
st::dialogsTTLBadgeSize,
|
||||
st::dialogsTTLBadgeSize);
|
||||
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setBrush(color);
|
||||
p.drawEllipse(partRect);
|
||||
|
||||
const auto innerRect = partRect - st::dialogsTTLBadgeInnerMargins;
|
||||
const auto ttlText = u"1"_q;
|
||||
|
||||
p.setFont(st::dialogsScamFont);
|
||||
p.setPen(st::premiumButtonFg);
|
||||
p.drawText(innerRect, ttlText, style::al_center);
|
||||
|
||||
constexpr auto kPenWidth = 1.5;
|
||||
|
||||
const auto penWidth = style::ConvertScaleExact(kPenWidth);
|
||||
auto pen = QPen(st::premiumButtonFg);
|
||||
pen.setJoinStyle(Qt::RoundJoin);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
pen.setWidthF(penWidth);
|
||||
|
||||
p.setPen(pen);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
||||
|
||||
p.setClipRect(innerRect
|
||||
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
|
||||
pen.setStyle(Qt::DotLine);
|
||||
p.setPen(pen);
|
||||
p.drawEllipse(innerRect);
|
||||
p.restore();
|
||||
}
|
||||
|
||||
[[nodiscard]] HistoryView::TtlPaintCallback CreateTtlPaintCallback(
|
||||
std::shared_ptr<rpl::lifetime> lifetime,
|
||||
Fn<void()> update) {
|
||||
|
@ -675,6 +719,10 @@ void Document::draw(
|
|||
PainterHighQualityEnabler hq(p);
|
||||
p.setBrush(stm->msgFileBg);
|
||||
p.drawEllipse(inner);
|
||||
|
||||
if (_parent->data()->media()->ttlSeconds()) {
|
||||
DrawCornerBadgeTTL(p, stm->msgFileBg, inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue