From 09a8ade6becca2a71f45ff0db5f4bf6d64afb212 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 21 Apr 2018 03:46:58 +0200 Subject: Add support for static image emoji Emoji are downloaded asynchronously using remote program (curl). Need to add support for converting [inline](url) chat message emoji and gifs. --- src/MessagePart.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/MessagePart.cpp') diff --git a/src/MessagePart.cpp b/src/MessagePart.cpp index ea8e4a5..dcef3f3 100644 --- a/src/MessagePart.cpp +++ b/src/MessagePart.cpp @@ -34,4 +34,28 @@ namespace dchat { return sf::Vector2f(text.getLocalBounds().width, getFontSizeScaled()); } + + MessagePartEmoji::MessagePartEmoji(const string &_url) : + MessagePart(Type::EMOJI), + url(_url) + { + + } + + float MessagePartEmoji::getHeightScaled() + { + return MessagePart::getSizeScaled() * 1.0f; + } + + sf::Vector2f MessagePartEmoji::getPosition() const + { + return sprite.getPosition(); + } + + sf::Vector2f MessagePartEmoji::getSize() const + { + auto spriteScale = sprite.getScale(); + auto textureSize = sprite.getTexture()->getSize(); + return { (float)textureSize.x * spriteScale.x, (float)textureSize.y * spriteScale.y }; + } } -- cgit v1.2.3