Commit 6cc1c1aa authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

overlays: replace fade animation with geometry animation for vignette

Change-Id: Ic0918b5d14cdf6acf2652964070f4aaf64c751e4
parent 88ddded1
......@@ -111,7 +111,7 @@ VideoView::resizeEvent(QResizeEvent* event)
resetPreview();
vignette_->resize(this->size());
vignette_->updateGeometry(this->size());
audioOnlyAvatar_->resize(this->size());
overlay_->resize(this->size());
}
......
......@@ -125,7 +125,8 @@ VignetteWidget::VignetteWidget(QWidget* parent)
: QWidget(parent)
{
setAttribute(Qt::WA_NoSystemBackground);
fadeOutAnimation_ = new FadeAnimation(this, fadeTime_);
geometryAnimation_ = new QPropertyAnimation(this, "geometry");
geometryAnimation_->setDuration(1000);
}
VignetteWidget::~VignetteWidget()
......@@ -134,18 +135,29 @@ VignetteWidget::~VignetteWidget()
void
VignetteWidget::slotWillFadeOut()
{
fadeOutAnimation_->setDirection(QAbstractAnimation::Direction::Forward);
fadeOutAnimation_->start();
geometryAnimation_->setDirection(QAbstractAnimation::Direction::Forward);
geometryAnimation_->start();
}
void
VignetteWidget::slotWillResetOpacity()
{
if (fadeOutAnimation_->direction() != QAbstractAnimation::Direction::Forward) {
if (geometryAnimation_->direction() != QAbstractAnimation::Direction::Forward) {
return;
}
fadeOutAnimation_->setDirection(QAbstractAnimation::Direction::Backward);
fadeOutAnimation_->start();
geometryAnimation_->setDirection(QAbstractAnimation::Direction::Backward);
geometryAnimation_->start();
}
void
VignetteWidget::updateGeometry(QSize size)
{
resize(size);
QRect endRect = rect();
Utils::whileBlocking(geometryAnimation_)->setStartValue(endRect);
endRect.setHeight(endRect.height() + height_);
endRect.setY(endRect.y() - height_);
Utils::whileBlocking(geometryAnimation_)->setEndValue(endRect);
}
void
......
......@@ -102,6 +102,7 @@ public:
public slots:
void slotWillFadeOut();
void slotWillResetOpacity();
void updateGeometry(QSize size);
protected:
void paintEvent(QPaintEvent *event) override;
......@@ -109,7 +110,7 @@ protected:
private:
void fillRoundRectPath(QPainter& painter, const QLinearGradient& gradient);
FadeAnimation* fadeOutAnimation_;
QPropertyAnimation* geometryAnimation_;
constexpr static qreal cornerRadius_ = 10.0f;
quint64 height_{ 128 };
quint64 fadeTime_{ 1000 };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment