MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / drawUIString

Method drawUIString

src/ui/graphics.cpp:220–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void Graphics::drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt,
221 bool drawUnderscore)
222{
223 she::SurfaceLock lock(m_surface);
224 base::utf8_const_iterator it(str.begin()), end(str.end());
225 int x = m_dx+pt.x;
226 int y = m_dy+pt.y;
227 int underscored_x = 0;
228 int underscored_w = -1;
229
230 while (it != end) {
231 if (*it == '&') {
232 ++it;
233 if (it != end && *it != '&') {
234 underscored_x = x;
235 underscored_w = m_font->charWidth(*it);
236 }
237 }
238 m_surface->drawChar(m_font.get(), fg, bg, x, y, *it);
239 x += m_font->charWidth(*it);
240 ++it;
241 }
242
243 y += m_font->height();
244 if (drawUnderscore && underscored_w > 0) {
245 m_surface->fillRect(fg,
246 gfx::Rect(underscored_x, y, underscored_w, guiscale()));
247 y += guiscale();
248 }
249
250 dirty(gfx::Rect(pt, gfx::Point(x, y)));
251}
252
253void Graphics::drawAlignedUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align)
254{

Callers 5

onPaintMethod · 0.80
onPaintMethod · 0.80
onPaintMethod · 0.80
drawTextStringMethod · 0.80
drawTextBoxFunction · 0.80

Calls 9

guiscaleFunction · 0.85
PointClass · 0.85
beginMethod · 0.45
endMethod · 0.45
charWidthMethod · 0.45
drawCharMethod · 0.45
getMethod · 0.45
heightMethod · 0.45
fillRectMethod · 0.45

Tested by

no test coverage detected