mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed drawing of ttl circles with non-default scale.
This commit is contained in:
parent
69f8cb5951
commit
098e797045
3 changed files with 26 additions and 12 deletions
|
@ -86,7 +86,7 @@ constexpr auto kBlurRadius = 24;
|
||||||
q.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
q.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
||||||
|
|
||||||
q.setClipRect(innerRect
|
q.setClipRect(innerRect
|
||||||
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
|
- QMargins(innerRect.width() / 2, -penWidth, -penWidth, -penWidth));
|
||||||
pen.setStyle(Qt::DotLine);
|
pen.setStyle(Qt::DotLine);
|
||||||
q.setPen(pen);
|
q.setPen(pen);
|
||||||
q.drawEllipse(innerRect);
|
q.drawEllipse(innerRect);
|
||||||
|
|
|
@ -312,7 +312,8 @@ TTLButton::TTLButton(
|
||||||
|
|
||||||
Ui::RippleButton::paintRipple(p, _rippleRect.x(), _rippleRect.y());
|
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);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
|
|
||||||
p.setFont(st::semiboldFont);
|
p.setFont(st::semiboldFont);
|
||||||
|
@ -331,7 +332,11 @@ TTLButton::TTLButton(
|
||||||
|
|
||||||
{
|
{
|
||||||
p.setClipRect(innerRect
|
p.setClipRect(innerRect
|
||||||
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
|
- QMarginsF(
|
||||||
|
innerRect.width() / 2,
|
||||||
|
-penWidth,
|
||||||
|
-penWidth,
|
||||||
|
-penWidth));
|
||||||
pen.setStyle(Qt::DotLine);
|
pen.setStyle(Qt::DotLine);
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
p.drawEllipse(innerRect);
|
p.drawEllipse(innerRect);
|
||||||
|
|
|
@ -53,30 +53,36 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
|
||||||
|
|
||||||
void DrawCornerBadgeTTL(
|
void DrawCornerBadgeTTL(
|
||||||
QPainter &p,
|
QPainter &p,
|
||||||
const style::color &color,
|
const style::color &bg,
|
||||||
|
const style::color &fg,
|
||||||
const QRect &circleRect) {
|
const QRect &circleRect) {
|
||||||
p.save();
|
p.save();
|
||||||
const auto partRect = QRect(
|
const auto partRect = QRectF(
|
||||||
circleRect.left() + circleRect.width() - st::dialogsTTLBadgeSize * 0.85,
|
rect::right(circleRect)
|
||||||
circleRect.top() + circleRect.height() - st::dialogsTTLBadgeSize * 0.85,
|
- st::dialogsTTLBadgeSize
|
||||||
|
+ rect::m::sum::h(st::dialogsTTLBadgeInnerMargins),
|
||||||
|
rect::bottom(circleRect)
|
||||||
|
- st::dialogsTTLBadgeSize
|
||||||
|
+ rect::m::sum::v(st::dialogsTTLBadgeInnerMargins),
|
||||||
st::dialogsTTLBadgeSize,
|
st::dialogsTTLBadgeSize,
|
||||||
st::dialogsTTLBadgeSize);
|
st::dialogsTTLBadgeSize);
|
||||||
|
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setBrush(color);
|
p.setPen(Qt::NoPen);
|
||||||
|
p.setBrush(bg);
|
||||||
p.drawEllipse(partRect);
|
p.drawEllipse(partRect);
|
||||||
|
|
||||||
const auto innerRect = partRect - st::dialogsTTLBadgeInnerMargins;
|
const auto innerRect = partRect - st::dialogsTTLBadgeInnerMargins;
|
||||||
const auto ttlText = u"1"_q;
|
const auto ttlText = u"1"_q;
|
||||||
|
|
||||||
p.setFont(st::dialogsScamFont);
|
p.setFont(st::dialogsScamFont);
|
||||||
p.setPen(st::premiumButtonFg);
|
p.setPen(fg);
|
||||||
p.drawText(innerRect, ttlText, style::al_center);
|
p.drawText(innerRect, ttlText, style::al_center);
|
||||||
|
|
||||||
constexpr auto kPenWidth = 1.5;
|
constexpr auto kPenWidth = 1.5;
|
||||||
|
|
||||||
const auto penWidth = style::ConvertScaleExact(kPenWidth);
|
const auto penWidth = style::ConvertScaleExact(kPenWidth);
|
||||||
auto pen = QPen(st::premiumButtonFg);
|
auto pen = QPen(fg);
|
||||||
pen.setJoinStyle(Qt::RoundJoin);
|
pen.setJoinStyle(Qt::RoundJoin);
|
||||||
pen.setCapStyle(Qt::RoundCap);
|
pen.setCapStyle(Qt::RoundCap);
|
||||||
pen.setWidthF(penWidth);
|
pen.setWidthF(penWidth);
|
||||||
|
@ -86,7 +92,7 @@ void DrawCornerBadgeTTL(
|
||||||
p.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
p.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
||||||
|
|
||||||
p.setClipRect(innerRect
|
p.setClipRect(innerRect
|
||||||
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
|
- QMarginsF(innerRect.width() / 2, -penWidth, -penWidth, -penWidth));
|
||||||
pen.setStyle(Qt::DotLine);
|
pen.setStyle(Qt::DotLine);
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
p.drawEllipse(innerRect);
|
p.drawEllipse(innerRect);
|
||||||
|
@ -895,7 +901,10 @@ void Document::draw(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_parent->data()->media()->ttlSeconds()) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue