Fixed drawing of ttl circles with non-default scale.

This commit is contained in:
23rd 2024-01-04 13:22:20 +03:00
parent 69f8cb5951
commit 098e797045
3 changed files with 26 additions and 12 deletions

View file

@ -86,7 +86,7 @@ constexpr auto kBlurRadius = 24;
q.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
q.setClipRect(innerRect
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
- QMargins(innerRect.width() / 2, -penWidth, -penWidth, -penWidth));
pen.setStyle(Qt::DotLine);
q.setPen(pen);
q.drawEllipse(innerRect);

View file

@ -312,7 +312,8 @@ TTLButton::TTLButton(
Ui::RippleButton::paintRipple(p, _rippleRect.x(), _rippleRect.y());
const auto innerRect = inner - st::historyRecordLockMargin * 2;
const auto innerRect = QRectF(inner)
- st::historyRecordLockMargin * 2;
auto hq = PainterHighQualityEnabler(p);
p.setFont(st::semiboldFont);
@ -331,7 +332,11 @@ TTLButton::TTLButton(
{
p.setClipRect(innerRect
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
- QMarginsF(
innerRect.width() / 2,
-penWidth,
-penWidth,
-penWidth));
pen.setStyle(Qt::DotLine);
p.setPen(pen);
p.drawEllipse(innerRect);

View file

@ -53,30 +53,36 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
void DrawCornerBadgeTTL(
QPainter &p,
const style::color &color,
const style::color &bg,
const style::color &fg,
const QRect &circleRect) {
p.save();
const auto partRect = QRect(
circleRect.left() + circleRect.width() - st::dialogsTTLBadgeSize * 0.85,
circleRect.top() + circleRect.height() - st::dialogsTTLBadgeSize * 0.85,
const auto partRect = QRectF(
rect::right(circleRect)
- st::dialogsTTLBadgeSize
+ rect::m::sum::h(st::dialogsTTLBadgeInnerMargins),
rect::bottom(circleRect)
- st::dialogsTTLBadgeSize
+ rect::m::sum::v(st::dialogsTTLBadgeInnerMargins),
st::dialogsTTLBadgeSize,
st::dialogsTTLBadgeSize);
auto hq = PainterHighQualityEnabler(p);
p.setBrush(color);
p.setPen(Qt::NoPen);
p.setBrush(bg);
p.drawEllipse(partRect);
const auto innerRect = partRect - st::dialogsTTLBadgeInnerMargins;
const auto ttlText = u"1"_q;
p.setFont(st::dialogsScamFont);
p.setPen(st::premiumButtonFg);
p.setPen(fg);
p.drawText(innerRect, ttlText, style::al_center);
constexpr auto kPenWidth = 1.5;
const auto penWidth = style::ConvertScaleExact(kPenWidth);
auto pen = QPen(st::premiumButtonFg);
auto pen = QPen(fg);
pen.setJoinStyle(Qt::RoundJoin);
pen.setCapStyle(Qt::RoundCap);
pen.setWidthF(penWidth);
@ -86,7 +92,7 @@ void DrawCornerBadgeTTL(
p.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
p.setClipRect(innerRect
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
- QMarginsF(innerRect.width() / 2, -penWidth, -penWidth, -penWidth));
pen.setStyle(Qt::DotLine);
p.setPen(pen);
p.drawEllipse(innerRect);
@ -895,7 +901,10 @@ void Document::draw(
});
}
if (_parent->data()->media()->ttlSeconds()) {
DrawCornerBadgeTTL(p, stm->msgFileBg, inner);
const auto &fg = context.outbg
? st::historyFileOutIconFg
: st::historyFileInIconFg;
DrawCornerBadgeTTL(p, stm->msgFileBg, fg, inner);
}
}