Cogs.Core
TextComponent.h
1#pragma once
2
3#include "SpriteRenderComponent.h"
4
5#include "Resources/Resources.h"
6
7#include <glm/vec3.hpp>
8#include <glm/vec4.hpp>
9
10#include <vector>
11
12namespace Cogs
13{
14 namespace Core
15 {
16 class TransformComponent;
17
25 {
29 Top = 1,
33 Center = 2,
37 Bottom = 3
38 };
39
44 {
45 None = 0,
46 Left = 1,
47 Right = 2,
48 Center = 3
49 };
50
58 {
62 Left = 1,
66 Right = 2,
70 None = 3
71 };
72
77 {
78 public:
80 static void registerType();
81
91 std::vector<std::string> texts;
92
102 std::vector<glm::vec3> positions;
103
110 std::vector<glm::vec4> colors;
111
118
122 glm::vec4 color = glm::vec4(1, 1, 1, 1);
123
126
129
132
134 // Cache component handles.
138 };
139 }
140}
141
142template<> inline Cogs::StringView getName<Cogs::Core::VerticalAlignment>() { return "VerticalAlignment"; }
143template<> inline Cogs::StringView getName<Cogs::Core::HorizontalAlignment>() { return "HorizontalAlignment"; }
144template<> inline Cogs::StringView getName<Cogs::Core::HorizontalJustification>() { return "HorizontalJustification"; }
145
146template<> inline Cogs::StringView getName<Cogs::Core::TextComponent>() { return "TextComponent"; }
Base class for Component instances.
Definition: Component.h:143
Renders the given text(s) by generating sprites.
Definition: TextComponent.h:77
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.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
PositionMode
Positioning mode.
@ Pixels
Position given in screen pixels ranging from [0, 0] in the lower left corner to [viewport....
HorizontalJustification
Horizontal justification modes for text.
Definition: TextComponent.h:58
@ Left
The leftmost character is placed to the right of the screen position.
HorizontalAlignment
Horizontal alignment of overlays.
Definition: TextComponent.h:44
VerticalAlignment
Defines vertical alignment modes for text.
Definition: TextComponent.h:25
@ Center
Center the text on the screen position.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Handle to a Component instance.
Definition: Component.h:67
static ComponentHandle Empty()
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool().
Definition: Component.h:119
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.