2022-01-11 14:13:04 +00: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 "ui/effects/animations.h"
|
2022-09-06 16:53:42 +00:00
|
|
|
#include "data/data_message_reaction_id.h"
|
2022-01-11 14:13:04 +00:00
|
|
|
|
2022-09-01 09:29:10 +00:00
|
|
|
namespace Ui::Text {
|
|
|
|
class CustomEmoji;
|
2022-10-06 13:06:18 +00:00
|
|
|
struct CustomEmojiColored;
|
2022-09-01 09:29:10 +00:00
|
|
|
} // namespace Ui::Text
|
|
|
|
|
2022-01-11 14:13:04 +00:00
|
|
|
namespace Data {
|
|
|
|
class Reactions;
|
2022-09-06 16:53:42 +00:00
|
|
|
enum class CustomEmojiSizeTag : uchar;
|
2022-01-11 14:13:04 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2022-10-06 13:06:18 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class AnimatedIcon;
|
2022-01-11 14:13:04 +00:00
|
|
|
|
2022-10-06 13:06:18 +00:00
|
|
|
struct ReactionFlyAnimationArgs {
|
2022-09-06 16:53:42 +00:00
|
|
|
::Data::ReactionId id;
|
|
|
|
QImage flyIcon;
|
|
|
|
QRect flyFrom;
|
|
|
|
|
2022-10-06 13:06:18 +00:00
|
|
|
[[nodiscard]] ReactionFlyAnimationArgs translated(QPoint point) const;
|
2022-09-06 16:53:42 +00:00
|
|
|
};
|
|
|
|
|
2022-10-06 13:06:18 +00:00
|
|
|
class ReactionFlyAnimation final {
|
2022-01-11 14:13:04 +00:00
|
|
|
public:
|
2022-10-06 13:06:18 +00:00
|
|
|
ReactionFlyAnimation(
|
2022-01-11 14:13:04 +00:00
|
|
|
not_null<::Data::Reactions*> owner,
|
2022-10-06 13:06:18 +00:00
|
|
|
ReactionFlyAnimationArgs &&args,
|
2022-01-11 14:13:04 +00:00
|
|
|
Fn<void()> repaint,
|
2022-09-06 16:53:42 +00:00
|
|
|
int size,
|
|
|
|
Data::CustomEmojiSizeTag customSizeTag = {});
|
2022-10-06 13:06:18 +00:00
|
|
|
~ReactionFlyAnimation();
|
2022-01-11 14:13:04 +00:00
|
|
|
|
|
|
|
void setRepaintCallback(Fn<void()> repaint);
|
2022-09-01 12:49:25 +00:00
|
|
|
QRect paintGetArea(
|
|
|
|
QPainter &p,
|
|
|
|
QPoint origin,
|
|
|
|
QRect target,
|
2022-09-06 16:53:42 +00:00
|
|
|
const QColor &colored,
|
|
|
|
QRect clip,
|
2022-09-01 12:49:25 +00:00
|
|
|
crl::time now) const;
|
2022-01-11 14:13:04 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool flying() const;
|
2022-01-16 11:11:50 +00:00
|
|
|
[[nodiscard]] float64 flyingProgress() const;
|
2022-01-28 12:13:49 +00:00
|
|
|
[[nodiscard]] bool finished() const;
|
2022-01-11 14:13:04 +00:00
|
|
|
|
|
|
|
private:
|
2022-09-01 12:49:25 +00:00
|
|
|
struct Parabolic {
|
|
|
|
float64 a = 0.;
|
|
|
|
float64 b = 0.;
|
|
|
|
std::optional<int> key;
|
|
|
|
};
|
|
|
|
struct MiniCopy {
|
|
|
|
mutable Parabolic cached;
|
|
|
|
float64 maxScale = 1.;
|
|
|
|
float64 duration = 1.;
|
|
|
|
int flyUp = 0;
|
|
|
|
int finalX = 0;
|
|
|
|
int finalY = 0;
|
|
|
|
};
|
|
|
|
|
2022-09-01 09:29:10 +00:00
|
|
|
[[nodiscard]] auto flyCallback();
|
|
|
|
[[nodiscard]] auto callback();
|
2022-01-11 14:13:04 +00:00
|
|
|
void startAnimations();
|
2022-09-01 12:49:25 +00:00
|
|
|
int computeParabolicTop(
|
|
|
|
Parabolic &cache,
|
|
|
|
int from,
|
|
|
|
int to,
|
|
|
|
int top,
|
|
|
|
float64 progress) const;
|
2022-09-06 16:53:42 +00:00
|
|
|
void paintCenterFrame(
|
|
|
|
QPainter &p,
|
|
|
|
QRect target,
|
|
|
|
const QColor &colored,
|
|
|
|
crl::time now) const;
|
|
|
|
void paintMiniCopies(
|
|
|
|
QPainter &p,
|
|
|
|
QPoint center,
|
|
|
|
const QColor &colored,
|
|
|
|
crl::time now) const;
|
2022-09-01 12:49:25 +00:00
|
|
|
void generateMiniCopies(int size);
|
2022-01-11 14:13:04 +00:00
|
|
|
|
|
|
|
const not_null<::Data::Reactions*> _owner;
|
|
|
|
Fn<void()> _repaint;
|
2022-08-29 13:54:56 +00:00
|
|
|
QImage _flyIcon;
|
2022-10-06 13:06:18 +00:00
|
|
|
std::unique_ptr<Text::CustomEmoji> _custom;
|
|
|
|
std::unique_ptr<Text::CustomEmojiColored> _colored;
|
|
|
|
std::unique_ptr<AnimatedIcon> _center;
|
|
|
|
std::unique_ptr<AnimatedIcon> _effect;
|
2022-09-01 12:49:25 +00:00
|
|
|
std::vector<MiniCopy> _miniCopies;
|
2022-10-06 13:06:18 +00:00
|
|
|
Animations::Simple _fly;
|
|
|
|
Animations::Simple _minis;
|
2022-01-11 14:13:04 +00:00
|
|
|
QRect _flyFrom;
|
2022-08-30 06:52:42 +00:00
|
|
|
float64 _centerSizeMultiplier = 0.;
|
2022-09-01 12:49:25 +00:00
|
|
|
int _customSize = 0;
|
2022-01-11 14:13:04 +00:00
|
|
|
bool _valid = false;
|
|
|
|
|
2022-09-01 12:49:25 +00:00
|
|
|
mutable Parabolic _cached;
|
2022-01-12 11:41:33 +00:00
|
|
|
|
2022-01-11 14:13:04 +00:00
|
|
|
};
|
|
|
|
|
2022-10-06 13:06:18 +00:00
|
|
|
} // namespace Ui
|