aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/MessageBoard.hpp3
-rw-r--r--include/StringView.hpp15
-rw-r--r--include/Text.hpp8
3 files changed, 17 insertions, 9 deletions
diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp
index 06a7cd1..ca1405f 100644
--- a/include/MessageBoard.hpp
+++ b/include/MessageBoard.hpp
@@ -29,5 +29,8 @@ namespace dchat
sf::Vector2f mousePos;
sf::Vector2f selectingTextStart;
std::vector<Message*> messages;
+ double scroll;
+ double scrollSpeed;
+ sf::Clock frameTimer;
};
}
diff --git a/include/StringView.hpp b/include/StringView.hpp
index 4e9066b..9eea387 100644
--- a/include/StringView.hpp
+++ b/include/StringView.hpp
@@ -15,7 +15,7 @@ namespace dchat
}
- BasicStringView(const BasicStringView<CharType> &other) : data(other.data), size(other.size)
+ BasicStringView(const BasicStringView<CharType> &other) : data(other.data), size(other.size)
{
}
@@ -30,13 +30,14 @@ namespace dchat
}
- BasicStringView<CharType> operator = (const BasicStringView<CharType> &other)
+ BasicStringView<CharType>& operator = (const BasicStringView<CharType> &other)
{
- BasicStringView<CharType> result(other.data, other.size);
- return result;
+ data = other.data;
+ size = other.size;
+ return *this;
}
- BasicStringView( BasicStringView<CharType> &&other)
+ BasicStringView(BasicStringView<CharType> &&other)
{
data = other.data;
size = other.size;
@@ -45,10 +46,10 @@ namespace dchat
other.size = 0;
}
- bool equals(const BasicStringView<CharType> &other) const
+ bool equals(const BasicStringView<CharType> &other) const
{
if(size != other.size) return false;
- return memcmp(data, other.data, size) == 0;
+ return memcmp(data, other.data, size * sizeof(CharType)) == 0;
}
CharType operator [] (usize index) const
diff --git a/include/Text.hpp b/include/Text.hpp
index 53db93b..93ec0c1 100644
--- a/include/Text.hpp
+++ b/include/Text.hpp
@@ -17,6 +17,8 @@ namespace dchat
Text(const sf::String &str, const sf::Font &font, unsigned int characterSize, float maxWidth, bool plainText = true);
void setString(const sf::String &str);
+ void appendStringNewLine(const sf::String &str);
+
void setPosition(float x, float y);
void setPosition(const sf::Vector2f &position);
void setMaxWidth(float maxWidth);
@@ -26,9 +28,10 @@ namespace dchat
// Warning: won't update until @draw is called
float getHeight() const;
+ // Performs culling. @updateGeometry is called even if text is not visible if text is dirty, because updateGeometry might change the dimension of the text and make is visible
void draw(sf::RenderTarget &target, Cache &cache);
private:
- void stringSplitElements();
+ void stringSplitElements(sf::String &stringToSplit, usize startIndex);
void updateGeometry();
private:
struct TextElement
@@ -40,11 +43,12 @@ namespace dchat
};
TextElement() {}
- TextElement(const StringViewUtf32 &_text, Type _type) : text(_text), type(_type) {}
+ TextElement(const StringViewUtf32 &_text, Type _type) : text(_text), type(_type), ownLine(false) {}
StringViewUtf32 text;
sf::Vector2f position;
Type type;
+ bool ownLine; // Currently only used for emoji, to make emoji bigger when it's the only thing on a line
};
sf::String str;