aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/MessageBoard.hpp4
-rw-r--r--include/Scrollbar.hpp33
2 files changed, 36 insertions, 1 deletions
diff --git a/include/MessageBoard.hpp b/include/MessageBoard.hpp
index acdaad4..fdde8c7 100644
--- a/include/MessageBoard.hpp
+++ b/include/MessageBoard.hpp
@@ -3,6 +3,7 @@
#include "Message.hpp"
#include "types.hpp"
#include "../include/Cache.hpp"
+#include "../include/Scrollbar.hpp"
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/Event.hpp>
@@ -42,8 +43,8 @@ namespace dchat
odhtdb::MapHash<Message*> messageIdMap;
double scroll;
double scrollSpeed;
- sf::Clock frameTimer;
double totalHeight;
+ sf::Clock frameTimer;
bool scrollToBottom;
sf::Vector2f backgroundSizeWithoutPadding;
sf::Vector2f backgroundSize;
@@ -51,5 +52,6 @@ namespace dchat
std::mutex messageProcessMutex;
usize visibleMessageStartIndex;
usize visibleMessageEndIndex;
+ Scrollbar scrollbar;
};
}
diff --git a/include/Scrollbar.hpp b/include/Scrollbar.hpp
new file mode 100644
index 0000000..7cf625b
--- /dev/null
+++ b/include/Scrollbar.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <SFML/Graphics/RenderWindow.hpp>
+#include <SFML/Graphics/Color.hpp>
+#include <SFML/System/Vector2.hpp>
+
+namespace dchat
+{
+ class Scrollbar
+ {
+ public:
+ Scrollbar();
+
+ void draw(sf::RenderWindow &window);
+
+ float getScrollingForContent() const;
+
+ float width;
+ double maxHeight;
+ double scroll;
+ double maxScroll;
+ double scrollRelative;
+ sf::Vector2f position;
+
+ sf::Color backgroundColor;
+ sf::Color scrollColor;
+ private:
+ float height;
+ bool grabbing;
+ bool followMouse;
+ sf::Vector2f grabOffset;
+ };
+}