2016-04-04 21:09:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-04 21:09:46 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2016-04-04 21:09:46 +00:00
|
|
|
#include "inline_bots/inline_bot_layout_item.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "media/clip/media_clip_reader.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2016-09-28 10:15:03 +00:00
|
|
|
#include "ui/effects/radial_animation.h"
|
2016-04-14 11:00:23 +00:00
|
|
|
#include "ui/text/text.h"
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2019-07-02 13:41:50 +00:00
|
|
|
namespace Lottie {
|
|
|
|
class SinglePlayer;
|
|
|
|
} // namespace Lottie
|
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
namespace Data {
|
2020-05-25 14:16:04 +00:00
|
|
|
class PhotoMedia;
|
2020-04-08 15:09:29 +00:00
|
|
|
class DocumentMedia;
|
|
|
|
} // namespace Data
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
namespace InlineBots {
|
|
|
|
namespace Layout {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class FileBase : public ItemBase {
|
|
|
|
public:
|
2018-06-28 15:01:32 +00:00
|
|
|
FileBase(not_null<Context*> context, not_null<Result*> result);
|
2020-05-25 14:16:04 +00:00
|
|
|
|
|
|
|
// For saved gif layouts.
|
|
|
|
FileBase(not_null<Context*> context, not_null<DocumentData*> document);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
DocumentData *getShownDocument() const;
|
|
|
|
|
|
|
|
int content_width() const;
|
|
|
|
int content_height() const;
|
|
|
|
int content_duration() const;
|
2020-04-15 14:06:34 +00:00
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DeleteSavedGifClickHandler : public LeftButtonClickHandler {
|
|
|
|
public:
|
2020-06-09 09:36:40 +00:00
|
|
|
DeleteSavedGifClickHandler(not_null<DocumentData*> data) : _data(data) {
|
2016-04-04 21:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
private:
|
2020-06-09 09:36:40 +00:00
|
|
|
const not_null<DocumentData*> _data;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
class Gif final : public FileBase {
|
2016-04-04 21:09:46 +00:00
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Gif(not_null<Context*> context, not_null<Result*> result);
|
|
|
|
Gif(
|
|
|
|
not_null<Context*> context,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
bool hasDeleteButton);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void setPosition(int32 position) override;
|
|
|
|
void initDimensions() override;
|
|
|
|
|
|
|
|
bool isFullLine() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool hasRightSkip() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
// ClickHandlerHost interface
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
|
2017-12-18 14:10:24 +00:00
|
|
|
int resizeGetHeight(int width) override;
|
2017-11-14 10:26:12 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
void unloadHeavyPart() override;
|
2020-03-16 13:38:36 +00:00
|
|
|
|
2022-02-13 22:40:34 +00:00
|
|
|
QRect innerContentRect() const override;
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
private:
|
|
|
|
enum class StateFlag {
|
2020-04-08 15:09:29 +00:00
|
|
|
Over = (1 << 0),
|
2017-09-03 18:36:06 +00:00
|
|
|
DeleteOver = (1 << 1),
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
2017-08-31 16:28:58 +00:00
|
|
|
using StateFlags = base::flags<StateFlag>;
|
|
|
|
friend inline constexpr auto is_flag_type(StateFlag) { return true; };
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
struct AnimationData {
|
|
|
|
template <typename Callback>
|
|
|
|
AnimationData(Callback &&callback)
|
|
|
|
: radial(std::forward<Callback>(callback)) {
|
|
|
|
}
|
|
|
|
bool over = false;
|
|
|
|
Ui::Animations::Simple _a_over;
|
|
|
|
Ui::RadialAnimation radial;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ensureDataMediaCreated(not_null<DocumentData*> document) const;
|
|
|
|
QSize countFrameSize() const;
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
void validateThumbnail(
|
|
|
|
Image *image,
|
|
|
|
QSize size,
|
|
|
|
QSize frame,
|
|
|
|
bool good) const;
|
|
|
|
void prepareThumbnail(QSize size, QSize frame) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void ensureAnimation() const;
|
2019-04-04 15:24:13 +00:00
|
|
|
bool isRadialAnimation() const;
|
|
|
|
void radialAnimationCallback(crl::time now) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2016-06-24 10:37:29 +00:00
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
StateFlags _state;
|
|
|
|
|
|
|
|
Media::Clip::ReaderPointer _gif;
|
|
|
|
ClickHandlerPtr _delete;
|
2022-08-04 10:35:08 +00:00
|
|
|
mutable QImage _thumb;
|
2020-04-08 15:09:29 +00:00
|
|
|
mutable bool _thumbGood = false;
|
|
|
|
|
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<AnimationData> _animation;
|
2019-04-02 09:13:30 +00:00
|
|
|
mutable Ui::Animations::Simple _a_deleteOver;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Photo : public ItemBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Photo(not_null<Context*> context, not_null<Result*> result);
|
2016-04-04 21:09:46 +00:00
|
|
|
// Not used anywhere currently.
|
2020-05-25 14:16:04 +00:00
|
|
|
//Photo(not_null<Context*> context, not_null<PhotoData*> photo);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
|
|
|
bool isFullLine() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool hasRightSkip() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
void unloadHeavyPart() override;
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
private:
|
|
|
|
PhotoData *getShownPhoto() const;
|
|
|
|
|
|
|
|
QSize countFrameSize() const;
|
|
|
|
|
|
|
|
mutable QPixmap _thumb;
|
2019-01-25 14:37:28 +00:00
|
|
|
mutable bool _thumbGood = false;
|
|
|
|
void prepareThumbnail(QSize size, QSize frame) const;
|
|
|
|
void validateThumbnail(
|
|
|
|
Image *image,
|
|
|
|
QSize size,
|
|
|
|
QSize frame,
|
|
|
|
bool good) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
mutable std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Sticker : public FileBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Sticker(not_null<Context*> context, not_null<Result*> result);
|
2019-07-02 13:41:50 +00:00
|
|
|
~Sticker();
|
2016-04-04 21:09:46 +00:00
|
|
|
// Not used anywhere currently.
|
2020-05-25 14:16:04 +00:00
|
|
|
//Sticker(not_null<Context*> context, not_null<DocumentData*> document);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
|
|
|
bool isFullLine() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool hasRightSkip() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void preload() const override;
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
// ClickHandlerHost interface
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
void unloadHeavyPart() override;
|
|
|
|
|
2022-02-11 04:40:11 +00:00
|
|
|
QRect innerContentRect() const override;
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
private:
|
2020-04-09 08:15:47 +00:00
|
|
|
void ensureDataMediaCreated(not_null<DocumentData*> document) const;
|
2020-04-09 12:27:53 +00:00
|
|
|
void setupLottie() const;
|
2022-01-25 09:27:33 +00:00
|
|
|
void setupWebm() const;
|
2016-04-04 21:09:46 +00:00
|
|
|
QSize getThumbSize() const;
|
2022-01-25 09:27:33 +00:00
|
|
|
QSize boundingBox() const;
|
2019-07-02 13:41:50 +00:00
|
|
|
void prepareThumbnail() const;
|
2022-01-25 09:27:33 +00:00
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
mutable Ui::Animations::Simple _a_over;
|
2016-04-04 21:09:46 +00:00
|
|
|
mutable bool _active = false;
|
|
|
|
|
|
|
|
mutable QPixmap _thumb;
|
|
|
|
mutable bool _thumbLoaded = false;
|
2019-07-02 13:41:50 +00:00
|
|
|
|
|
|
|
mutable std::unique_ptr<Lottie::SinglePlayer> _lottie;
|
2022-01-25 09:27:33 +00:00
|
|
|
Media::Clip::ReaderPointer _webm;
|
2020-04-09 08:15:47 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
2019-07-02 13:41:50 +00:00
|
|
|
mutable rpl::lifetime _lifetime;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Video : public FileBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Video(not_null<Context*> context, not_null<Result*> result);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
void unloadHeavyPart() override;
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
private:
|
|
|
|
ClickHandlerPtr _link;
|
|
|
|
|
|
|
|
mutable QPixmap _thumb;
|
2020-04-15 14:06:34 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2016-04-04 21:09:46 +00:00
|
|
|
QString _duration;
|
2016-04-08 15:37:14 +00:00
|
|
|
int _durationWidth = 0;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2020-04-15 14:06:34 +00:00
|
|
|
[[nodiscard]] bool withThumbnail() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
void prepareThumbnail(QSize size) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class CancelFileClickHandler : public LeftButtonClickHandler {
|
|
|
|
public:
|
2018-06-28 15:01:32 +00:00
|
|
|
CancelFileClickHandler(not_null<Result*> result) : _result(result) {
|
2016-04-04 21:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
private:
|
2018-06-28 15:01:32 +00:00
|
|
|
not_null<Result*> _result;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class File : public FileBase {
|
|
|
|
public:
|
2018-06-28 15:01:32 +00:00
|
|
|
File(not_null<Context*> context, not_null<Result*> result);
|
2020-05-25 14:16:04 +00:00
|
|
|
~File();
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
// ClickHandlerHost interface
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
void unloadHeavyPart() override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
private:
|
2016-12-07 13:32:25 +00:00
|
|
|
void thumbAnimationCallback();
|
2019-04-04 15:24:13 +00:00
|
|
|
void radialAnimationCallback(crl::time now) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void ensureAnimation() const;
|
2020-04-10 13:18:51 +00:00
|
|
|
void ensureDataMediaCreated() const;
|
2016-12-09 06:19:55 +00:00
|
|
|
void checkAnimationFinished() const;
|
2016-04-10 18:18:26 +00:00
|
|
|
bool updateStatusText() const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2019-04-04 15:24:13 +00:00
|
|
|
bool isRadialAnimation() const {
|
|
|
|
if (_animation) {
|
|
|
|
if (_animation->radial.animating()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
checkAnimationFinished();
|
|
|
|
}
|
|
|
|
return false;
|
2016-04-04 21:09:46 +00:00
|
|
|
}
|
2019-04-02 09:13:30 +00:00
|
|
|
bool isThumbAnimation() const {
|
2016-12-07 13:32:25 +00:00
|
|
|
if (_animation) {
|
2019-04-02 09:13:30 +00:00
|
|
|
if (_animation->a_thumbOver.animating()) {
|
2016-12-09 06:19:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
checkAnimationFinished();
|
2016-12-07 13:32:25 +00:00
|
|
|
}
|
|
|
|
return false;
|
2016-04-04 21:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct AnimationData {
|
2019-04-01 17:44:54 +00:00
|
|
|
template <typename Callback>
|
|
|
|
AnimationData(Callback &&radialCallback)
|
|
|
|
: radial(std::forward<Callback>(radialCallback)) {
|
2016-04-04 21:09:46 +00:00
|
|
|
}
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple a_thumbOver;
|
2016-09-28 10:15:03 +00:00
|
|
|
Ui::RadialAnimation radial;
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<AnimationData> _animation;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2021-06-14 06:21:56 +00:00
|
|
|
ClickHandlerPtr _cancel;
|
2016-04-10 18:18:26 +00:00
|
|
|
|
|
|
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
|
|
|
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
2022-05-10 14:22:28 +00:00
|
|
|
// 0xFFFFFFF0LL will contain status for not yet downloaded file
|
|
|
|
// 0xFFFFFFF1LL will contain status for already downloaded file
|
|
|
|
// 0xFFFFFFF2LL will contain status for failed to download / upload file
|
|
|
|
mutable int64 _statusSize = 0;
|
2016-04-10 18:18:26 +00:00
|
|
|
mutable QString _statusText;
|
|
|
|
|
|
|
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
2022-05-10 14:22:28 +00:00
|
|
|
void setStatusSize(
|
|
|
|
int64 newSize,
|
|
|
|
int64 fullSize,
|
|
|
|
TimeId duration,
|
|
|
|
TimeId realDuration) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2018-06-28 15:01:32 +00:00
|
|
|
not_null<DocumentData*> _document;
|
2020-04-10 13:18:51 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2018-06-28 15:01:32 +00:00
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
|
|
|
|
2016-04-08 15:37:14 +00:00
|
|
|
class Contact : public ItemBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Contact(not_null<Context*> context, not_null<Result*> result);
|
2016-04-08 15:37:14 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-08 15:37:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
mutable QPixmap _thumb;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2016-04-08 15:37:14 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
void prepareThumbnail(int width, int height) const;
|
2016-04-08 15:37:14 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
class Article : public ItemBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Article(not_null<Context*> context, not_null<Result*> result, bool withThumb);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
2016-04-08 15:37:14 +00:00
|
|
|
int resizeGetHeight(int width) override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2016-04-13 18:29:32 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ClickHandlerPtr _url, _link;
|
|
|
|
|
|
|
|
bool _withThumb;
|
|
|
|
mutable QPixmap _thumb;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2016-04-05 20:24:27 +00:00
|
|
|
QString _thumbLetter, _urlText;
|
2016-04-04 21:09:46 +00:00
|
|
|
int32 _urlWidth;
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
void prepareThumbnail(int width, int height) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-09-28 16:23:25 +00:00
|
|
|
class Game : public ItemBase {
|
|
|
|
public:
|
2020-05-25 14:16:04 +00:00
|
|
|
Game(not_null<Context*> context, not_null<Result*> result);
|
2016-09-28 16:23:25 +00:00
|
|
|
|
|
|
|
void setPosition(int32 position) override;
|
|
|
|
void initDimensions() override;
|
|
|
|
|
|
|
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-09-28 16:23:25 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
void unloadHeavyPart() override;
|
2020-03-16 13:38:36 +00:00
|
|
|
|
2016-09-28 16:23:25 +00:00
|
|
|
private:
|
2020-05-25 14:16:04 +00:00
|
|
|
void ensureDataMediaCreated(not_null<PhotoData*> photo) const;
|
2020-04-08 15:09:29 +00:00
|
|
|
void ensureDataMediaCreated(not_null<DocumentData*> document) const;
|
2016-09-28 16:23:25 +00:00
|
|
|
void countFrameSize();
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
void prepareThumbnail(QSize size) const;
|
|
|
|
void validateThumbnail(Image *image, QSize size, bool good) const;
|
2016-09-28 16:23:25 +00:00
|
|
|
|
2019-04-04 15:24:13 +00:00
|
|
|
bool isRadialAnimation() const;
|
|
|
|
void radialAnimationCallback(crl::time now) const;
|
2016-09-28 16:23:25 +00:00
|
|
|
|
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
|
|
|
|
2016-09-28 20:28:53 +00:00
|
|
|
Media::Clip::ReaderPointer _gif;
|
2020-05-25 14:16:04 +00:00
|
|
|
mutable std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2022-08-04 10:35:08 +00:00
|
|
|
mutable QImage _thumb;
|
2019-01-25 14:37:28 +00:00
|
|
|
mutable bool _thumbGood = false;
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<Ui::RadialAnimation> _radial;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2016-09-28 16:23:25 +00:00
|
|
|
|
|
|
|
QSize _frameSize;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace Layout
|
|
|
|
} // namespace InlineBots
|