MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / draw_cursor

Method draw_cursor

src/ClientData.cpp:222–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222void ClientData::draw_cursor(SkCanvas* canvas, const DrawData& drawData) const {
223 if((drawData.cam.c.inverseScale << 10) > camCoords.inverseScale && drawData.clampDrawMinimum < camCoords.inverseScale) {
224 canvas->save();
225 camCoords.transform_sk_canvas(canvas, drawData);
226
227 canvas->translate(cursorPos.x(), cursorPos.y());
228
229 {
230 SkPaint p(SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.3f});
231 p.setAntiAlias(drawData.skiaAA);
232 canvas->drawCircle(0.0f, 0.0f, 4.5f, p);
233 p.setStroke(true);
234 p.setStrokeWidth(1.0f);
235 p.setColor4f({cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f});
236 canvas->drawCircle(0.0f, 0.0f, 5.0f, p);
237 }
238
239 Vector2f bounds;
240 std::unique_ptr<skia::textlayout::Paragraph> paragraph;
241 {
242 skia::textlayout::ParagraphStyle pStyle;
243 pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
244 skia::textlayout::TextStyle tStyle;
245 tStyle.setFontSize(18.0f * drawData.main->g.final_gui_scale());
246 tStyle.setFontFamilies(drawData.main->g.gui.io.fonts->get_default_font_families());
247 tStyle.setForegroundPaint(SkPaint{SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f}});
248 pStyle.setTextStyle(tStyle);
249
250 skia::textlayout::ParagraphBuilderImpl a(pStyle, drawData.main->g.gui.io.fonts->collection, SkUnicodes::ICU::Make());
251 a.addText(displayName.c_str(), displayName.length());
252 paragraph = a.Build();
253 paragraph->layout(std::numeric_limits<float>::max());
254
255 bounds = {paragraph->getMaxIntrinsicWidth(), paragraph->getHeight()};
256 }
257
258 Vector2f textPos = {6.0f, -bounds.y()};
259
260 SkPaint p3(color_mul_alpha(drawData.main->g.gui.io.theme->backColor1, 0.6f));
261 p3.setAntiAlias(drawData.skiaAA);
262 canvas->drawRoundRect(SkRect::MakeXYWH(textPos.x(), textPos.y(), bounds.x(), bounds.y()), 3.0f, 3.0f, p3);
263
264 paragraph->paint(canvas, textPos.x(), textPos.y());
265
266 canvas->restore();
267 }
268}

Callers 1

Calls 13

color_mul_alphaFunction · 0.85
transform_sk_canvasMethod · 0.80
final_gui_scaleMethod · 0.80
c_strMethod · 0.80
paintMethod · 0.80
restoreMethod · 0.80
saveMethod · 0.45
translateMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected