1 #ifndef GONG_UI_TEXTINPUT_HPP_
2 #define GONG_UI_TEXTINPUT_HPP_
5 #include "../graphics/PrimitiveMesh.hpp"
20 explicit TextInput(const graphics::Font &);
22 const std::string &GetInput() const noexcept { return input; }
24 void Focus(graphics::Viewport &) noexcept;
27 void Clear() noexcept;
28 void Backspace() noexcept;
29 void Delete() noexcept;
31 void MoveBegin() noexcept;
32 void MoveBackward() noexcept;
33 void MoveForward() noexcept;
34 void MoveEnd() noexcept;
36 void Insert(const char *);
38 bool AtBegin() const noexcept;
39 bool AtEnd() const noexcept;
41 void Position(const glm::vec3 &p, graphics::Gravity g, graphics::Gravity pv) noexcept;
42 void Width(float) noexcept;
44 void Foreground(const graphics::PrimitiveMesh::Color &col) noexcept { fg = col; dirty_cursor = true; }
45 void Background(const graphics::PrimitiveMesh::Color &col) noexcept { bg = col; dirty_box = true; }
47 void Handle(const SDL_TextInputEvent &);
48 void Handle(const SDL_TextEditingEvent &);
50 void Render(graphics::Viewport &);
56 const graphics::Font &font;
58 std::string::size_type cursor;
61 graphics::PrimitiveMesh bg_mesh;
62 graphics::PrimitiveMesh cursor_mesh;
64 graphics::PrimitiveMesh::Color bg;
65 graphics::PrimitiveMesh::Color fg;
69 graphics::Gravity gravity;