mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Fixed lock from voice recording bar with transparent foreground.
This commit is contained in:
parent
fc07954276
commit
15cce4900c
1 changed files with 58 additions and 34 deletions
|
@ -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,31 +786,50 @@ void RecordLock::drawProgress(Painter &p) {
|
||||||
blockRectHeight);
|
blockRectHeight);
|
||||||
const auto &lineHeight = st::historyRecordLockIconLineHeight;
|
const auto &lineHeight = st::historyRecordLockIconLineHeight;
|
||||||
|
|
||||||
|
const auto lockTranslation = QPoint(
|
||||||
|
(inner.width() - size.width()) / 2,
|
||||||
|
(originTop.height() * 2 - size.height()) / 2);
|
||||||
|
const auto xRadius = anim::interpolate(2, 3, _lockToStopProgress);
|
||||||
|
|
||||||
|
if (_lockToStopProgress == 1.) {
|
||||||
|
// Paint the block.
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.translate(inner.topLeft() + lockTranslation);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::historyRecordLockIconFg);
|
p.setBrush(st::historyRecordLockIconFg);
|
||||||
p.translate(
|
|
||||||
inner.x() + (inner.width() - size.width()) / 2,
|
|
||||||
inner.y() + (originTop.height() * 2 - size.height()) / 2);
|
|
||||||
{
|
|
||||||
const auto xRadius = anim::interpolate(2, 3, _lockToStopProgress);
|
|
||||||
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);
|
||||||
|
|
||||||
|
Painter q(&frame);
|
||||||
|
PainterHighQualityEnabler hq(q);
|
||||||
|
|
||||||
|
q.setPen(Qt::NoPen);
|
||||||
|
q.setBrush(_arcPen.brush());
|
||||||
|
|
||||||
|
q.translate(lockTranslation);
|
||||||
|
q.drawRoundedRect(blockRect, xRadius, 3);
|
||||||
|
|
||||||
const auto offsetTranslate = _lockToStopProgress *
|
const auto offsetTranslate = _lockToStopProgress *
|
||||||
(lineHeight + arcHeight + _arcPen.width() * 2);
|
(lineHeight + arcHeight + _arcPen.width() * 2);
|
||||||
p.translate(
|
q.translate(
|
||||||
size.width() - arcOffset,
|
size.width() - arcOffset,
|
||||||
blockRect.y() + offsetTranslate);
|
blockRect.y() + offsetTranslate);
|
||||||
|
|
||||||
if (progress < 1. && progress > 0.) {
|
if (progress < 1. && progress > 0.) {
|
||||||
p.rotate(kLockArcAngle * progress);
|
q.rotate(kLockArcAngle * progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setPen(_arcPen);
|
q.setPen(_arcPen);
|
||||||
const auto rLine = QLineF(0, 0, 0, -lineHeight);
|
const auto rLine = QLineF(0, 0, 0, -lineHeight);
|
||||||
p.drawLine(rLine);
|
q.drawLine(rLine);
|
||||||
|
|
||||||
p.drawArc(
|
q.drawArc(
|
||||||
-arcWidth,
|
-arcWidth,
|
||||||
rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(),
|
rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(),
|
||||||
arcWidth,
|
arcWidth,
|
||||||
|
@ -821,12 +839,18 @@ void RecordLock::drawProgress(Painter &p) {
|
||||||
|
|
||||||
const auto lockProgress = 1. - _lockToStopProgress;
|
const auto lockProgress = 1. - _lockToStopProgress;
|
||||||
if (progress == 1. && lockProgress < 1.) {
|
if (progress == 1. && lockProgress < 1.) {
|
||||||
p.drawLine(
|
q.drawLine(
|
||||||
-arcWidth,
|
-arcWidth,
|
||||||
rLine.y2(),
|
rLine.y2(),
|
||||||
-arcWidth,
|
-arcWidth,
|
||||||
rLine.dy() * lockProgress);
|
rLine.dy() * lockProgress);
|
||||||
}
|
}
|
||||||
|
q.end();
|
||||||
|
|
||||||
|
p.drawImage(
|
||||||
|
inner.topLeft(),
|
||||||
|
style::colorizeImage(frame, st::historyRecordLockIconFg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue