aboutsummaryrefslogtreecommitdiff
path: root/include/MessagePart.hpp
blob: 00544fba0fd7b3b18cd1e862bff9223f266193fa (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
55
#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, bool _newLine) : type(_type), newLine(_newLine) {}
        virtual ~MessagePart(){}
        
        static float getSizeScaled();
        virtual sf::Vector2f getPosition() const = 0;
        virtual sf::Vector2f getSize() const = 0;
        
        const Type type;
        bool newLine;
    };
    
    class MessagePartText : public MessagePart
    {
    public:
        MessagePartText(const std::string &text, bool newLine);
        
        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, bool newLine);
        
        static float getHeightScaled();
        virtual sf::Vector2f getPosition() const override;
        virtual sf::Vector2f getSize() const override;
        
        sf::Sprite sprite;
        std::string url;
        bool dirty;
    };
}