diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-23 18:49:45 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-04-23 18:49:52 +0200 |
commit | 7e7dfd227eacaa80b21ca8ed99e8a99ccbd47769 (patch) | |
tree | 016e3907471ae1b588c35cf963ea2551efc57cfc /src/ChannelSidePanel.cpp | |
parent | 3ab4127ae3fc3b837f5350509c78db03467500cd (diff) |
Add side bar, make submodule public
Diffstat (limited to 'src/ChannelSidePanel.cpp')
-rw-r--r-- | src/ChannelSidePanel.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ChannelSidePanel.cpp b/src/ChannelSidePanel.cpp index 23693b3..3958376 100644 --- a/src/ChannelSidePanel.cpp +++ b/src/ChannelSidePanel.cpp @@ -1,9 +1,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()); + } + } } |