31 #include <glm/vec2.hpp>
33 #include "eng3d/ui/widget.hpp"
34 #include "eng3d/ui/input.hpp"
35 #include "eng3d/ui/ui.hpp"
36 #include "eng3d/texture.hpp"
37 #include "eng3d/rectangle.hpp"
38 #include "eng3d/state.hpp"
46 std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv_utf8_utf32;
47 std::u32string unicode_text = conv_utf8_utf32.from_bytes(w.buffer);
48 if(input !=
nullptr) {
49 std::u32string unicode_input = conv_utf8_utf32.from_bytes(input);
50 unicode_text.insert(w.curpos, unicode_input);
51 w.curpos += unicode_input.length();
52 }
else if(!unicode_text.empty() && w.curpos) {
53 unicode_text.erase(w.curpos - 1, 1);
56 w.buffer = conv_utf8_utf32.to_bytes(unicode_text);
57 w.
set_text(w.buffer.empty() ?
" " : w.buffer);
66 this->set_text(buffer);
68 std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv_utf8_utf32;
69 std::u32string unicode_text = conv_utf8_utf32.from_bytes(this->buffer);
70 this->curpos = unicode_text.length();
86 input.is_selected =
false;
91 std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv_utf8_utf32;
92 std::u32string unicode_text = conv_utf8_utf32.from_bytes(input.buffer);
93 if(input.curpos == unicode_text.length()) {
94 input.timer = (input.timer + 1) % 30;
95 const std::string cursor = input.timer >= 10 ?
"_" :
"";
96 if(input.is_selected && input.timer % 30 == 0) {
97 if(!input.buffer.empty()) {
98 input.set_text(input.buffer + cursor);
99 }
else if(!cursor.empty()) {
100 input.set_text(cursor);
WidgetType
The type of the widget, some widgets share types between them to keep simplicity.