diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index 65f5fd6595..d689b6535d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -247,7 +247,17 @@ void Game::draw(Painter &p, const PaintContext &context) const { endskip = _parent->skipBlockWidth(); } _parent->prepareCustomEmojiPaint(p, context, _description); - _description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection)); + _description.draw(p, { + .position = { padding.left(), tshift }, + .outerWidth = width(), + .availableWidth = paintw, + .spoiler = Ui::Text::DefaultSpoilerCache(), + .now = context.now, + .paused = context.paused, + .selection = toDescriptionSelection(context.selection), + .elisionLines = _descriptionLines, + .elisionRemoveFromEnd = endskip, + }); tshift += _descriptionLines * lineHeight; } if (_attach) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp index e726ab9104..a57bbf0f33 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp @@ -228,7 +228,16 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { } if (_descriptionHeight) { p.setPen(stm->historyTextFg); - _description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection)); + _parent->prepareCustomEmojiPaint(p, context, _description); + _description.draw(p, { + .position = { padding.left(), tshift }, + .outerWidth = width(), + .availableWidth = paintw, + .spoiler = Ui::Text::DefaultSpoilerCache(), + .now = context.now, + .paused = context.paused, + .selection = toDescriptionSelection(context.selection), + }); tshift += _descriptionHeight; } if (_attach) { @@ -353,6 +362,17 @@ void Invoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) } } +bool Invoice::hasHeavyPart() const { + return _attach ? _attach->hasHeavyPart() : false; +} + +void Invoice::unloadHeavyPart() { + if (_attach) { + _attach->unloadHeavyPart(); + } + _description.unloadPersistentAnimation(); +} + TextForMimeData Invoice::selectedText(TextSelection selection) const { auto titleResult = _title.toTextForMimeData(selection); auto descriptionResult = _description.toTextForMimeData( diff --git a/Telegram/SourceFiles/history/view/media/history_view_invoice.h b/Telegram/SourceFiles/history/view/media/history_view_invoice.h index 2b5d6b20e9..a95c7d5dc3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_invoice.h +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.h @@ -70,14 +70,8 @@ public: return _attach.get(); } - bool hasHeavyPart() const override { - return _attach ? _attach->hasHeavyPart() : false; - } - void unloadHeavyPart() override { - if (_attach) { - _attach->unloadHeavyPart(); - } - } + bool hasHeavyPart() const override; + void unloadHeavyPart() override; private: QSize countOptimalSize() override; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index b6d8c5ce0d..357b2580aa 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -568,13 +568,20 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { endskip = _parent->skipBlockWidth(); } _parent->prepareCustomEmojiPaint(p, context, _description); - if (_descriptionLines > 0) { - _description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection)); - tshift += _descriptionLines * lineHeight; - } else { - _description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection)); - tshift += _description.countHeight(paintw); - } + _description.draw(p, { + .position = { padding.left(), tshift }, + .outerWidth = width(), + .availableWidth = paintw, + .spoiler = Ui::Text::DefaultSpoilerCache(), + .now = context.now, + .paused = context.paused, + .selection = toDescriptionSelection(context.selection), + .elisionLines = std::max(_descriptionLines, 0), + .elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0, + }); + tshift += (_descriptionLines > 0) + ? (_descriptionLines * lineHeight) + : _description.countHeight(paintw); } if (_attach) { auto attachAtTop = !_siteNameLines && !_titleLines && !_descriptionLines;