MCPcopy Create free account
hub / github.com/aseprite/laf / draw_window

Function draw_window

examples/text_shape.cpp:80–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78};
79
80void 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);

Callers 1

app_mainFunction · 0.70

Calls 15

rgbaFunction · 0.85
to_skiaFunction · 0.85
draw_text_with_shaperFunction · 0.85
x2Method · 0.80
pointToScreenMethod · 0.80
originMethod · 0.80
saveMethod · 0.80
clipRectMethod · 0.80
restoreMethod · 0.80
draw_textFunction · 0.50
RegionClass · 0.50
surfaceMethod · 0.45

Tested by

no test coverage detected