Cogs.Core
TextComponent.cpp
1#include "TextComponent.h"
2
3#include "Types.h"
4
5using namespace Cogs::Reflection;
6
8{
9 static constexpr EnumeratorDef vEnumerators[] = {
10 { "Bottom", VerticalAlignment::Bottom },
11 { "Center", VerticalAlignment::Center },
12 { "Top", VerticalAlignment::Top },
13 };
14
15 TypeDatabase::createType<VerticalAlignment>().setEnumerators(vEnumerators);
16
17 static constexpr EnumeratorDef hEnumerators[] = {
18 { "Left", HorizontalAlignment::Left },
19 { "Right", HorizontalAlignment::Right },
20 { "Center", HorizontalAlignment::Center },
21 };
22
23 TypeDatabase::createType<HorizontalAlignment>().setEnumerators(hEnumerators);
24
25 static constexpr EnumeratorDef hjEumerators[] = {
29 };
30
31 TypeDatabase::createType<HorizontalJustification>().setEnumerators(hjEumerators);
32
33 Field fields [] = {
35 Field(Name("positions"), &TextComponent::positions),
36 Field(Name("colors"), &TextComponent::colors),
37 Field(Name("fontHandle"), &TextComponent::fontHandle),
39 Field(Name("positioningMode"), &TextComponent::positionMode),
40 Field(Name("verticalAlignment"), &TextComponent::verticalAlignment),
41 Field(Name("horizontalJustification"), &TextComponent::horizontalJustification),
42 };
43
44 TypeDatabase::createType<TextComponent>().setBase<Component>().setFields(fields);
45}
std::vector< glm::vec3 > positions
Offset positions for each of the strings in texts.
HorizontalJustification horizontalJustification
Horizontal justification of the text.
VerticalAlignment verticalAlignment
Vertical alignment of the text.
std::vector< std::string > texts
A set of text strings to render.
Definition: TextComponent.h:91
static void registerType()
Register the type in the type system.
PositionMode positionMode
Positioning mode of the text.
std::vector< glm::vec4 > colors
Colors for individual strings in text.
glm::vec4 color
Single color value to apply to all text strings.
FontHandle fontHandle
Handle to the font resource to use when rendering text.
Field definition describing a single data member of a data structure.
Definition: Field.h:68
@ None
None, the text is centered on the position.
@ Right
The rightmost character is placed to the left of the screen position.
@ Left
The leftmost character is placed to the right of the screen position.
@ Bottom
Align the text towards the bottom, making the position minus the font height the baseline of the text...
@ Center
Center the text on the screen position.
@ Top
Align the text towards the top, making the position the baseline of the text.
Contains reflection support.
Definition: Component.h:11
Represents an unique name.
Definition: Name.h:70