MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / onRender

Method onRender

forms/label.cpp:39–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void Label::onRender()
40{
41 Control::onRender();
42
43 std::list<UString> lines = font->wordWrapText(text, Size.x);
44
45 int ysize = font->getFontHeight(text, Size.x);
46 if (scroller)
47 {
48 scroller->setVisible(ysize > this->Size.y && lines.size() > 1);
49 scroller->setMaximum(ysize - this->Size.y);
50 }
51
52 int ypos = align(TextVAlign, Size.y, ysize);
53 if (scroller && scroller->isVisible())
54 {
55 ypos = -scrollOffset;
56 }
57
58 for (const auto &line : lines)
59 {
60 int xpos = align(TextHAlign, Size.x, font->getFontWidth(line));
61
62 auto textImage = font->getString(line);
63 fw().renderer->drawTinted(textImage, Vec2<float>{xpos, ypos}, Tint);
64
65 ypos += font->getFontHeight();
66 }
67}
68
69void Label::update()
70{

Callers

nothing calls this directly

Calls 9

wordWrapTextMethod · 0.80
setMaximumMethod · 0.80
getFontWidthMethod · 0.80
getFontHeightMethod · 0.45
setVisibleMethod · 0.45
sizeMethod · 0.45
isVisibleMethod · 0.45
getStringMethod · 0.45
drawTintedMethod · 0.45

Tested by

no test coverage detected