mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added transform animation from lock to stop icon for recording voice.
This commit is contained in:
parent
c9314e5e5e
commit
92298316ab
2 changed files with 38 additions and 10 deletions
|
@ -61,6 +61,10 @@ enum class FilterType {
|
||||||
Cancel,
|
Cancel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline float64 InterpolateF(int a, int b, float64 b_ratio) {
|
||||||
|
return a + float64(b - a) * b_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto InactiveColor(const QColor &c) {
|
[[nodiscard]] auto InactiveColor(const QColor &c) {
|
||||||
return QColor(c.red(), c.green(), c.blue(), kInactiveWaveformBarAlpha);
|
return QColor(c.red(), c.green(), c.blue(), kInactiveWaveformBarAlpha);
|
||||||
}
|
}
|
||||||
|
@ -772,26 +776,51 @@ void RecordLock::drawProgress(Painter &p) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
|
const auto lockToStopProgress =
|
||||||
|
_lockAnimation.value(isLocked() ? 1. : 0);
|
||||||
|
const auto &arcOffset = st::historyRecordLockIconLineSkip;
|
||||||
const auto &size = st::historyRecordLockIconSize;
|
const auto &size = st::historyRecordLockIconSize;
|
||||||
|
|
||||||
|
const auto arcWidth = size.width() - arcOffset * 2;
|
||||||
|
const auto &arcHeight = st::historyRecordLockIconArcHeight;
|
||||||
|
|
||||||
const auto &blockHeight = st::historyRecordLockIconBottomHeight;
|
const auto &blockHeight = st::historyRecordLockIconBottomHeight;
|
||||||
const auto blockRect = QRect(
|
|
||||||
0,
|
const auto blockRectWidth = InterpolateF(
|
||||||
size.height() - blockHeight,
|
|
||||||
size.width(),
|
size.width(),
|
||||||
blockHeight);
|
st::historyRecordStopIconWidth,
|
||||||
|
lockToStopProgress);
|
||||||
|
const auto blockRectHeight = InterpolateF(
|
||||||
|
blockHeight,
|
||||||
|
st::historyRecordStopIconWidth,
|
||||||
|
lockToStopProgress);
|
||||||
|
const auto blockRectTop = InterpolateF(
|
||||||
|
size.height() - blockHeight,
|
||||||
|
std::round((size.height() - blockRectHeight) / 2.),
|
||||||
|
lockToStopProgress);
|
||||||
|
|
||||||
|
const auto blockRect = QRectF(
|
||||||
|
(size.width() - blockRectWidth) / 2,
|
||||||
|
blockRectTop,
|
||||||
|
blockRectWidth,
|
||||||
|
blockRectHeight);
|
||||||
const auto &lineHeight = st::historyRecordLockIconLineHeight;
|
const auto &lineHeight = st::historyRecordLockIconLineHeight;
|
||||||
const auto &offset = st::historyRecordLockIconLineSkip;
|
|
||||||
|
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::historyRecordLockIconFg);
|
p.setBrush(st::historyRecordLockIconFg);
|
||||||
p.translate(
|
p.translate(
|
||||||
inner.x() + (inner.width() - size.width()) / 2,
|
inner.x() + (inner.width() - size.width()) / 2,
|
||||||
inner.y() + (originTop.height() * 2 - size.height()) / 2);
|
inner.y() + (originTop.height() * 2 - size.height()) / 2);
|
||||||
p.drawRoundedRect(blockRect, 2, 3);
|
{
|
||||||
|
const auto xRadius = anim::interpolate(2, 3, lockToStopProgress);
|
||||||
|
p.drawRoundedRect(blockRect, xRadius, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto offsetTranslate = lockToStopProgress *
|
||||||
|
(lineHeight + arcHeight + _arcPen.width() * 2);
|
||||||
p.translate(
|
p.translate(
|
||||||
size.width() - offset,
|
size.width() - arcOffset,
|
||||||
blockRect.y());
|
blockRect.y() + offsetTranslate);
|
||||||
|
|
||||||
if (progress < 1. && progress > 0.) {
|
if (progress < 1. && progress > 0.) {
|
||||||
p.rotate(kLockArcAngle * progress);
|
p.rotate(kLockArcAngle * progress);
|
||||||
|
@ -801,8 +830,6 @@ void RecordLock::drawProgress(Painter &p) {
|
||||||
const auto rLine = QLineF(0, 0, 0, -lineHeight);
|
const auto rLine = QLineF(0, 0, 0, -lineHeight);
|
||||||
p.drawLine(rLine);
|
p.drawLine(rLine);
|
||||||
|
|
||||||
const auto arcWidth = size.width() - offset * 2;
|
|
||||||
const auto &arcHeight = st::historyRecordLockIconArcHeight;
|
|
||||||
p.drawArc(
|
p.drawArc(
|
||||||
-arcWidth,
|
-arcWidth,
|
||||||
rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(),
|
rLine.dy() - arcHeight - _arcPen.width() + rLine.y1(),
|
||||||
|
|
|
@ -371,6 +371,7 @@ historyRecordLockIconLineHeight: 2px;
|
||||||
historyRecordLockIconLineSkip: 3px;
|
historyRecordLockIconLineSkip: 3px;
|
||||||
historyRecordLockIconLineWidth: 2px;
|
historyRecordLockIconLineWidth: 2px;
|
||||||
historyRecordLockIconArcHeight: 4px;
|
historyRecordLockIconArcHeight: 4px;
|
||||||
|
historyRecordStopIconWidth: 12px;
|
||||||
|
|
||||||
historyRecordLockTopShadow: icon {{ "voice_lock/record_lock_top_shadow", historyToDownShadow }};
|
historyRecordLockTopShadow: icon {{ "voice_lock/record_lock_top_shadow", historyToDownShadow }};
|
||||||
historyRecordLockTop: icon {{ "voice_lock/record_lock_top", historyToDownBg }};
|
historyRecordLockTop: icon {{ "voice_lock/record_lock_top", historyToDownBg }};
|
||||||
|
|
Loading…
Add table
Reference in a new issue