Formalize zero-width emote implementation (#4314)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Daniel Sage
2023-03-18 12:30:08 -04:00
committed by GitHub
parent db97a14cdc
commit 0acbc0d2c3
18 changed files with 947 additions and 146 deletions
+38 -3
View File
@@ -141,9 +141,7 @@ enum class MessageElementFlag : int64_t {
LowercaseLink = (1LL << 29),
OriginalLink = (1LL << 30),
// ZeroWidthEmotes are emotes that are supposed to overlay over any pre-existing emotes
// e.g. BTTV's SoSnowy during christmas season or 7TV's RainTime
ZeroWidthEmote = (1LL << 31),
// Unused: (1LL << 31)
// for elements of the message reply
RepliedMessage = (1LL << 32),
@@ -321,6 +319,43 @@ private:
EmotePtr emote_;
};
// A LayeredEmoteElement represents multiple Emotes layered on top of each other.
// This class takes care of rendering animated and non-animated emotes in the
// correct order and aligning them in the right way.
class LayeredEmoteElement : public MessageElement
{
public:
LayeredEmoteElement(
std::vector<EmotePtr> &&emotes, MessageElementFlags flags,
const MessageColor &textElementColor = MessageColor::Text);
void addEmoteLayer(const EmotePtr &emote);
void addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags) override;
// Returns a concatenation of each emote layer's cleaned copy string
QString getCleanCopyString() const;
const std::vector<EmotePtr> &getEmotes() const;
std::vector<EmotePtr> getUniqueEmotes() const;
const std::vector<QString> &getEmoteTooltips() const;
private:
MessageLayoutElement *makeImageLayoutElement(
const std::vector<ImagePtr> &image, const std::vector<QSize> &sizes,
QSize largestSize);
QString getCopyString() const;
void updateTooltips();
std::vector<ImagePtr> getLoadedImages(float scale);
std::vector<EmotePtr> emotes_;
std::vector<QString> emoteTooltips_;
std::unique_ptr<TextElement> textElement_;
MessageColor textElementColor_;
};
class BadgeElement : public MessageElement
{
public: