aboutsummaryrefslogtreecommitdiff
path: root/src/Chatbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Chatbar.cpp')
-rw-r--r--src/Chatbar.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp
index 8c4083b..e88986a 100644
--- a/src/Chatbar.cpp
+++ b/src/Chatbar.cpp
@@ -5,6 +5,7 @@
#include "../include/ChannelSidePanel.hpp"
#include "../include/UsersSidePanel.hpp"
#include "../include/Command.hpp"
+#include "../include/ColorScheme.hpp"
#include <cmath>
#include <cstring>
#include <process.hpp>
@@ -13,12 +14,14 @@ using namespace std;
namespace dchat
{
- const float FONT_SIZE = 24;
+ const float FONT_SIZE = 20;
const float BOX_PADDING_X = 15.0f;
const float BOX_PADDING_Y = 5.0f;
const int BLINK_TIME_VISIBLE_MS = 500;
const int BLINK_TIME_INVISIBLE_MS = 500;
const float PADDING_SIDE = 20.0f;
+ const float PADDING_TOP = 30.0f;
+ const float PADDING_BOTTOM = 30.0f;
Chatbar::Chatbar() :
text("", *ResourceCache::getFont("fonts/Roboto-Regular.ttf"), FONT_SIZE * Settings::getScaling()),
@@ -26,7 +29,8 @@ namespace dchat
focused(true)
{
text.setFillColor(sf::Color(240, 240, 240));
- background.setFillColor(sf::Color(60, 60, 60));
+ background.setFillColor(ColorScheme::getBackgroundColor());
+ inputBackground.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(10, 10, 10));
}
void Chatbar::addChar(sf::Uint32 codePoint)
@@ -268,20 +272,28 @@ namespace dchat
{
auto windowSize = window.getSize();
- sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * 2.0f), floor(text.getCharacterSize() * 1.7f + BOX_PADDING_Y * 2.0f));
- sf::Vector2f backgroundPos(floor(ChannelSidePanel::getWidth() + PADDING_SIDE), floor(windowSize.y - backgroundSize.y - 20.0f));
- background.setSize(backgroundSize);
- background.setPosition(backgroundPos);
- text.setPosition(floor(backgroundPos.x + BOX_PADDING_X), floor(backgroundPos.y + backgroundSize.y * 0.5f - text.getCharacterSize() * 0.5f));
+ text.setCharacterSize(FONT_SIZE * Settings::getScaling());
+ const float fontHeight = text.getFont()->getLineSpacing(text.getCharacterSize());
+ sf::Vector2f inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * 2.0f), floor(fontHeight * 1.7f + BOX_PADDING_Y * 2.0f));
+ sf::Vector2f backgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth()), floor(PADDING_TOP + inputBackgroundSize.y + PADDING_BOTTOM));
+ background.setSize(backgroundSize);
+ background.setPosition(ChannelSidePanel::getWidth(), floor(windowSize.y - backgroundSize.y));
window.draw(background);
+
+ sf::Vector2f inputBackgroundPos(floor(ChannelSidePanel::getWidth() + PADDING_SIDE), floor(windowSize.y - inputBackgroundSize.y - PADDING_BOTTOM));
+ inputBackground.setSize(inputBackgroundSize);
+ inputBackground.setPosition(inputBackgroundPos);
+ text.setPosition(floor(inputBackgroundPos.x + BOX_PADDING_X), floor(inputBackgroundPos.y + inputBackgroundSize.y * 0.5f - fontHeight * 0.5f));
+
+ window.draw(inputBackground);
window.draw(text);
int blinkElapsedTime = blinkTimer.getElapsedTime().asMilliseconds();
if(focused && blinkElapsedTime <= BLINK_TIME_VISIBLE_MS)
{
- sf::RectangleShape caretShape(sf::Vector2f(2.0f, backgroundSize.y - BOX_PADDING_Y * 2.0f));
- caretShape.setPosition(floor(text.getPosition().x + caretOffset.x), (caretOffset.y + backgroundPos.y + BOX_PADDING_Y));
+ sf::RectangleShape caretShape(sf::Vector2f(2.0f, inputBackgroundSize.y - BOX_PADDING_Y * 2.0f));
+ caretShape.setPosition(floor(text.getPosition().x + caretOffset.x), floor(caretOffset.y + inputBackgroundPos.y + BOX_PADDING_Y));
window.draw(caretShape);
}