2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Add hierarchy of GIF pausing inside a window.

GIFs get paused if some other layer is displayed above.
Media preview > Box or layer > Saved GIFs panel > Inline bot results.
If any of those is displayed, GIFs inside message history pause too.
This commit is contained in:
John Preston
2017-04-03 17:13:55 +03:00
parent 6003ac2132
commit ffc9585196
19 changed files with 89 additions and 80 deletions

View File

@@ -31,6 +31,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_history.h"
#include "styles/style_boxes.h"
#include "media/media_clip_reader.h"
#include "mainwindow.h"
namespace {
@@ -330,7 +331,8 @@ void SendFilesBox::paintEvent(QPaintEvent *e) {
}
if (_gifPreview && _gifPreview->started()) {
auto s = QSize(_previewWidth, _previewHeight);
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), frame);
} else {
p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), _preview);
@@ -671,7 +673,8 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
}
if (_gifPreview && _gifPreview->started()) {
auto s = QSize(_thumbw, _thumbh);
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), frame);
} else {
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), _thumb);