aboutsummaryrefslogtreecommitdiff
path: root/include/MessagePart.hpp
blob: d0a0a0337ab5ca1f385d91f26bcf59a6f449a7a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/System/Vector2.hpp>
#include <string>

namespace dchat
{
    class MessagePart
    {
    public:
        enum class Type
        {
            TEXT,
            EMOJI
        };
        
        MessagePart(Type _type) : type(_type) {}
        virtual ~MessagePart(){}
        
        static float getSizeScaled();
        virtual sf::Vector2f getPosition() const = 0;
        virtual sf::Vector2f getSize() const = 0;
        
        const Type type;
    };
    
    class MessagePartText : public MessagePart
    {
    public:
        MessagePartText(const std::string &text);
        
        static float getFontSizeScaled();
        virtual sf::Vector2f getPosition() const override;
        virtual sf::Vector2f getSize() const override;
        
        sf::Text text;
    };
    
    class MessagePartEmoji : public MessagePart
    {
    public:
        MessagePartEmoji(const std::string &url);
        
        static float getHeightScaled();
        virtual sf::Vector2f getPosition() const override;
        virtual sf::Vector2f getSize() const override;
        
        sf::Sprite sprite;
        std::string url;
        bool dirty;
    };
}