aboutsummaryrefslogtreecommitdiff
path: root/src/MessagePart.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-04-20 01:29:54 +0200
committerdec05eba <dec05eba@protonmail.com>2018-04-20 01:31:23 +0200
commit391f7fd6d832cb40f74fb37f9e0af7ff33db202f (patch)
tree1d3e2b54dfade403da579a23029ae98f1a5c8f5b /src/MessagePart.cpp
parentc670ad2839d886107189a5a0d0854a02aa0ace53 (diff)
Add message board, in the middle of text selection
Diffstat (limited to 'src/MessagePart.cpp')
-rw-r--r--src/MessagePart.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/MessagePart.cpp b/src/MessagePart.cpp
new file mode 100644
index 0000000..47c96bd
--- /dev/null
+++ b/src/MessagePart.cpp
@@ -0,0 +1,37 @@
+#include "../include/MessagePart.hpp"
+#include "../include/ResourceCache.hpp"
+#include "../include/Settings.hpp"
+
+using namespace std;
+
+namespace dchat
+{
+ const float MESSAGE_PART_SIZE = 27;
+
+ float MessagePart::getSizeScaled()
+ {
+ return MESSAGE_PART_SIZE * Settings::getScaling();
+ }
+
+ MessagePartText::MessagePartText(const string &_text) :
+ MessagePart(Type::TEXT),
+ text(_text, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), MessagePartText::getFontSizeScaled())
+ {
+
+ }
+
+ float MessagePartText::getFontSizeScaled()
+ {
+ return MessagePart::getSizeScaled() * 0.8f;
+ }
+
+ sf::Vector2f MessagePartText::getPosition() const
+ {
+ return text.getPosition();
+ }
+
+ sf::Vector2f MessagePartText::getSize() const
+ {
+ return sf::Vector2f(text.getLocalBounds().width, getFontSizeScaled());
+ }
+}