MCPcopy Create free account
hub / github.com/VCVRack/Rack / draw

Method draw

src/ui/TextField.cpp:58–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void 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
92void TextField::onDragHover(const DragHoverEvent& e) {
93 OpaqueWidget::onDragHover(e);

Callers

nothing calls this directly

Calls 5

minFunction · 0.85
maxFunction · 0.85
UTF8LengthFunction · 0.85
UTF8CodepointIndexFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected