Added ability to set custom animation duration for MediaPreviewWidget.
This commit is contained in:
@@ -243,7 +243,10 @@ void MediaPreviewWidget::startShow() {
|
||||
Window::GifPauseReason::MediaPreview);
|
||||
}
|
||||
_hiding = false;
|
||||
_a_shown.start([=] { update(); }, 0., 1., st::stickerPreviewDuration);
|
||||
const auto duration = _customDuration
|
||||
? _customDuration
|
||||
: st::stickerPreviewDuration;
|
||||
_a_shown.start([=] { update(); }, 0., 1., duration);
|
||||
} else {
|
||||
update();
|
||||
}
|
||||
@@ -257,7 +260,10 @@ void MediaPreviewWidget::hidePreview() {
|
||||
_cache = currentImage();
|
||||
}
|
||||
_hiding = true;
|
||||
_a_shown.start([=] { update(); }, 1., 0., st::stickerPreviewDuration);
|
||||
const auto duration = _customDuration
|
||||
? _customDuration
|
||||
: st::stickerPreviewDuration;
|
||||
_a_shown.start([=] { update(); }, 1., 0., duration);
|
||||
_photo = nullptr;
|
||||
_photoMedia = nullptr;
|
||||
_document = nullptr;
|
||||
@@ -309,6 +315,10 @@ void MediaPreviewWidget::setCustomRadius(int radius) {
|
||||
update();
|
||||
}
|
||||
|
||||
void MediaPreviewWidget::setCustomDuration(crl::time duration) {
|
||||
_customDuration = duration;
|
||||
}
|
||||
|
||||
QSize MediaPreviewWidget::currentDimensions() const {
|
||||
if (!_cachedSize.isEmpty()) {
|
||||
return _cachedSize;
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
void setCustomPadding(const QMargins &padding = QMargins());
|
||||
void setBackgroundMargins(const QMargins &margins = QMargins());
|
||||
void setCustomRadius(int radius);
|
||||
void setCustomDuration(crl::time duration);
|
||||
|
||||
~MediaPreviewWidget();
|
||||
|
||||
@@ -93,6 +94,7 @@ private:
|
||||
QMargins _customPadding;
|
||||
QMargins _backgroundMargins;
|
||||
int _customRadius = 0;
|
||||
crl::time _customDuration = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user