skia2/experimental/sktext/editor/Selection.cpp
Julia Lavrova 8343e003ca SkText: implement select via styles
Change-Id: I047f7fc4027572892433d759f4098f5da9da4662
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438657
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2021-08-11 19:49:35 +00:00

27 lines
624 B
C++

// Copyright 2021 Google LLC.
#include "experimental/sktext/editor/Selection.h"
using namespace skia::text;
namespace skia {
namespace editor {
void Selection::select(TextRange range, SkRect rect) {
fGlyphBoxes.clear();
fTextRanges.clear();
fGlyphBoxes.emplace_back(rect);
fTextRanges.emplace_back(range);
}
void Selection::paint(SkCanvas* canvas, SkPoint xy) {
for (auto& box : fGlyphBoxes) {
canvas->drawRect(
SkRect::MakeXYWH(box.fLeft + xy.fX, box.fTop + xy.fY, box.width(), box.height()),
fBackground);
}
}
} // namespace editor
} // namespace skia