From 7e7dfd227eacaa80b21ca8ed99e8a99ccbd47769 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 23 Apr 2018 18:49:45 +0200 Subject: Add side bar, make submodule public --- src/ChannelSidePanel.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/ChannelSidePanel.cpp') 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 +#include +#include 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()); + } + } } -- cgit v1.2.3