#pragma once #include "Message.hpp" #include "types.hpp" #include "../include/Cache.hpp" #include #include #include #include namespace dchat { class Channel; class MessageBoard { friend class Channel; public: MessageBoard(const sf::Vector2u &size); ~MessageBoard(); void processEvent(const sf::Event &event); void draw(sf::RenderWindow &window, Cache &cache); private: void updateStaticContentTexture(const sf::Vector2u &newSize); void addMessage(Message *message); void drawDefault(sf::RenderWindow &window, Cache &cache); void drawSimple(sf::RenderWindow &window, Cache &cache); private: sf::RenderTexture staticContentTexture; bool dirty; bool selectingText; bool leftMouseButtonPressed; sf::Vector2f mousePos; sf::Vector2f selectingTextStart; std::vector messages; double scroll; double scrollSpeed; sf::Clock frameTimer; double totalHeight; bool scrollToBottom; sf::Vector2f backgroundSizeWithoutPadding; sf::Vector2f backgroundSize; sf::Vector2f backgroundPos; }; }