aboutsummaryrefslogtreecommitdiff
path: root/src/MessagePart.cpp
blob: 47c96bdc66b149a5641da4f9b056dbe115bd0d1a (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
#include "../include/MessagePart.hpp"
#include "../include/ResourceCache.hpp"
#include "../include/Settings.hpp"

using namespace std;

namespace dchat
{
    const float MESSAGE_PART_SIZE = 27;
    
    float MessagePart::getSizeScaled()
    {
        return MESSAGE_PART_SIZE * Settings::getScaling();
    }
    
    MessagePartText::MessagePartText(const string &_text) : 
        MessagePart(Type::TEXT),
        text(_text, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), MessagePartText::getFontSizeScaled())
    {
        
    }
    
    float MessagePartText::getFontSizeScaled()
    {
        return MessagePart::getSizeScaled() * 0.8f;
    }
    
    sf::Vector2f MessagePartText::getPosition() const
    {
        return text.getPosition();
    }
    
    sf::Vector2f MessagePartText::getSize() const
    {
        return sf::Vector2f(text.getLocalBounds().width, getFontSizeScaled());
    }
}