2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Implement basic effect animation.

This commit is contained in:
John Preston
2024-05-07 14:58:03 +04:00
parent f762634036
commit a19e71324b
19 changed files with 258 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "data/data_file_origin.h"
#include "data/data_peer_values.h"
#include "data/data_saved_sublist.h"
#include "data/stickers/data_custom_emoji.h"
@@ -594,6 +595,9 @@ void Reactions::preloadImageFor(const ReactionId &id) {
} else {
generateImage(set, i->title);
}
if (set.effect) {
preloadEffect(*i);
}
} else if (set.effect && !_waitingForEffects) {
_waitingForEffects = true;
refreshEffects();
@@ -603,6 +607,15 @@ void Reactions::preloadImageFor(const ReactionId &id) {
}
}
void Reactions::preloadEffect(const Reaction &effect) {
if (effect.aroundAnimation) {
effect.aroundAnimation->createMediaView()->checkStickerLarge();
} else {
const auto premium = effect.selectAnimation;
premium->loadVideoThumbnail(premium->stickerSetOrigin());
}
}
void Reactions::preloadAnimationsFor(const ReactionId &id) {
const auto custom = id.custom();
const auto document = custom ? _owner->document(custom).get() : nullptr;

View File

@@ -212,6 +212,7 @@ private:
[[nodiscard]] std::optional<Reaction> parse(
const MTPAvailableEffect &entry);
void preloadEffect(const Reaction &effect);
void preloadImageFor(const ReactionId &id);
[[nodiscard]] QImage resolveImageFor(const ReactionId &id);
void loadImage(

View File

@@ -321,6 +321,8 @@ enum class MessageFlag : uint64 {
ReactionsAreTags = (1ULL << 43),
ShortcutMessage = (1ULL << 44),
EffectWatchedLocal = (1ULL << 45),
};
inline constexpr bool is_flag_type(MessageFlag) { return true; }
using MessageFlags = base::flags<MessageFlag>;