Fixed lock from voice recording bar with transparent foreground.

This commit is contained in:
23rd 2022-06-13 08:48:31 +03:00
parent fc07954276
commit 15cce4900c

View file

@ -650,7 +650,7 @@ RecordLock::RecordLock(not_null<Ui::RpWidget*> parent)
st::historyRecordLockTopShadow.width()) st::historyRecordLockTopShadow.width())
.marginsRemoved(st::historyRecordLockRippleMargin)) .marginsRemoved(st::historyRecordLockRippleMargin))
, _arcPen( , _arcPen(
st::historyRecordLockIconFg, QColor(Qt::white),
st::historyRecordLockIconLineWidth, st::historyRecordLockIconLineWidth,
Qt::SolidLine, Qt::SolidLine,
Qt::SquareCap, Qt::SquareCap,
@ -758,7 +758,6 @@ void RecordLock::drawProgress(Painter &p) {
paintRipple(p, _rippleRect.x(), _rippleRect.y()); paintRipple(p, _rippleRect.x(), _rippleRect.y());
} }
{ {
PainterHighQualityEnabler hq(p);
const auto &arcOffset = st::historyRecordLockIconLineSkip; const auto &arcOffset = st::historyRecordLockIconLineSkip;
const auto &size = st::historyRecordLockIconSize; const auto &size = st::historyRecordLockIconSize;
@ -787,45 +786,70 @@ void RecordLock::drawProgress(Painter &p) {
blockRectHeight); blockRectHeight);
const auto &lineHeight = st::historyRecordLockIconLineHeight; const auto &lineHeight = st::historyRecordLockIconLineHeight;
p.setPen(Qt::NoPen); const auto lockTranslation = QPoint(
p.setBrush(st::historyRecordLockIconFg); (inner.width() - size.width()) / 2,
p.translate( (originTop.height() * 2 - size.height()) / 2);
inner.x() + (inner.width() - size.width()) / 2, const auto xRadius = anim::interpolate(2, 3, _lockToStopProgress);
inner.y() + (originTop.height() * 2 - size.height()) / 2);
{ if (_lockToStopProgress == 1.) {
const auto xRadius = anim::interpolate(2, 3, _lockToStopProgress); // Paint the block.
PainterHighQualityEnabler hq(p);
p.translate(inner.topLeft() + lockTranslation);
p.setPen(Qt::NoPen);
p.setBrush(st::historyRecordLockIconFg);
p.drawRoundedRect(blockRect, xRadius, 3); p.drawRoundedRect(blockRect, xRadius, 3);
} } else {
// Paint an animation frame.
auto frame = QImage(
inner.size() * style::DevicePixelRatio(),
QImage::Format_ARGB32_Premultiplied);
frame.setDevicePixelRatio(style::DevicePixelRatio());
frame.fill(Qt::transparent);
const auto offsetTranslate = _lockToStopProgress * Painter q(&frame);
(lineHeight + arcHeight + _arcPen.width() * 2); PainterHighQualityEnabler hq(q);
p.translate(
size.width() - arcOffset,
blockRect.y() + offsetTranslate);
if (progress < 1. && progress > 0.) { q.setPen(Qt::NoPen);
p.rotate(kLockArcAngle * progress); q.setBrush(_arcPen.brush());
}
p.setPen(_arcPen); q.translate(lockTranslation);
const auto rLine = QLineF(0, 0, 0, -lineHeight); q.drawRoundedRect(blockRect, xRadius, 3);
p.drawLine(rLine);
p.drawArc( const auto offsetTranslate = _lockToStopProgress *
-arcWidth, (lineHeight + arcHeight + _arcPen.width() * 2);
rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(), q.translate(
arcWidth, size.width() - arcOffset,
arcHeight * 2, blockRect.y() + offsetTranslate);
0,
180 * 16);
const auto lockProgress = 1. - _lockToStopProgress; if (progress < 1. && progress > 0.) {
if (progress == 1. && lockProgress < 1.) { q.rotate(kLockArcAngle * progress);
p.drawLine( }
q.setPen(_arcPen);
const auto rLine = QLineF(0, 0, 0, -lineHeight);
q.drawLine(rLine);
q.drawArc(
-arcWidth, -arcWidth,
rLine.y2(), rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(),
-arcWidth, arcWidth,
rLine.dy() * lockProgress); arcHeight * 2,
0,
180 * 16);
const auto lockProgress = 1. - _lockToStopProgress;
if (progress == 1. && lockProgress < 1.) {
q.drawLine(
-arcWidth,
rLine.y2(),
-arcWidth,
rLine.dy() * lockProgress);
}
q.end();
p.drawImage(
inner.topLeft(),
style::colorizeImage(frame, st::historyRecordLockIconFg));
} }
} }
} }