| 78 | }; |
| 79 | |
| 80 | void draw_window(System* system, |
| 81 | Window* window, |
| 82 | const FontMgrRef& fontMgr, |
| 83 | const FontRef& font, |
| 84 | const FontRef& fontBig, |
| 85 | const gfx::Point& mousePos, |
| 86 | TextEdit& edit) |
| 87 | { |
| 88 | Surface* surface = window->surface(); |
| 89 | SurfaceLock lock(surface); |
| 90 | const gfx::Rect rc = surface->bounds(); |
| 91 | |
| 92 | Paint p; |
| 93 | p.color(gfx::rgba(64, 64, 64)); |
| 94 | p.style(Paint::Fill); |
| 95 | surface->drawRect(rc, p); |
| 96 | |
| 97 | gfx::PointF textPos; |
| 98 | gfx::RectF box; |
| 99 | |
| 100 | // Draw caret |
| 101 | { |
| 102 | int i = edit.caretIndex; |
| 103 | float x, w, h; |
| 104 | if (i < edit.boxes.size()) { |
| 105 | x = edit.boxes[i].bounds.x; |
| 106 | w = edit.boxes[i].bounds.w; |
| 107 | h = std::max(edit.caretHeight, edit.boxes[i].bounds.h); |
| 108 | } |
| 109 | else { |
| 110 | x = (!edit.boxes.empty() ? edit.boxes.back().bounds.x2() : 0); |
| 111 | w = 4; |
| 112 | h = edit.caretHeight; |
| 113 | } |
| 114 | |
| 115 | box = gfx::RectF(textPos.x + x, textPos.y, w, h); |
| 116 | |
| 117 | // Set the position for a possible IME dialog of the system. |
| 118 | system->setTextInput(true, window->pointToScreen(gfx::Point(box.origin()))); |
| 119 | |
| 120 | if (edit.caretVisible) { |
| 121 | surface->save(); |
| 122 | surface->clipRect(rc); |
| 123 | p.color(gfx::rgba(240, 240, 240)); |
| 124 | surface->drawRect(box, p); |
| 125 | p.color(gfx::rgba(64, 64, 64)); |
| 126 | if (edit.blob) |
| 127 | draw_text(surface, edit.blob, textPos, &p); |
| 128 | surface->restore(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | surface->save(); |
| 133 | p.color(gfx::rgba(240, 240, 240)); |
| 134 | if (!box.isEmpty()) |
| 135 | static_cast<SkiaSurface*>(surface)->canvas().clipRect(to_skia(box), SkClipOp::kDifference); |
| 136 | if (edit.blob) |
| 137 | draw_text(surface, edit.blob, textPos, &p); |
no test coverage detected