blob: 3958376598a9415a985b59eefd346d42249d0ad1 (
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
|
#include "../include/ChannelSidePanel.hpp"
#include "../include/ResourceCache.hpp"
#include "../include/Settings.hpp"
#include "../include/Channel.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include <cmath>
namespace dchat
{
ChannelSidePanel::ChannelSidePanel(float _width) :
width(floor(_width))
{
}
void ChannelSidePanel::addChannel(Channel *channel)
{
channels.push_back(channel);
}
void ChannelSidePanel::draw(sf::RenderWindow &window)
{
auto windowSize = window.getSize();
sf::RectangleShape rect(sf::Vector2f(width, windowSize.y));
rect.setFillColor(sf::Color(30, 30, 30));
window.draw(rect);
const sf::Font &font = ResourceCache::getFont("fonts/Roboto-Regular.ttf");
sf::Vector2f position;
for(Channel *channel : channels)
{
// TODO: Remove this shit
sf::String str = "# ";
str += sf::String::fromUtf8(channel->getName().begin(), channel->getName().end());
sf::Text text(str, font, 24 * Settings::getScaling());
text.setPosition(position);
window.draw(text);
position.y += font.getLineSpacing(24 * Settings::getScaling());
}
}
}
|