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; SpoilerMessCache *spoiler = nullptr;
crl::time now = 0; crl::time now = 0;
bool paused = false; bool paused = false;
bool pausedEmoji = false;
bool pausedSpoiler = false;
TextSelection selection; TextSelection selection;
bool fullWidthSelection = true; bool fullWidthSelection = true;

View file

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

View file

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