From 4277763df5c1dac8ff389d3bfd138f03acc7f1e2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 28 Sep 2020 13:32:34 +0200 Subject: Implement text editing with navigation and multilingual fonts --- include/Entry.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/Entry.hpp (limited to 'include/Entry.hpp') 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 +#include + +namespace sf { + class Font; + class Event; + class RenderWindow; +} + +namespace QuickMedia { + // Return true to clear the text + using OnEntrySubmit = std::function; + + 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 -- cgit v1.2.3