| 168 | } |
| 169 | |
| 170 | void TextEdit::onRender() |
| 171 | { |
| 172 | Control::onRender(); |
| 173 | |
| 174 | auto u8str = to_ustring(text); |
| 175 | |
| 176 | int xpos = align(TextHAlign, Size.x, font->getFontWidth(u8str)); |
| 177 | int ypos = align(TextVAlign, Size.y, font->getFontHeight()); |
| 178 | |
| 179 | if (editing) |
| 180 | { |
| 181 | int cxpos = xpos + font->getFontWidth(to_ustring(text.substr(0, SelectionStart))) + 1; |
| 182 | |
| 183 | if (cxpos < 0) |
| 184 | { |
| 185 | xpos += cxpos; |
| 186 | cxpos = xpos + font->getFontWidth(to_ustring(text.substr(0, SelectionStart))) + 1; |
| 187 | } |
| 188 | if (cxpos > Size.x) |
| 189 | { |
| 190 | xpos -= cxpos - Size.x; |
| 191 | cxpos = xpos + font->getFontWidth(to_ustring(text.substr(0, SelectionStart))) + 1; |
| 192 | } |
| 193 | |
| 194 | if (caretDraw) |
| 195 | { |
| 196 | auto textImage = font->getString(cursor); |
| 197 | fw().renderer->draw(textImage, Vec2<float>{cxpos, ypos}); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | auto textImage = font->getString(u8str); |
| 202 | fw().renderer->draw(textImage, Vec2<float>{xpos, ypos}); |
| 203 | } |
| 204 | |
| 205 | void TextEdit::update() |
| 206 | { |
nothing calls this directly
no test coverage detected