From 2b7d030551a357272f9cc39e347855bd2e3faba2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 7 May 2018 23:00:21 +0200 Subject: Improve text editing, use Text object for chatbar Improve text rendering by not using floating point position --- include/Chatbar.hpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'include/Chatbar.hpp') diff --git a/include/Chatbar.hpp b/include/Chatbar.hpp index 27b57f9..5d69448 100644 --- a/include/Chatbar.hpp +++ b/include/Chatbar.hpp @@ -1,7 +1,8 @@ #pragma once #include "StringView.hpp" -#include +#include "Text.hpp" +#include "Cache.hpp" #include #include #include @@ -18,20 +19,10 @@ namespace dchat public: Chatbar(); - void addChar(sf::Uint32 codePoint); - void addString(const std::string &strToAdd); - const sf::String& getString() const; - void removePreviousChar(); - void removeNextChar(); - void clear(); - - void moveCaretLeft(); - void moveCaretRight(); - bool isFocused() const; void processEvent(const sf::Event &event, Channel *channel); - void draw(sf::RenderWindow &window); + void draw(sf::RenderWindow &window, Cache &cache); static float getHeight(); @@ -41,12 +32,9 @@ namespace dchat private: void processChatCommand(const StringView &cmd); private: - sf::Text text; + Text text; sf::RectangleShape background; sf::RectangleShape inputBackground; - int caretIndex; - sf::Vector2f caretOffset; - sf::Clock blinkTimer; bool focused; }; } -- cgit v1.2.3