1 // Copyright 2021 Google LLC. 2 #include "experimental/sktext/editor/Cursor.h" 3 4 using namespace skia::text; 5 6 namespace skia { 7 namespace editor { 8 Make()9std::unique_ptr<Cursor> Cursor::Make() { return std::make_unique<Cursor>(); } 10 Cursor()11Cursor::Cursor() { 12 fLinePaint.setColor(SK_ColorGRAY); 13 fLinePaint.setAntiAlias(true); 14 15 fRectPaint.setColor(DEFAULT_CURSOR_COLOR); 16 fRectPaint.setStyle(SkPaint::kStroke_Style); 17 fRectPaint.setStrokeWidth(2); 18 fRectPaint.setAntiAlias(true); 19 20 fXY = SkPoint::Make(0, 0); 21 fSize = SkSize::Make(0, 0); 22 fBlink = true; 23 } 24 paint(SkCanvas * canvas)25void Cursor::paint(SkCanvas* canvas) { 26 27 if (fBlink) { 28 canvas->drawRect(SkRect::MakeXYWH(fXY.fX, fXY.fY, DEFAULT_CURSOR_WIDTH, fSize.fHeight), fRectPaint); 29 } else { 30 //canvas->drawLine(fXY + xy, fXY + xy + SkPoint::Make(1, fSize.fHeight), fLinePaint); 31 } 32 } 33 34 } // namespace editor 35 } // namespace skia 36