Clip intro animation by Next button.

This commit is contained in:
John Preston 2019-11-29 16:42:42 +03:00
parent 66961dce83
commit 524d64a462
3 changed files with 13 additions and 0 deletions

View File

@ -233,6 +233,9 @@ bool Step::paintAnimated(Painter &p, QRect clip) {
}
return false;
}
if (!_coverAnimation.clipping.isEmpty()) {
p.setClipRect(_coverAnimation.clipping);
}
auto progress = (hasCover() ? anim::easeOutCirc(1., dt) : anim::linear(1., dt));
auto arrivingAlpha = progress;
@ -451,6 +454,10 @@ void Step::showAnimated(Direction direction) {
}
}
void Step::setShowAnimationClipping(QRect clipping) {
_coverAnimation.clipping = clipping;
}
void Step::setGoCallback(Fn<void(Step *step, Direction direction)> callback) {
_goCallback = std::move(callback);
}

View File

@ -64,6 +64,7 @@ public:
void showAnimated(Direction direction);
void showFast();
[[nodiscard]] bool animating() const;
void setShowAnimationClipping(QRect clipping);
[[nodiscard]] bool hasCover() const;
[[nodiscard]] virtual bool hasBack() const;
@ -142,6 +143,8 @@ private:
// From content top till the next button top.
QPixmap contentSnapshotWas;
QPixmap contentSnapshotNow;
QRect clipping;
};
void updateLabelsPosition();
void paintContentSnapshot(

View File

@ -639,6 +639,9 @@ void Widget::updateControlsGeometry() {
nextTop,
shownAmount);
_next->moveToLeft((width() - _next->width()) / 2, realNextTop);
getStep()->setShowAnimationClipping(shownAmount > 0
? QRect(0, 0, width(), realNextTop)
: QRect());
if (_changeLanguage) {
_changeLanguage->moveToLeft((width() - _changeLanguage->width()) / 2, _next->y() + _next->height() + _changeLanguage->height());
}