Cogs.Core
|
Renders the given text(s) by generating sprites. More...
#include <TextComponent.h>
Static Public Member Functions | |
static void | registerType () |
Register the type in the type system. | |
![]() | |
static COGSFOUNDATION_API void | registerType () |
Register the Component type in the global type database. | |
static COGSFOUNDATION_API Reflection::TypeId | getComponentTypeId (const StringView &name) |
Get the type id of the component type with the given name. | |
Public Attributes | |
std::vector< std::string > | texts |
A set of text strings to render. | |
std::vector< glm::vec3 > | positions |
Offset positions for each of the strings in texts. | |
std::vector< glm::vec4 > | colors |
Colors for individual strings in text. | |
FontHandle | fontHandle = FontHandle::NoHandle |
Handle to the font resource to use when rendering text. | |
glm::vec4 | color = glm::vec4(1, 1, 1, 1) |
Single color value to apply to all text strings. | |
PositionMode | positionMode = PositionMode::Pixels |
Positioning mode of the text. | |
VerticalAlignment | verticalAlignment = VerticalAlignment::Center |
Vertical alignment of the text. | |
HorizontalJustification | horizontalJustification = HorizontalJustification::Left |
Horizontal justification of the text. | |
Additional Inherited Members | |
![]() | |
class Entity * | getContainer () const |
Get the container currently owning this component instance. | |
void | setContainer (class Entity *container) |
Set the container owning this component instance. | |
template<typename ComponentType > | |
ComponentType * | getComponent () const |
COGSFOUNDATION_API Component * | getComponent (const Reflection::Name &name) const |
COGSFOUNDATION_API Component * | getComponent (const Reflection::TypeId &id) const |
template<typename ComponentType > | |
ComponentHandle | getComponentHandle () const |
COGSFOUNDATION_API ComponentHandle | getComponentHandle (const Reflection::Name &name) const |
COGSFOUNDATION_API ComponentHandle | getComponentHandle (const Reflection::TypeId &id) const |
void | setActive () |
Sets the component to the ComponentFlags::Active state. | |
bool | isActive () const |
Gets if the component is currently set to the ComponentFlags::Active state. | |
void | setChanged () |
Sets the component to the ComponentFlags::Changed state with carry. | |
void | setChangedTransient () |
Sets the component to the ComponentFlags::Changed state without carry. | |
void | setFieldChanged (const Reflection::FieldId fieldId) |
Sets the component to the ComponentFlags::Changed state without carry. | |
template<typename ClassType , typename FieldType > | |
void | setFieldChanged (FieldType ClassType::*field) |
Sets a flag indicating that the given field has changed. | |
void | setFieldChangedTransient (const Reflection::FieldId fieldId) |
Sets the component to the ComponentFlags::Changed state without carry. | |
bool | hasChanged () const |
bool | hasAnyfieldChanged () const |
Gets if any fields have been changed. | |
bool | hasFieldChanged (const Reflection::FieldId fieldId) const |
Gets if the field with the given id on this component instance has changed. | |
template<typename ClassType , typename FieldType > | |
bool | hasFieldChanged (FieldType ClassType::*field) const |
Gets if the given field has changed. | |
void | resetCarryChanged () |
Reset the CarryChanged flag. Called at start of redraw. See ComponentFlags::CarryChanged. | |
void | resetChanged () |
Resets the changed state of the component, respecting any carry state set. | |
template<typename ClassType , typename FieldType > | |
Reflection::FieldId | getFieldId (FieldType ClassType::*field) const |
Gets field ID of the given field. | |
void | resetFieldsChanged () |
Resets the state of all changed field flags. | |
void | resetFieldChanged (const Reflection::FieldId fieldId) |
Resets the changed state of the given fieldId. | |
template<typename ClassType , typename FieldType > | |
void | resetFieldChanged (FieldType ClassType::*field) |
Resets the changed state of the given field. | |
constexpr void | setFlags (const uint32_t flags) |
Override all flags of the Component, setting the given flags. | |
constexpr void | setFlag (const uint32_t flag) |
Set the given flags. Does not override the currently set flags. | |
constexpr void | unsetFlag (const uint32_t flag) |
Unset the given flag. Does not remove the status of other than the given flags. | |
constexpr bool | isSet (const uint32_t flag) const |
Checks if the given flag is set. Requires exact bit match if test of several bits. | |
constexpr void | setTypeId (const Reflection::TypeId typeId) |
Set the Reflection::TypeId of the component. | |
constexpr Reflection::TypeId | getTypeId () const |
Get the Reflection::TypeId of the component. | |
COGSFOUNDATION_API const Reflection::Type & | getType () const |
Get the full Reflection::Type of the component. | |
constexpr void | setIndex (const ComponentIndex index) |
Set the components pool index. For internal use only. | |
constexpr ComponentIndex | getIndex () const |
Get the components pool index. For internal use only. | |
constexpr void | setGeneration (uint16_t generation) |
Sets the component generation. | |
constexpr uint16_t | getGeneration () const |
Gets the component generation. | |
size_t | hash (size_t hashValue=Cogs::hash()) const |
Calculates a hash of this component's members. | |
Renders the given text(s) by generating sprites.
Definition at line 76 of file TextComponent.h.
|
static |
Register the type in the type system.
Definition at line 7 of file TextComponent.cpp.
References Cogs::Core::Bottom, Cogs::Core::Center, color, colors, fontHandle, horizontalJustification, Cogs::Core::Left, Cogs::Core::None, positionMode, positions, Cogs::Core::Right, texts, Cogs::Core::Top, and verticalAlignment.
glm::vec4 Cogs::Core::TextComponent::color = glm::vec4(1, 1, 1, 1) |
Single color value to apply to all text strings.
Definition at line 122 of file TextComponent.h.
Referenced by registerType().
std::vector<glm::vec4> Cogs::Core::TextComponent::colors |
Colors for individual strings in text.
If colors contains the same number of elements as texts, each text string is rendered using the corresponding color. If not, the field color is used.
Definition at line 110 of file TextComponent.h.
Referenced by registerType().
FontHandle Cogs::Core::TextComponent::fontHandle = FontHandle::NoHandle |
Handle to the font resource to use when rendering text.
If the handle is not valid, text rendering will fall back to using the default font.
Definition at line 117 of file TextComponent.h.
Referenced by registerType().
HorizontalJustification Cogs::Core::TextComponent::horizontalJustification = HorizontalJustification::Left |
Horizontal justification of the text.
Definition at line 131 of file TextComponent.h.
Referenced by registerType().
PositionMode Cogs::Core::TextComponent::positionMode = PositionMode::Pixels |
Positioning mode of the text.
Definition at line 125 of file TextComponent.h.
Referenced by registerType().
std::vector<glm::vec3> Cogs::Core::TextComponent::positions |
Offset positions for each of the strings in texts.
If positions is empty, all texts will be rendered at the position given by TransformComponent. If positions contains the same number of elements as texts, each text string is rendered using the corresponding position offset.
Definition at line 102 of file TextComponent.h.
Referenced by registerType(), and Cogs::Core::DepthAxisSystem::update().
std::vector<std::string> Cogs::Core::TextComponent::texts |
A set of text strings to render.
The text is positioned on the screen according to the position given by the TransformComponent and the positioningMode field.
All the texts are rendered using the same font, positioning mode, alignment and justification. However, color and position can vary according to the positions and color arrays.
Definition at line 91 of file TextComponent.h.
Referenced by registerType(), and Cogs::Core::AnnotationAxisSystem::update().
VerticalAlignment Cogs::Core::TextComponent::verticalAlignment = VerticalAlignment::Center |
Vertical alignment of the text.
Definition at line 128 of file TextComponent.h.
Referenced by registerType().