-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.h
More file actions
33 lines (28 loc) · 954 Bytes
/
text.h
File metadata and controls
33 lines (28 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef TEXT_H
#define TEXT_H
#include "item.h"
#include "color.h"
class Text: public Item
{
PROP(Text, std::string, text);
PROP(Text, Color, color) = Color::black;
PROP(Text, int, alignment) = NVG_ALIGN_LEFT|NVG_ALIGN_TOP;
PROP(Text, std::string, fontName) = "sans";
PROP(Text, int, fontSize) = 12.0f;
public:
static Text* createIcon(float width, float hieght, const char* unicode, uint32_t color, int size) {
auto icon = new Text(nullptr, 0, 0, width, hieght);
icon->m_alignment = NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE;
icon->m_fontName = "fas";
icon->m_fontSize = size;
icon->m_color = color;
icon->m_text = unicode;
return icon;
}
Text(Item *parent, float x = 0, float y = 0, float width = 0, float hieght = 0);
virtual void performLayout() override;
virtual void draw(NVGcontext *) override;
private:
bool needsUpdate = true;
};
#endif // TEXT_H