Allow pausing emoji and spoilers separately.

This commit is contained in:
John Preston 2023-02-21 16:30:59 +04:00
parent 74ab66cfa9
commit a110c6ea53
3 changed files with 8 additions and 4 deletions

View file

@ -138,6 +138,8 @@ struct PaintContext {
SpoilerMessCache *spoiler = nullptr;
crl::time now = 0;
bool paused = false;
bool pausedEmoji = false;
bool pausedSpoiler = false;
TextSelection selection;
bool fullWidthSelection = true;

View file

@ -198,7 +198,8 @@ void Renderer::draw(QPainter &p, const PaintContext &context) {
_w = context.availableWidth;
_align = context.align;
_cachedNow = context.now;
_paused = context.paused;
_pausedEmoji = context.paused || context.pausedEmoji;
_pausedSpoiler = context.paused || context.pausedSpoiler;
_spoilerOpacity = _spoiler
? (1. - _spoiler->revealAnimation.value(
_spoiler->revealed ? 1. : 0.))
@ -838,7 +839,7 @@ bool Renderer::drawLine(uint16 _lineEnd, const String::TextBlocks::const_iterato
_customEmojiContext = CustomEmoji::Context{
.textColor = color,
.now = now(),
.paused = _paused,
.paused = _pausedEmoji,
};
} else {
_customEmojiContext->textColor = color;
@ -1161,7 +1162,7 @@ void Renderer::paintSpoilerRects() {
if (_spoilerOpacity < 1.) {
_p->setOpacity(opacity * _spoilerOpacity);
}
const auto index = _spoiler->animation.index(now(), _paused);
const auto index = _spoiler->animation.index(now(), _pausedSpoiler);
paintSpoilerRects(
_spoilerRects,
_palette->spoilerFg,

View file

@ -118,7 +118,8 @@ private:
bool _elideLast = false;
bool _breakEverywhere = false;
int _elideRemoveFromEnd = 0;
bool _paused = false;
bool _pausedEmoji = false;
bool _pausedSpoiler = false;
style::align _align = style::al_topleft;
QPen _originalPen;
QPen _originalPenSelected;