diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-29 09:31:06 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-04-29 09:31:10 +0200 |
commit | e7caed2208893723181892d5e197b924311373fb (patch) | |
tree | 1a92cd65f23537eb57b4d80646e84bd359bc0ee2 /src/MessageBoard.cpp | |
parent | f90a5705bd65a4ebb5edc9df003a383039fec555 (diff) |
Improve scaling, start implementing color scheme
Diffstat (limited to 'src/MessageBoard.cpp')
-rw-r--r-- | src/MessageBoard.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp index 58d54f2..fbc7484 100644 --- a/src/MessageBoard.cpp +++ b/src/MessageBoard.cpp @@ -5,6 +5,7 @@ #include "../include/ChannelSidePanel.hpp" #include "../include/UsersSidePanel.hpp" #include "../include/ChannelTopPanel.hpp" +#include "../include/ColorScheme.hpp" #include <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/Sprite.hpp> #include <SFML/Window/Mouse.hpp> @@ -21,7 +22,6 @@ namespace dchat sf::Color sideColor, centerColor; }; - const sf::Color BACKGROUND_COLOR(40, 40, 40); const float USERNAME_PADDING_BOTTOM = 0.0f; const float MESSAGE_PADDING_TOP = 25.0f; const float MESSAGE_PADDING_BOTTOM = 30.0f; @@ -33,8 +33,8 @@ namespace dchat const LineColor LINE_COLOR { - .sideColor = sf::Color(50, 50, 50), - .centerColor = sf::Color(50, 50, 50) + .sideColor = ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10), + .centerColor = ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10) }; static void drawGradientLine(const sf::Vector2f &position, const sf::Vector2f &size, const LineColor &color, sf::RenderWindow &window) @@ -133,7 +133,7 @@ namespace dchat void MessageBoard::draw(sf::RenderWindow &window, Cache &cache) { auto windowSize = window.getSize(); - const float backgroundWidthWithoutPadding = floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()); + sf::Vector2f backgroundSizeWithoutPadding(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(windowSize.y - ChannelTopPanel::getHeight())); sf::Vector2u backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * 2.0f), floor(windowSize.y)); //if(backgroundSize != staticContentTexture.getSize()) @@ -144,6 +144,11 @@ namespace dchat //if(dirty) // staticContentTexture.clear(BACKGROUND_COLOR); + sf::RectangleShape backgroundRect(backgroundSizeWithoutPadding); + backgroundRect.setFillColor(ColorScheme::getBackgroundColor()); + backgroundRect.setPosition(ChannelSidePanel::getWidth(), ChannelTopPanel::getHeight()); + window.draw(backgroundRect); + const sf::Font *usernameFont = ResourceCache::getFont("fonts/Roboto-Regular.ttf"); double deltaTimeMicro = (double)frameTimer.getElapsedTime().asMicroseconds(); @@ -177,7 +182,7 @@ namespace dchat position.y += message->text.getHeight() + MESSAGE_PADDING_BOTTOM; if(position.y + LINE_HEIGHT > 0.0f && position.y < backgroundSize.y) - drawGradientLine(sf::Vector2f(position.x + LINE_SIDE_PADDING, floor(position.y)), sf::Vector2f(backgroundWidthWithoutPadding - LINE_SIDE_PADDING * 2.0f, LINE_HEIGHT), LINE_COLOR, window); + drawGradientLine(sf::Vector2f(position.x + LINE_SIDE_PADDING, floor(position.y)), sf::Vector2f(backgroundSizeWithoutPadding.x - LINE_SIDE_PADDING * 2.0f, LINE_HEIGHT), LINE_COLOR, window); } } |