MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / TextObject

Class TextObject

LibLemon/include/lemon/gfx/text.h:12–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11namespace Lemon::Graphics{
12 class TextObject {
13 public:
14 enum {
15 RenderLeftToRight,
16 RenderNormal = RenderLeftToRight,
17 RenderRightToLeft,
18 RenderVerticalDownToUp,
19 RenderVerticalUpToDown,
20 };
21 protected:
22 std::string text;
23 Font* font = nullptr;
24
25 vector2i_t pos;
26
27 bool textDirty = true;
28 vector2i_t textSize;
29
30 int renderMode = RenderNormal;
31
32 rgba_colour_t colour = {0, 0, 0, 255};
33
34 void CalculateSizes();
35 public:
36 TextObject(vector2i_t pos, std::string& text, Font* font = DefaultFont());
37 TextObject(vector2i_t pos, const char* text, Font* font = DefaultFont());
38 TextObject(vector2i_t pos = {0, 0}, Font* font = DefaultFont());
39
40 /////////////////////////////
41 /// \brief Render TextObject on surface
42 ///
43 /// \param surface Surface to render to
44 /////////////////////////////
45 void Render(surface_t* surface);
46
47 /////////////////////////////
48 /// \brief Set TextObject font
49 ///
50 /// \param font Font object
51 /////////////////////////////
52 inline void SetFont(Font* font){
53 assert(font);
54
55 this->font = font;
56 textDirty = true;
57 }
58
59 /////////////////////////////
60 /// \brief Set position of TextObject
61 ///
62 /// \param pos New position
63 /////////////////////////////
64 inline void SetPos(vector2i_t pos){
65 this->pos = pos;
66 }
67
68 /////////////////////////////
69 /// \brief Set colour of TextObject

Callers 2

MenuWidgetClass · 0.85
MenuWidgetMethod · 0.85

Calls 1

DefaultFontFunction · 0.85

Tested by

no test coverage detected