2019-08-02 17:06:44 +02:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "history/view/media/history_view_media.h"
|
|
|
|
#include "base/weak_ptr.h"
|
|
|
|
#include "base/timer.h"
|
|
|
|
|
|
|
|
struct HistoryMessageVia;
|
|
|
|
struct HistoryMessageReply;
|
|
|
|
struct HistoryMessageForwarded;
|
|
|
|
|
|
|
|
namespace HistoryView {
|
|
|
|
|
|
|
|
class UnwrappedMedia final : public Media {
|
|
|
|
public:
|
|
|
|
class Content {
|
|
|
|
public:
|
2022-08-03 19:26:39 +02:00
|
|
|
[[nodiscard]] virtual QSize countOptimalSize() = 0;
|
|
|
|
[[nodiscard]] virtual QSize countCurrentSize(int newWidth);
|
2019-08-02 20:19:14 +02:00
|
|
|
|
2021-09-03 16:18:03 +02:00
|
|
|
virtual void draw(
|
|
|
|
Painter &p,
|
|
|
|
const PaintContext &context,
|
|
|
|
const QRect &r) = 0;
|
2019-08-02 20:19:14 +02:00
|
|
|
|
|
|
|
[[nodiscard]] virtual ClickHandlerPtr link() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-08-02 17:06:44 +02:00
|
|
|
|
|
|
|
[[nodiscard]] virtual DocumentData *document() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-06-16 18:53:44 +02:00
|
|
|
virtual void stickerClearLoopPlayed() {
|
2019-08-02 17:06:44 +02:00
|
|
|
}
|
2020-07-02 12:44:12 +02:00
|
|
|
virtual std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
|
|
|
|
not_null<DocumentData*> data,
|
|
|
|
const Lottie::ColorReplacements *replacements);
|
2022-04-26 18:31:10 +02:00
|
|
|
|
2022-05-19 15:57:39 +02:00
|
|
|
//virtual void externalLottieProgressing(bool external) {
|
|
|
|
//}
|
|
|
|
//virtual bool externalLottieTill(ExternalLottieInfo info) {
|
|
|
|
// return true;
|
|
|
|
//}
|
|
|
|
//virtual ExternalLottieInfo externalLottieInfo() const {
|
|
|
|
// return {};
|
|
|
|
//}
|
2022-04-26 18:31:10 +02:00
|
|
|
|
2020-05-26 15:40:36 +02:00
|
|
|
virtual bool hasHeavyPart() const {
|
|
|
|
return false;
|
2020-03-27 12:40:50 +01:00
|
|
|
}
|
2019-08-02 17:06:44 +02:00
|
|
|
virtual void unloadHeavyPart() {
|
|
|
|
}
|
|
|
|
virtual void refreshLink() {
|
|
|
|
}
|
2019-08-06 13:27:11 +02:00
|
|
|
[[nodiscard]] virtual bool alwaysShowOutTimestamp() {
|
|
|
|
return false;
|
|
|
|
}
|
2022-07-25 14:06:12 +02:00
|
|
|
virtual bool hasTextForCopy() const {
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-26 16:32:38 +02:00
|
|
|
virtual ~Content() = default;
|
2019-08-02 17:06:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
UnwrappedMedia(
|
|
|
|
not_null<Element*> parent,
|
|
|
|
std::unique_ptr<Content> content);
|
|
|
|
|
2021-08-20 12:12:07 +02:00
|
|
|
void draw(Painter &p, const PaintContext &context) const override;
|
2019-08-18 16:03:34 +02:00
|
|
|
PointState pointState(QPoint point) const override;
|
2019-08-02 17:06:44 +02:00
|
|
|
TextState textState(QPoint point, StateRequest request) const override;
|
|
|
|
|
2022-07-25 14:06:12 +02:00
|
|
|
bool hasTextForCopy() const override;
|
|
|
|
|
2019-08-02 17:06:44 +02:00
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItem() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DocumentData *getDocument() const override {
|
|
|
|
return _content->document();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool needsBubble() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2021-12-31 00:17:34 +01:00
|
|
|
QRect contentRectForReactions() const override;
|
|
|
|
std::optional<int> reactionButtonCenterOverride() const override;
|
2022-01-11 15:13:04 +01:00
|
|
|
QPoint resolveCustomInfoRightBottom() const override;
|
|
|
|
|
2020-06-16 18:53:44 +02:00
|
|
|
void stickerClearLoopPlayed() override {
|
|
|
|
_content->stickerClearLoopPlayed();
|
2019-08-02 17:06:44 +02:00
|
|
|
}
|
2020-07-02 12:44:12 +02:00
|
|
|
std::unique_ptr<Lottie::SinglePlayer> stickerTakeLottie(
|
|
|
|
not_null<DocumentData*> data,
|
|
|
|
const Lottie::ColorReplacements *replacements) override;
|
2019-08-02 17:06:44 +02:00
|
|
|
|
2022-05-19 15:57:39 +02:00
|
|
|
//void externalLottieProgressing(bool external) override;
|
|
|
|
//bool externalLottieTill(ExternalLottieInfo info) override;
|
|
|
|
//ExternalLottieInfo externalLottieInfo() const override;
|
2022-04-26 18:31:10 +02:00
|
|
|
|
2020-05-26 15:40:36 +02:00
|
|
|
bool hasHeavyPart() const override {
|
|
|
|
return _content->hasHeavyPart();
|
2020-03-27 12:40:50 +01:00
|
|
|
}
|
2019-08-02 17:06:44 +02:00
|
|
|
void unloadHeavyPart() override {
|
|
|
|
_content->unloadHeavyPart();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-03-06 08:53:59 +01:00
|
|
|
struct SurroundingInfo {
|
|
|
|
int height = 0;
|
|
|
|
int forwardedHeight = 0;
|
|
|
|
bool forwardedBreakEverywhere = false;
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
return (height > 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
[[nodiscard]] SurroundingInfo surroundingInfo(
|
2019-08-06 11:59:02 +02:00
|
|
|
const HistoryMessageVia *via,
|
2020-03-06 08:53:59 +01:00
|
|
|
const HistoryMessageReply *reply,
|
|
|
|
const HistoryMessageForwarded *forwarded,
|
|
|
|
int outerw) const;
|
2019-08-02 17:06:44 +02:00
|
|
|
void drawSurrounding(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &inner,
|
2021-09-03 00:08:57 +02:00
|
|
|
const PaintContext &context,
|
2019-08-02 17:06:44 +02:00
|
|
|
const HistoryMessageVia *via,
|
2020-03-06 08:53:59 +01:00
|
|
|
const HistoryMessageReply *reply,
|
|
|
|
const HistoryMessageForwarded *forwarded) const;
|
2019-08-02 17:06:44 +02:00
|
|
|
|
|
|
|
QSize countOptimalSize() override;
|
|
|
|
QSize countCurrentSize(int newWidth) override;
|
|
|
|
|
|
|
|
bool needInfoDisplay() const;
|
|
|
|
int additionalWidth(
|
|
|
|
const HistoryMessageVia *via,
|
2020-03-06 08:53:59 +01:00
|
|
|
const HistoryMessageReply *reply,
|
|
|
|
const HistoryMessageForwarded *forwarded) const;
|
2019-08-02 17:06:44 +02:00
|
|
|
|
2020-09-17 18:25:06 +02:00
|
|
|
int calculateFullRight(const QRect &inner) const;
|
|
|
|
QPoint calculateFastActionPosition(
|
2019-08-16 18:52:35 +02:00
|
|
|
int fullBottom,
|
|
|
|
int replyRight,
|
2020-09-17 18:25:06 +02:00
|
|
|
int fullRight,
|
|
|
|
QSize size) const;
|
2019-08-16 18:52:35 +02:00
|
|
|
|
2020-03-06 08:53:59 +01:00
|
|
|
const HistoryMessageForwarded *getDisplayedForwardedInfo() const;
|
|
|
|
|
2019-08-02 17:06:44 +02:00
|
|
|
std::unique_ptr<Content> _content;
|
|
|
|
QSize _contentSize;
|
2022-08-03 19:26:39 +02:00
|
|
|
int _topAdded = 0;
|
|
|
|
bool _additionalOnTop = false;
|
2019-08-02 17:06:44 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace HistoryView
|