From 4aac8df198e3a5bd9c6efc95cdf4c520c2e05401 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 30 Mar 2019 19:09:23 +0100 Subject: Move users to left side --- debug.sh | 6 ++++++ depends/odhtdb | 2 +- include/ChannelSidePanel.hpp | 1 + src/ChannelSidePanel.cpp | 10 ++++++++-- src/ChannelTopPanel.cpp | 2 +- src/Chatbar.cpp | 8 ++++---- src/MessageBoard.cpp | 6 +++--- src/UsersSidePanel.cpp | 9 +++------ src/main.cpp | 2 +- 9 files changed, 28 insertions(+), 18 deletions(-) create mode 100755 debug.sh diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..a973101 --- /dev/null +++ b/debug.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +sibs build +LD_PRELOAD=/lib/libSegFault.so ./sibs-build/debug/dchat diff --git a/depends/odhtdb b/depends/odhtdb index 109108c..e673a8d 160000 --- a/depends/odhtdb +++ b/depends/odhtdb @@ -1 +1 @@ -Subproject commit 109108c896f1ada76121330ab01602072f32dd8c +Subproject commit e673a8de53278814a860e9eba03ef776be0a4169 diff --git a/include/ChannelSidePanel.hpp b/include/ChannelSidePanel.hpp index 9cee907..265ee67 100644 --- a/include/ChannelSidePanel.hpp +++ b/include/ChannelSidePanel.hpp @@ -14,5 +14,6 @@ namespace dchat static void draw(sf::RenderWindow &window); static float getWidth(); + static float getHeight(); }; } diff --git a/src/ChannelSidePanel.cpp b/src/ChannelSidePanel.cpp index 524e504..49407cc 100644 --- a/src/ChannelSidePanel.cpp +++ b/src/ChannelSidePanel.cpp @@ -13,7 +13,8 @@ using namespace std; namespace dchat { - vector channels; + static vector channels; + static sf::Vector2f position; const float WIDTH = 300.0f; const unsigned int FONT_SIZE = 20; const float PADDING_BOTTOM = 10.0f; @@ -45,7 +46,7 @@ namespace dchat auto mousePos = sf::Mouse::getPosition(window); - sf::Vector2f position(10.0f, posY); + position.y = posY; for(Channel *channel : channels) { sf::FloatRect box(0.0f, position.y, getWidth(), channelBoxHeight); @@ -84,4 +85,9 @@ namespace dchat { return floor(WIDTH * Settings::getScaling()); } + + float ChannelSidePanel::getHeight() + { + return position.y; + } } diff --git a/src/ChannelTopPanel.cpp b/src/ChannelTopPanel.cpp index 9d4869e..ec02651 100644 --- a/src/ChannelTopPanel.cpp +++ b/src/ChannelTopPanel.cpp @@ -51,7 +51,7 @@ namespace dchat window.draw(rect); sf::Vector2f bottomLinePos(floor(ChannelSidePanel::getWidth() + PADDING_SIDE * Settings::getScaling()), getHeight() - BOTTOM_LINE_HEIGHT); - sf::Vector2f bottomLineSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), BOTTOM_LINE_HEIGHT); + sf::Vector2f bottomLineSize(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), BOTTOM_LINE_HEIGHT); LineColor lineColor; lineColor.sideColor = lineSideColor; diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp index a3e1d0f..6a459cc 100644 --- a/src/Chatbar.cpp +++ b/src/Chatbar.cpp @@ -197,13 +197,13 @@ namespace dchat text.setCharacterSize(FONT_SIZE * Settings::getScaling()); const float fontHeight = text.getFont()->getLineSpacing(text.getCharacterSize()); - sf::RectangleShape lineShape(sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - LINE_PADDING_SIDE * Settings::getScaling() * 2.0f), LINE_HEIGHT)); + sf::RectangleShape lineShape(sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - LINE_PADDING_SIDE * Settings::getScaling() * 2.0f), LINE_HEIGHT)); lineShape.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10)); lineShape.setPosition(ChannelSidePanel::getWidth() + LINE_PADDING_SIDE * Settings::getScaling(), floor(windowSize.y - getHeight())); window.draw(lineShape); - sf::Vector2f inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f)); - sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(getHeight() - LINE_HEIGHT)); + sf::Vector2f inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f)); + sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth()), floor(getHeight() - LINE_HEIGHT)); background.setSize(backgroundSize); background.setPosition(ChannelSidePanel::getWidth(), floor(windowSize.y - backgroundSize.y)); window.draw(background); @@ -229,7 +229,7 @@ namespace dchat auto windowSize = window.getSize(); const float fontSize = FONT_SIZE * Settings::getScaling(); const float fontHeight = ResourceCache::getFont("fonts/Nunito-Regular.ttf")->getLineSpacing(fontSize); - return { floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f) }; + return { floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f) }; } float Chatbar::getHeight() diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp index 2c89be3..4366d9b 100644 --- a/src/MessageBoard.cpp +++ b/src/MessageBoard.cpp @@ -385,8 +385,8 @@ namespace dchat void MessageBoard::draw(sf::RenderWindow &window, Cache &cache) { auto windowSize = window.getSize(); - backgroundSizeWithoutPadding = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight())); - backgroundSize = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight() - PADDING_TOP)); + backgroundSizeWithoutPadding = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth()), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight())); + backgroundSize = sf::Vector2f(floor(windowSize.x - ChannelSidePanel::getWidth() - PADDING_SIDE * Settings::getScaling() * 2.0f), floor(windowSize.y - ChannelTopPanel::getHeight() - Chatbar::getHeight() - PADDING_TOP)); backgroundPos = sf::Vector2f(ChannelSidePanel::getWidth(), ChannelTopPanel::getHeight()); //if(backgroundSize != staticContentTexture.getSize()) @@ -459,7 +459,7 @@ namespace dchat scrollbar.maxScroll = totalHeight; scrollbar.width = 10.0f * Settings::getScaling(); scrollbar.maxHeight = (float)backgroundSize.y; - scrollbar.position.x = windowSize.x - UsersSidePanel::getWidth() - scrollbar.width; + scrollbar.position.x = windowSize.x - scrollbar.width; scrollbar.position.y = backgroundPos.y; scrollbar.draw(window); scroll = scrollbar.getScrollingForContent(); diff --git a/src/UsersSidePanel.cpp b/src/UsersSidePanel.cpp index b1f7843..7d7970f 100644 --- a/src/UsersSidePanel.cpp +++ b/src/UsersSidePanel.cpp @@ -1,5 +1,6 @@ #include "../include/UsersSidePanel.hpp" #include "../include/ChannelTopPanel.hpp" +#include "../include/ChannelSidePanel.hpp" #include "../include/ResourceCache.hpp" #include "../include/Settings.hpp" #include "../include/Channel.hpp" @@ -74,18 +75,14 @@ namespace dchat void UsersSidePanel::draw(sf::RenderWindow &window, Cache &cache) { - float posY = ChannelTopPanel::getHeight(); auto windowSize = window.getSize(); - sf::RectangleShape rect(sf::Vector2f(getWidth(), windowSize.y - ChannelTopPanel::getHeight())); - rect.setFillColor(ColorScheme::getBackgroundColor()); - rect.setPosition(windowSize.x - getWidth(), posY); - window.draw(rect); // TODO: Remove this? + float posY = std::min((windowSize.y - ChannelTopPanel::getHeight()) * 0.5f, ChannelSidePanel::getHeight()); Channel *currentChannel = Channel::getCurrent(); if(!currentChannel) return; const sf::Font *font = ResourceCache::getFont("fonts/Nunito-Regular.ttf"); - sf::Vector2f position(rect.getPosition().x + 10.0f, posY); + sf::Vector2f position(10.0f, posY); const float textHeight = font->getLineSpacing(FONT_SIZE * Settings::getScaling()); diff --git a/src/main.cpp b/src/main.cpp index 77b1d5c..15c02ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -353,7 +353,7 @@ int main(int argc, char **argv) } } }; - database = odhtdb::Database::connect("83.252.53.188", 27130, Cache::getDchatDir(), callbackFuncs).get(); + database = odhtdb::Database::connect("127.0.0.1", 27130, Cache::getDchatDir(), callbackFuncs).get(); auto addSystemMessage = [&lastFocusedTimer](const std::string &msg, bool plainText = true) { -- cgit v1.2.3