mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-28 09:32:56 +00:00
parent
1024f38944
commit
099482574e
@ -244,8 +244,9 @@ TextWithEntities Media::consumedMessageText() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Media> Media::createView(
|
||||
not_null<HistoryView::Element*> message) {
|
||||
return createView(message, message->data());
|
||||
not_null<HistoryView::Element*> message,
|
||||
HistoryView::Element *replacing) {
|
||||
return createView(message, message->data(), replacing);
|
||||
}
|
||||
|
||||
MediaPhoto::MediaPhoto(
|
||||
@ -386,7 +387,8 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaPhoto::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
if (_chat) {
|
||||
return std::make_unique<HistoryView::Photo>(
|
||||
message,
|
||||
@ -663,11 +665,15 @@ bool MediaFile::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaFile::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
if (_document->sticker()) {
|
||||
return std::make_unique<HistoryView::UnwrappedMedia>(
|
||||
message,
|
||||
std::make_unique<HistoryView::Sticker>(message, _document));
|
||||
std::make_unique<HistoryView::Sticker>(
|
||||
message,
|
||||
_document,
|
||||
replacing));
|
||||
} else if (_document->isAnimation() || _document->isVideoFile()) {
|
||||
return std::make_unique<HistoryView::Gif>(
|
||||
message,
|
||||
@ -760,7 +766,8 @@ bool MediaContact::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaContact::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Contact>(
|
||||
message,
|
||||
_contact.userId,
|
||||
@ -840,7 +847,8 @@ bool MediaLocation::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaLocation::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Location>(
|
||||
message,
|
||||
_location,
|
||||
@ -900,7 +908,8 @@ bool MediaCall::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaCall::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Call>(message, &_call);
|
||||
}
|
||||
|
||||
@ -995,7 +1004,8 @@ bool MediaWebPage::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaWebPage::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::WebPage>(message, _page);
|
||||
}
|
||||
|
||||
@ -1086,7 +1096,8 @@ bool MediaGame::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaGame::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Game>(
|
||||
message,
|
||||
_game,
|
||||
@ -1151,7 +1162,8 @@ bool MediaInvoice::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaInvoice::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Invoice>(message, &_invoice);
|
||||
}
|
||||
|
||||
@ -1217,7 +1229,8 @@ bool MediaPoll::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaPoll::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::Poll>(message, _poll);
|
||||
}
|
||||
|
||||
@ -1274,7 +1287,8 @@ bool MediaDice::updateSentMedia(const MTPMessageMedia &media) {
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaDice::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing) {
|
||||
return std::make_unique<HistoryView::UnwrappedMedia>(
|
||||
message,
|
||||
std::make_unique<HistoryView::Dice>(message, this));
|
||||
|
@ -111,9 +111,11 @@ public:
|
||||
virtual bool updateSentMedia(const MTPMessageMedia &media) = 0;
|
||||
virtual std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) = 0;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) = 0;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message);
|
||||
not_null<HistoryView::Element*> message,
|
||||
HistoryView::Element *replacing = nullptr);
|
||||
|
||||
private:
|
||||
const not_null<HistoryItem*> _parent;
|
||||
@ -152,7 +154,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
not_null<PhotoData*> _photo;
|
||||
@ -189,7 +192,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
not_null<DocumentData*> _document;
|
||||
@ -218,7 +222,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
SharedContact _contact;
|
||||
@ -248,7 +253,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
LocationPoint _point;
|
||||
@ -276,7 +282,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
static QString Text(
|
||||
not_null<HistoryItem*> item,
|
||||
@ -312,7 +319,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
not_null<WebPageData*> _page;
|
||||
@ -343,7 +351,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
not_null<GameData*> _game;
|
||||
@ -374,7 +383,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
Invoice _invoice;
|
||||
@ -401,7 +411,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
not_null<PollData*> _poll;
|
||||
@ -425,7 +436,8 @@ public:
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
not_null<HistoryItem*> realParent,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
private:
|
||||
QString _emoji;
|
||||
|
@ -537,13 +537,15 @@ HistoryView::Context InnerWidget::elementContext() {
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> InnerWidget::elementCreate(
|
||||
not_null<HistoryMessage*> message) {
|
||||
return std::make_unique<HistoryView::Message>(this, message);
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<HistoryView::Message>(this, message, replacing);
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> InnerWidget::elementCreate(
|
||||
not_null<HistoryService*> message) {
|
||||
return std::make_unique<HistoryView::Service>(this, message);
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<HistoryView::Service>(this, message, replacing);
|
||||
}
|
||||
|
||||
bool InnerWidget::elementUnderCursor(
|
||||
|
@ -89,9 +89,11 @@ public:
|
||||
// HistoryView::ElementDelegate interface.
|
||||
HistoryView::Context elementContext() override;
|
||||
std::unique_ptr<HistoryView::Element> elementCreate(
|
||||
not_null<HistoryMessage*> message) override;
|
||||
not_null<HistoryMessage*> message,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
std::unique_ptr<HistoryView::Element> elementCreate(
|
||||
not_null<HistoryService*> message) override;
|
||||
not_null<HistoryService*> message,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
bool elementUnderCursor(
|
||||
not_null<const HistoryView::Element*> view) override;
|
||||
void elementAnimationAutoplayAsync(
|
||||
|
@ -3364,7 +3364,9 @@ void HistoryBlock::refreshView(not_null<Element*> view) {
|
||||
Expects(view->block() == this);
|
||||
|
||||
const auto item = view->data();
|
||||
auto refreshed = item->createView(HistoryInner::ElementDelegate());
|
||||
auto refreshed = item->createView(
|
||||
HistoryInner::ElementDelegate(),
|
||||
view);
|
||||
|
||||
auto blockIndex = indexInHistory();
|
||||
auto itemIndex = view->indexInBlock();
|
||||
|
@ -2367,7 +2367,7 @@ HistoryInner::~HistoryInner() {
|
||||
for (const auto &item : _animatedStickersPlayed) {
|
||||
if (const auto view = item->mainView()) {
|
||||
if (const auto media = view->media()) {
|
||||
media->clearStickerLoopPlayed();
|
||||
media->stickerClearLoopPlayed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3314,12 +3314,20 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
|
||||
return HistoryView::Context::History;
|
||||
}
|
||||
std::unique_ptr<HistoryView::Element> elementCreate(
|
||||
not_null<HistoryMessage*> message) override {
|
||||
return std::make_unique<HistoryView::Message>(this, message);
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing = nullptr) override {
|
||||
return std::make_unique<HistoryView::Message>(
|
||||
this,
|
||||
message,
|
||||
replacing);
|
||||
}
|
||||
std::unique_ptr<HistoryView::Element> elementCreate(
|
||||
not_null<HistoryService*> message) override {
|
||||
return std::make_unique<HistoryView::Service>(this, message);
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing = nullptr) override {
|
||||
return std::make_unique<HistoryView::Service>(
|
||||
this,
|
||||
message,
|
||||
replacing);
|
||||
}
|
||||
bool elementUnderCursor(
|
||||
not_null<const HistoryView::Element*> view) override {
|
||||
|
@ -326,7 +326,8 @@ public:
|
||||
[[nodiscard]] PeerData *displayFrom() const;
|
||||
|
||||
[[nodiscard]] virtual std::unique_ptr<HistoryView::Element> createView(
|
||||
not_null<HistoryView::ElementDelegate*> delegate) = 0;
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
HistoryView::Element *replacing = nullptr) = 0;
|
||||
|
||||
void updateDate(TimeId newDate);
|
||||
[[nodiscard]] bool canUpdateDate() const;
|
||||
|
@ -1387,8 +1387,9 @@ QString HistoryMessage::notificationHeader() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> HistoryMessage::createView(
|
||||
not_null<HistoryView::ElementDelegate*> delegate) {
|
||||
return delegate->elementCreate(this);
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
HistoryView::Element *replacing) {
|
||||
return delegate->elementCreate(this, replacing);
|
||||
}
|
||||
|
||||
HistoryMessage::~HistoryMessage() {
|
||||
|
@ -168,7 +168,8 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
||||
not_null<HistoryView::ElementDelegate*> delegate) override;
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
~HistoryMessage();
|
||||
|
||||
|
@ -562,8 +562,9 @@ QString HistoryService::inReplyText() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> HistoryService::createView(
|
||||
not_null<HistoryView::ElementDelegate*> delegate) {
|
||||
return delegate->elementCreate(this);
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
HistoryView::Element *replacing) {
|
||||
return delegate->elementCreate(this, replacing);
|
||||
}
|
||||
|
||||
QString HistoryService::fromLinkText() const {
|
||||
|
@ -105,7 +105,8 @@ public:
|
||||
QString inReplyText() const override;
|
||||
|
||||
std::unique_ptr<HistoryView::Element> createView(
|
||||
not_null<HistoryView::ElementDelegate*> delegate) override;
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
~HistoryService();
|
||||
|
||||
|
@ -56,13 +56,15 @@ bool IsAttachedToPreviousInSavedMessages(
|
||||
|
||||
|
||||
std::unique_ptr<HistoryView::Element> SimpleElementDelegate::elementCreate(
|
||||
not_null<HistoryMessage*> message) {
|
||||
return std::make_unique<HistoryView::Message>(this, message);
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<HistoryView::Message>(this, message, replacing);
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> SimpleElementDelegate::elementCreate(
|
||||
not_null<HistoryService*> message) {
|
||||
return std::make_unique<HistoryView::Service>(this, message);
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<HistoryView::Service>(this, message, replacing);
|
||||
}
|
||||
|
||||
bool SimpleElementDelegate::elementUnderCursor(
|
||||
@ -203,14 +205,15 @@ void DateBadge::paint(Painter &p, int y, int w) const {
|
||||
|
||||
Element::Element(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryItem*> data)
|
||||
not_null<HistoryItem*> data,
|
||||
Element *replacing)
|
||||
: _delegate(delegate)
|
||||
, _data(data)
|
||||
, _isScheduledUntilOnline(IsItemScheduledUntilOnline(data))
|
||||
, _dateTime(_isScheduledUntilOnline ? QDateTime() : ItemDateTime(data))
|
||||
, _context(delegate->elementContext()) {
|
||||
history()->owner().registerItemView(this);
|
||||
refreshMedia();
|
||||
refreshMedia(replacing);
|
||||
if (_context == Context::History) {
|
||||
history()->setHasPendingResizedItems();
|
||||
}
|
||||
@ -338,7 +341,7 @@ bool Element::isHidden() const {
|
||||
return isHiddenByGroup();
|
||||
}
|
||||
|
||||
void Element::refreshMedia() {
|
||||
void Element::refreshMedia(Element *replacing) {
|
||||
_flags &= ~Flag::HiddenByGroup;
|
||||
|
||||
const auto item = data();
|
||||
@ -361,7 +364,7 @@ void Element::refreshMedia() {
|
||||
}
|
||||
const auto session = &history()->session();
|
||||
if (const auto media = _data->media()) {
|
||||
_media = media->createView(this);
|
||||
_media = media->createView(this, replacing);
|
||||
} else if (_data->isIsolatedEmoji()
|
||||
&& session->settings().largeEmoji()) {
|
||||
const auto emoji = _data->isolatedEmoji();
|
||||
@ -372,6 +375,7 @@ void Element::refreshMedia() {
|
||||
std::make_unique<Sticker>(
|
||||
this,
|
||||
sticker.document,
|
||||
replacing,
|
||||
sticker.replacements));
|
||||
} else {
|
||||
_media = std::make_unique<UnwrappedMedia>(
|
||||
|
@ -37,9 +37,11 @@ class ElementDelegate {
|
||||
public:
|
||||
virtual Context elementContext() = 0;
|
||||
virtual std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryMessage*> message) = 0;
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing = nullptr) = 0;
|
||||
virtual std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryService*> message) = 0;
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing = nullptr) = 0;
|
||||
virtual bool elementUnderCursor(not_null<const Element*> view) = 0;
|
||||
virtual void elementAnimationAutoplayAsync(
|
||||
not_null<const Element*> element) = 0;
|
||||
@ -63,9 +65,11 @@ public:
|
||||
class SimpleElementDelegate : public ElementDelegate {
|
||||
public:
|
||||
std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryMessage*> message) override;
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing = nullptr) override;
|
||||
std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryService*> message) override;
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing = nullptr) override;
|
||||
bool elementUnderCursor(not_null<const Element*> view) override;
|
||||
void elementAnimationAutoplayAsync(
|
||||
not_null<const Element*> element) override;
|
||||
@ -134,7 +138,8 @@ class Element
|
||||
public:
|
||||
Element(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryItem*> data);
|
||||
not_null<HistoryItem*> data,
|
||||
Element *replacing);
|
||||
|
||||
enum class Flag : uchar {
|
||||
NeedsResize = 0x01,
|
||||
@ -304,7 +309,7 @@ private:
|
||||
virtual QSize performCountOptimalSize() = 0;
|
||||
virtual QSize performCountCurrentSize(int newWidth) = 0;
|
||||
|
||||
void refreshMedia();
|
||||
void refreshMedia(Element *replacing);
|
||||
|
||||
const not_null<ElementDelegate*> _delegate;
|
||||
const not_null<HistoryItem*> _data;
|
||||
|
@ -1107,13 +1107,15 @@ Context ListWidget::elementContext() {
|
||||
}
|
||||
|
||||
std::unique_ptr<Element> ListWidget::elementCreate(
|
||||
not_null<HistoryMessage*> message) {
|
||||
return std::make_unique<Message>(this, message);
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<Message>(this, message, replacing);
|
||||
}
|
||||
|
||||
std::unique_ptr<Element> ListWidget::elementCreate(
|
||||
not_null<HistoryService*> message) {
|
||||
return std::make_unique<Service>(this, message);
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing) {
|
||||
return std::make_unique<Service>(this, message, replacing);
|
||||
}
|
||||
|
||||
bool ListWidget::elementUnderCursor(
|
||||
|
@ -184,9 +184,11 @@ public:
|
||||
// ElementDelegate interface.
|
||||
Context elementContext() override;
|
||||
std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryMessage*> message) override;
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing = nullptr) override;
|
||||
std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryService*> message) override;
|
||||
not_null<HistoryService*> message,
|
||||
Element *replacing = nullptr) override;
|
||||
bool elementUnderCursor(not_null<const Element*> view) override;
|
||||
void elementAnimationAutoplayAsync(
|
||||
not_null<const Element*> view) override;
|
||||
|
@ -201,8 +201,9 @@ LogEntryOriginal::~LogEntryOriginal() = default;
|
||||
|
||||
Message::Message(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryMessage*> data)
|
||||
: Element(delegate, data) {
|
||||
not_null<HistoryMessage*> data,
|
||||
Element *replacing)
|
||||
: Element(delegate, data, replacing) {
|
||||
initLogEntryOriginal();
|
||||
initPsa();
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ class Message : public Element, public base::has_weak_ptr {
|
||||
public:
|
||||
Message(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryMessage*> data);
|
||||
not_null<HistoryMessage*> data,
|
||||
Element *replacing);
|
||||
|
||||
int marginTop() const override;
|
||||
int marginBottom() const override;
|
||||
|
@ -309,8 +309,9 @@ void serviceColorsUpdated() {
|
||||
|
||||
Service::Service(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryService*> data)
|
||||
: Element(delegate, data) {
|
||||
not_null<HistoryService*> data,
|
||||
Element *replacing)
|
||||
: Element(delegate, data, replacing) {
|
||||
}
|
||||
|
||||
not_null<HistoryService*> Service::message() const {
|
||||
|
@ -17,7 +17,8 @@ class Service : public Element {
|
||||
public:
|
||||
Service(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryService*> data);
|
||||
not_null<HistoryService*> data,
|
||||
Element *replacing);
|
||||
|
||||
int marginTop() const override;
|
||||
int marginBottom() const override;
|
||||
|
@ -26,8 +26,6 @@ public:
|
||||
|
||||
ClickHandlerPtr link() override;
|
||||
|
||||
void clearStickerLoopPlayed() override {
|
||||
}
|
||||
bool hasHeavyPart() const override {
|
||||
return (_start ? _start->hasHeavyPart() : false)
|
||||
|| (_end ? _end->hasHeavyPart() : false);
|
||||
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "lottie/lottie_single_player.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
#include "data/data_document.h"
|
||||
#include "ui/text_options.h"
|
||||
@ -165,6 +166,10 @@ PointState Media::pointState(QPoint point) const {
|
||||
: PointState::Outside;
|
||||
}
|
||||
|
||||
std::unique_ptr<Lottie::SinglePlayer> Media::stickerTakeLottie() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextState Media::getStateGrouped(
|
||||
const QRect &geometry,
|
||||
RectParts sides,
|
||||
|
@ -24,6 +24,10 @@ enum class SharedMediaType : signed char;
|
||||
using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
|
||||
} // namespace Storage
|
||||
|
||||
namespace Lottie {
|
||||
class SinglePlayer;
|
||||
} // namespace Lottie
|
||||
|
||||
namespace HistoryView {
|
||||
|
||||
enum class PointState : char;
|
||||
@ -139,8 +143,9 @@ public:
|
||||
}
|
||||
virtual void stopAnimation() {
|
||||
}
|
||||
virtual void clearStickerLoopPlayed() {
|
||||
virtual void stickerClearLoopPlayed() {
|
||||
}
|
||||
virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie();
|
||||
virtual void checkAnimation() {
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "lottie/lottie_single_player.h"
|
||||
#include "layout.h"
|
||||
#include "facades.h"
|
||||
#include "app.h"
|
||||
@ -24,6 +25,11 @@ constexpr auto kMaxForwardedBarLines = 4;
|
||||
|
||||
} // namespace
|
||||
|
||||
auto UnwrappedMedia::Content::stickerTakeLottie()
|
||||
-> std::unique_ptr<Lottie::SinglePlayer> {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UnwrappedMedia::UnwrappedMedia(
|
||||
not_null<Element*> parent,
|
||||
std::unique_ptr<Content> content)
|
||||
@ -376,6 +382,10 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<Lottie::SinglePlayer> UnwrappedMedia::stickerTakeLottie() {
|
||||
return _content->stickerTakeLottie();
|
||||
}
|
||||
|
||||
int UnwrappedMedia::calculateFullRight(const QRect &inner) const {
|
||||
const auto rightAligned = _parent->hasOutLayout() && !Adaptive::ChatWide();
|
||||
const auto infoWidth = _parent->infoWidth()
|
||||
|
@ -32,8 +32,9 @@ public:
|
||||
[[nodiscard]] virtual DocumentData *document() {
|
||||
return nullptr;
|
||||
}
|
||||
virtual void clearStickerLoopPlayed() {
|
||||
virtual void stickerClearLoopPlayed() {
|
||||
}
|
||||
virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie();
|
||||
virtual bool hasHeavyPart() const {
|
||||
return false;
|
||||
}
|
||||
@ -81,9 +82,10 @@ public:
|
||||
bool hidesForwardedInfo() const override {
|
||||
return _content->hidesForwardedInfo();
|
||||
}
|
||||
void clearStickerLoopPlayed() override {
|
||||
_content->clearStickerLoopPlayed();
|
||||
void stickerClearLoopPlayed() override {
|
||||
_content->stickerClearLoopPlayed();
|
||||
}
|
||||
std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie() override;
|
||||
|
||||
bool hasHeavyPart() const override {
|
||||
return _content->hasHeavyPart();
|
||||
|
@ -57,11 +57,22 @@ namespace {
|
||||
Sticker::Sticker(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> data,
|
||||
Element *replacing,
|
||||
const Lottie::ColorReplacements *replacements)
|
||||
: _parent(parent)
|
||||
, _data(data)
|
||||
, _replacements(replacements) {
|
||||
if ((_dataMedia = _data->activeMediaView())) {
|
||||
dataMediaCreated();
|
||||
} else {
|
||||
_data->loadThumbnail(parent->data()->fullId());
|
||||
}
|
||||
if (const auto media = replacing ? replacing->media() : nullptr) {
|
||||
_lottie = media->stickerTakeLottie();
|
||||
if (_lottie) {
|
||||
lottieCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sticker::~Sticker() {
|
||||
@ -263,6 +274,12 @@ void Sticker::ensureDataMediaCreated() const {
|
||||
return;
|
||||
}
|
||||
_dataMedia = _data->createMediaView();
|
||||
dataMediaCreated();
|
||||
}
|
||||
|
||||
void Sticker::dataMediaCreated() const {
|
||||
Expects(_dataMedia != nullptr);
|
||||
|
||||
_dataMedia->goodThumbnailWanted();
|
||||
_dataMedia->thumbnailWanted(_parent->data()->fullId());
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
@ -282,6 +299,12 @@ void Sticker::setupLottie() {
|
||||
Stickers::LottieSize::MessageHistory,
|
||||
_size * cIntRetinaFactor(),
|
||||
Lottie::Quality::High);
|
||||
lottieCreated();
|
||||
}
|
||||
|
||||
void Sticker::lottieCreated() {
|
||||
Expects(_lottie != nullptr);
|
||||
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
|
||||
_lottie->updates(
|
||||
@ -315,4 +338,8 @@ void Sticker::unloadLottie() {
|
||||
_parent->checkHeavyPart();
|
||||
}
|
||||
|
||||
std::unique_ptr< Lottie::SinglePlayer> Sticker::stickerTakeLottie() {
|
||||
return std::move(_lottie);
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
Sticker(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> data,
|
||||
Element *replacing = nullptr,
|
||||
const Lottie::ColorReplacements *replacements = nullptr);
|
||||
~Sticker();
|
||||
|
||||
@ -46,9 +47,10 @@ public:
|
||||
DocumentData *document() override {
|
||||
return _data;
|
||||
}
|
||||
void clearStickerLoopPlayed() override {
|
||||
void stickerClearLoopPlayed() override {
|
||||
_lottieOncePlayed = false;
|
||||
}
|
||||
std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie() override;
|
||||
|
||||
bool hasHeavyPart() const override;
|
||||
void unloadHeavyPart() override;
|
||||
@ -74,8 +76,10 @@ private:
|
||||
[[nodiscard]] QPixmap paintedPixmap(bool selected) const;
|
||||
|
||||
void ensureDataMediaCreated() const;
|
||||
void dataMediaCreated() const;
|
||||
|
||||
void setupLottie();
|
||||
void lottieCreated();
|
||||
void unloadLottie();
|
||||
|
||||
const not_null<Element*> _parent;
|
||||
|
@ -550,7 +550,7 @@ void Sticker::prepareThumbnail() const {
|
||||
}
|
||||
_dataMedia->checkStickerSmall();
|
||||
if (const auto sticker = _dataMedia->getStickerSmall()) {
|
||||
if (!_lottie && !_thumbLoaded && _dataMedia->loaded()) {
|
||||
if (!_lottie && !_thumbLoaded) {
|
||||
const auto thumbSize = getThumbSize();
|
||||
_thumb = sticker->pix(
|
||||
thumbSize.width(),
|
||||
|
Loading…
Reference in New Issue
Block a user