aboutsummaryrefslogtreecommitdiff
path: root/src/ChannelSidePanel.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-04-08 21:04:12 +0200
committerdec05eba <dec05eba@protonmail.com>2019-04-08 21:04:17 +0200
commit725ea566a2b6a12e0a02e4f570b6e99102e2d21b (patch)
treed35a338392e15f50402c2055d520e7b1c3ea36a2 /src/ChannelSidePanel.cpp
parent4aac8df198e3a5bd9c6efc95cdf4c520c2e05401 (diff)
Refactor, remove a lot of code and use dchat core instead
Diffstat (limited to 'src/ChannelSidePanel.cpp')
-rw-r--r--src/ChannelSidePanel.cpp93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/ChannelSidePanel.cpp b/src/ChannelSidePanel.cpp
deleted file mode 100644
index 49407cc..0000000
--- a/src/ChannelSidePanel.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "../include/ChannelSidePanel.hpp"
-#include "../include/ChannelTopPanel.hpp"
-#include "../include/ResourceCache.hpp"
-#include "../include/Settings.hpp"
-#include "../include/Channel.hpp"
-#include "../include/ColorScheme.hpp"
-#include <SFML/Graphics/RectangleShape.hpp>
-#include <SFML/Graphics/Text.hpp>
-#include <vector>
-#include <cmath>
-
-using namespace std;
-
-namespace dchat
-{
- static vector<Channel*> channels;
- static sf::Vector2f position;
- const float WIDTH = 300.0f;
- const unsigned int FONT_SIZE = 20;
- const float PADDING_BOTTOM = 10.0f;
- const float CHANNEL_NAME_BOX_HEIGHT_RATIO = 1.5f;
-
- void ChannelSidePanel::addChannel(Channel *channel)
- {
- channels.push_back(channel);
- }
-
- void ChannelSidePanel::removeAllChannels()
- {
- channels.clear();
- }
-
- void ChannelSidePanel::draw(sf::RenderWindow &window)
- {
- float posY = ChannelTopPanel::getHeight();
- auto windowSize = window.getSize();
- sf::RectangleShape rect(sf::Vector2f(getWidth(), windowSize.y));
- rect.setPosition(0.0f, 0.0f);
- rect.setFillColor(ColorScheme::getPanelColor());
- window.draw(rect);
-
- const sf::Font *font = ResourceCache::getFont("fonts/Nunito-Regular.ttf");
- const float fontSize = FONT_SIZE * Settings::getScaling();
- const float fontHeight = font->getLineSpacing(fontSize);
- const float channelBoxHeight = floor(fontHeight * CHANNEL_NAME_BOX_HEIGHT_RATIO);
-
- auto mousePos = sf::Mouse::getPosition(window);
-
- position.y = posY;
- for(Channel *channel : channels)
- {
- sf::FloatRect box(0.0f, position.y, getWidth(), channelBoxHeight);
- if(channel == Channel::getCurrent())
- {
- rect.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(15, 15, 15));
- rect.setSize(sf::Vector2f(box.width, box.height));
- rect.setPosition(sf::Vector2f(0.0f, position.y));
- window.draw(rect);
- }
- else if(box.contains(mousePos.x, mousePos.y))
- {
- rect.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(5, 5, 5));
- rect.setSize(sf::Vector2f(box.width, box.height));
- rect.setPosition(sf::Vector2f(0.0f, position.y));
- window.draw(rect);
-
- if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
- {
- Channel::setCurrent(channel);
- }
- }
-
- // TODO: Remove this shit
- sf::String str = "# ";
- str += sf::String::fromUtf8(channel->getName().begin(), channel->getName().end());
- sf::Text text(str, *font, fontSize);
- text.setPosition(sf::Vector2f(position.x, floor(position.y + channelBoxHeight * 0.5f - fontHeight * 0.5f)));
- text.setFillColor(ColorScheme::getTextRegularColor());
- window.draw(text);
- position.y += floor(fontHeight + PADDING_BOTTOM);
- }
- }
-
- float ChannelSidePanel::getWidth()
- {
- return floor(WIDTH * Settings::getScaling());
- }
-
- float ChannelSidePanel::getHeight()
- {
- return position.y;
- }
-}