Added animation for recorded voice data delete.
This commit is contained in:
parent
fb2924f2d6
commit
eadd952e66
1 changed files with 21 additions and 7 deletions
|
@ -52,6 +52,8 @@ constexpr auto kPrecision = 10;
|
||||||
|
|
||||||
constexpr auto kLockArcAngle = 15.;
|
constexpr auto kLockArcAngle = 15.;
|
||||||
|
|
||||||
|
constexpr auto kHideWaveformBgOffset = 50;
|
||||||
|
|
||||||
enum class FilterType {
|
enum class FilterType {
|
||||||
Continue,
|
Continue,
|
||||||
ShowBox,
|
ShowBox,
|
||||||
|
@ -239,6 +241,8 @@ private:
|
||||||
const QColor _activeWaveformBar;
|
const QColor _activeWaveformBar;
|
||||||
const QColor _inactiveWaveformBar;
|
const QColor _inactiveWaveformBar;
|
||||||
|
|
||||||
|
bool _isShowAnimation = true;
|
||||||
|
|
||||||
QRect _waveformBgRect;
|
QRect _waveformBgRect;
|
||||||
QRect _waveformBgFinalCenterRect;
|
QRect _waveformBgFinalCenterRect;
|
||||||
QRect _waveformFgRect;
|
QRect _waveformFgRect;
|
||||||
|
@ -315,19 +319,22 @@ void ListenWrap::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
const auto hideOffset = _isShowAnimation
|
||||||
|
? 0
|
||||||
|
: anim::interpolate(kHideWaveformBgOffset, 0, progress);
|
||||||
const auto deleteIconLeft = _stDelete.iconPosition.x();
|
const auto deleteIconLeft = _stDelete.iconPosition.x();
|
||||||
const auto bgRectRight = anim::interpolate(
|
const auto bgRectRight = anim::interpolate(
|
||||||
deleteIconLeft,
|
deleteIconLeft,
|
||||||
_stDelete.width,
|
_stDelete.width,
|
||||||
progress);
|
_isShowAnimation ? progress : 1.);
|
||||||
const auto bgRectLeft = anim::interpolate(
|
const auto bgRectLeft = anim::interpolate(
|
||||||
_parent->width() - deleteIconLeft - _waveformBgRect.height(),
|
_parent->width() - deleteIconLeft - _waveformBgRect.height(),
|
||||||
_stDelete.width,
|
_stDelete.width,
|
||||||
progress);
|
_isShowAnimation ? progress : 1.);
|
||||||
const auto bgRectMargins = style::margins(
|
const auto bgRectMargins = style::margins(
|
||||||
bgRectLeft,
|
bgRectLeft - hideOffset,
|
||||||
0,
|
0,
|
||||||
bgRectRight,
|
bgRectRight + hideOffset,
|
||||||
0);
|
0);
|
||||||
const auto bgRect = _waveformBgRect.marginsRemoved(bgRectMargins);
|
const auto bgRect = _waveformBgRect.marginsRemoved(bgRectMargins);
|
||||||
|
|
||||||
|
@ -341,11 +348,17 @@ void ListenWrap::init() {
|
||||||
const auto bgCenterRect = bgRect.marginsRemoved(
|
const auto bgCenterRect = bgRect.marginsRemoved(
|
||||||
style::margins(halfHeight, 0, halfHeight, 0));
|
style::margins(halfHeight, 0, halfHeight, 0));
|
||||||
|
|
||||||
|
if (!_isShowAnimation) {
|
||||||
|
p.setOpacity(progress);
|
||||||
|
}
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::historyRecordCancelActive);
|
p.setBrush(st::historyRecordCancelActive);
|
||||||
p.drawEllipse(bgLeftCircleRect);
|
QPainterPath path;
|
||||||
p.drawEllipse(bgRightCircleRect);
|
path.setFillRule(Qt::WindingFill);
|
||||||
p.fillRect(bgCenterRect, st::historyRecordCancelActive);
|
path.addEllipse(bgLeftCircleRect);
|
||||||
|
path.addEllipse(bgRightCircleRect);
|
||||||
|
path.addRect(bgCenterRect);
|
||||||
|
p.drawPath(path);
|
||||||
|
|
||||||
// Duration paint.
|
// Duration paint.
|
||||||
{
|
{
|
||||||
|
@ -575,6 +588,7 @@ int ListenWrap::computeTopMargin(int height) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListenWrap::requestPaintProgress(float64 progress) {
|
void ListenWrap::requestPaintProgress(float64 progress) {
|
||||||
|
_isShowAnimation = (_showProgress.current() < progress);
|
||||||
_showProgress = progress;
|
_showProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue