aboutsummaryrefslogtreecommitdiff
path: root/include/Entry.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-28 13:32:34 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-28 13:32:34 +0200
commit4277763df5c1dac8ff389d3bfd138f03acc7f1e2 (patch)
treeb0c3fc77ea601f105308d42840adb1ce2050b414 /include/Entry.hpp
parenta16cfdc4f6cd14d576760c100a817c08f45be394 (diff)
Implement text editing with navigation and multilingual fonts
Diffstat (limited to 'include/Entry.hpp')
-rw-r--r--include/Entry.hpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/Entry.hpp b/include/Entry.hpp
new file mode 100644
index 0000000..6f96e58
--- /dev/null
+++ b/include/Entry.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "Text.hpp"
+#include "../external/RoundedRectangleShape.hpp"
+#include <SFML/Graphics/Text.hpp>
+#include <functional>
+
+namespace sf {
+ class Font;
+ class Event;
+ class RenderWindow;
+}
+
+namespace QuickMedia {
+ // Return true to clear the text
+ using OnEntrySubmit = std::function<bool(const sf::String& text)>;
+
+ class Entry {
+ public:
+ Entry(const std::string &placeholder_text, sf::Font *font, sf::Font *cjk_font);
+ void process_event(sf::Event &event);
+ void draw(sf::RenderWindow &window);
+
+ void set_editable(bool editable);
+ void set_position(const sf::Vector2f &pos);
+ void set_max_width(float width);
+
+ float get_height();
+
+ OnEntrySubmit on_submit_callback;
+ private:
+ Text text;
+ float width;
+ sf::RoundedRectangleShape background;
+ sf::Text placeholder;
+ };
+} \ No newline at end of file