| 56 | } |
| 57 | |
| 58 | void TextField::draw(const DrawArgs& args) { |
| 59 | nvgScissor(args.vg, RECT_ARGS(args.clipBox)); |
| 60 | |
| 61 | BNDwidgetState state; |
| 62 | if (this == APP->event->selectedWidget) |
| 63 | state = BND_ACTIVE; |
| 64 | else if (this == APP->event->hoveredWidget) |
| 65 | state = BND_HOVER; |
| 66 | else |
| 67 | state = BND_DEFAULT; |
| 68 | |
| 69 | int begin = std::min(cursor, selection); |
| 70 | int end = std::max(cursor, selection); |
| 71 | |
| 72 | std::string drawText; |
| 73 | if (password) { |
| 74 | drawText = std::string(string::UTF8Length(text), '*'); |
| 75 | begin = string::UTF8CodepointIndex(text, begin); |
| 76 | end = string::UTF8CodepointIndex(text, end); |
| 77 | } |
| 78 | else { |
| 79 | drawText = text; |
| 80 | } |
| 81 | |
| 82 | bndTextField(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, drawText.c_str(), begin, end); |
| 83 | |
| 84 | // Draw placeholder text |
| 85 | if (text.empty()) { |
| 86 | bndIconLabelCaret(args.vg, 0.0, 0.0, box.size.x, box.size.y, -1, bndGetTheme()->textFieldTheme.itemColor, 13, placeholder.c_str(), bndGetTheme()->textFieldTheme.itemColor, 0, -1); |
| 87 | } |
| 88 | |
| 89 | nvgResetScissor(args.vg); |
| 90 | } |
| 91 | |
| 92 | void TextField::onDragHover(const DragHoverEvent& e) { |
| 93 | OpaqueWidget::onDragHover(e); |
nothing calls this directly
no test coverage detected