| 102 | } |
| 103 | |
| 104 | void TextBoxCanvasComponent::draw(SkCanvas* canvas, const DrawData& drawData, const std::shared_ptr<void>& predrawData) const { |
| 105 | SkRect clipR = SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y()); |
| 106 | if(d.editing) { |
| 107 | SkPaint p; |
| 108 | p.setAntiAlias(drawData.skiaAA); |
| 109 | p.setStyle(SkPaint::kStroke_Style); |
| 110 | p.setStrokeWidth(0.0f); |
| 111 | p.setColor4f({0.5f, 0.5f, 0.5f, 1.0f}); |
| 112 | canvas->drawRect(clipR, p); |
| 113 | } |
| 114 | canvas->clipRect(clipR, drawData.skiaAA); |
| 115 | canvas->translate(d.p1.x() + TEXTBOX_PADDING, d.p1.y() + TEXTBOX_PADDING); |
| 116 | |
| 117 | TextBox::PaintOpts paintOpts; |
| 118 | paintOpts.cursorColor = {0.7f, 0.7f, 1.0f}; |
| 119 | if(d.editing && cursor) |
| 120 | paintOpts.cursor = *cursor; |
| 121 | paintOpts.skiaAA = drawData.skiaAA; |
| 122 | |
| 123 | textBox->paint(canvas, paintOpts); |
| 124 | } |
| 125 | |
| 126 | Vector2f TextBoxCanvasComponent::get_mouse_pos(DrawingProgram& drawP) const { |
| 127 | return compContainer->coords.get_mouse_pos(drawP.world) - d.p1 - Vector2f{TEXTBOX_PADDING, TEXTBOX_PADDING}; |