aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-01 16:34:49 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-01 16:34:54 +0200
commit90460867d4bff46cca0033c06475ffd2b4ac49b7 (patch)
treed1875aff157f390f5c1000ba516d73b29fa76f6f
parentbcb4458ae65545d67c047037082dea0e7701f749 (diff)
Improve scaling, give ui more space
-rw-r--r--src/Chatbar.cpp12
-rw-r--r--src/MessageBoard.cpp4
-rw-r--r--src/Settings.cpp2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp
index a711d9f..950734d 100644
--- a/src/Chatbar.cpp
+++ b/src/Chatbar.cpp
@@ -14,7 +14,7 @@ using namespace std;
namespace dchat
{
- const float FONT_SIZE = 20;
+ const float FONT_SIZE = 18;
const float BOX_PADDING_X = 15.0f;
const float BOX_PADDING_Y = 5.0f;
const int BLINK_TIME_VISIBLE_MS = 500;
@@ -282,13 +282,13 @@ namespace dchat
lineShape.setPosition(ChannelSidePanel::getWidth() + LINE_PADDING_SIDE, floor(windowSize.y - getHeight()));
window.draw(lineShape);
- 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 inputBackgroundSize(floor(windowSize.x - ChannelSidePanel::getWidth() - UsersSidePanel::getWidth() - PADDING_SIDE * 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));
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));
+ sf::Vector2f inputBackgroundPos(floor(ChannelSidePanel::getWidth() + PADDING_SIDE), floor(windowSize.y - inputBackgroundSize.y - PADDING_BOTTOM * Settings::getScaling()));
inputBackground.setSize(inputBackgroundSize);
inputBackground.setPosition(inputBackgroundPos);
text.setPosition(floor(inputBackgroundPos.x + BOX_PADDING_X), floor(inputBackgroundPos.y + inputBackgroundSize.y * 0.5f - fontHeight * 0.5f));
@@ -299,8 +299,8 @@ namespace dchat
int blinkElapsedTime = blinkTimer.getElapsedTime().asMilliseconds();
if(focused && blinkElapsedTime <= BLINK_TIME_VISIBLE_MS)
{
- 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));
+ sf::RectangleShape caretShape(sf::Vector2f(2.0f, inputBackgroundSize.y - BOX_PADDING_Y * Settings::getScaling() * 2.0f));
+ caretShape.setPosition(floor(text.getPosition().x + caretOffset.x), floor(caretOffset.y + inputBackgroundPos.y + BOX_PADDING_Y * Settings::getScaling()));
window.draw(caretShape);
}
@@ -312,6 +312,6 @@ namespace dchat
{
const float fontSize = FONT_SIZE * Settings::getScaling();
const float fontHeight = ResourceCache::getFont("fonts/Roboto-Regular.ttf")->getLineSpacing(fontSize);
- return PADDING_TOP + floor(fontHeight * 1.7f + BOX_PADDING_Y * 2.0f) + PADDING_BOTTOM;
+ return PADDING_TOP * Settings::getScaling() + floor(fontHeight * 1.7f + BOX_PADDING_Y * Settings::getScaling() * 2.0f) + PADDING_BOTTOM * Settings::getScaling();
}
}
diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp
index 031bbdf..6c75399 100644
--- a/src/MessageBoard.cpp
+++ b/src/MessageBoard.cpp
@@ -176,7 +176,7 @@ namespace dchat
position.y += scroll;
for(Message *message : messages)
{
- position.y += MESSAGE_PADDING_TOP;
+ position.y += (MESSAGE_PADDING_TOP * Settings::getScaling());
if(position.y + usernameTextHeight > 0.0f && position.y < backgroundPos.y + backgroundSize.y)
{
sf::Text usernameText(message->user->getName(), *usernameFont, usernameTextCharacterSize);
@@ -204,7 +204,7 @@ namespace dchat
message->text.setMaxWidth(backgroundSize.x);
message->text.setPosition(sf::Vector2f(floor(position.x + PADDING_SIDE), floor(position.y)));
message->text.draw(window, cache);
- position.y += message->text.getHeight() + MESSAGE_PADDING_BOTTOM;
+ position.y += (message->text.getHeight() + MESSAGE_PADDING_BOTTOM * Settings::getScaling());
if(position.y + LINE_HEIGHT > 0.0f && position.y < backgroundPos.y + backgroundSize.y)
{
diff --git a/src/Settings.cpp b/src/Settings.cpp
index 79c4fda..37abaf5 100644
--- a/src/Settings.cpp
+++ b/src/Settings.cpp
@@ -2,7 +2,7 @@
namespace dchat
{
- float scaling = 1.0f;
+ float scaling = 0.8f;
float Settings::getScaling()
{