aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-31 20:00:19 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-31 20:22:39 +0200
commit7913c19875cd407a1559da66a26906184dcd712b (patch)
treebff43faa87ce66a745b499f3f281add609f68ed6 /include
parentee691432cc618474f12bac7976189cb4f91e2f63 (diff)
Add scrollbar (currently only used in message board)
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;
+ };
+}