vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ui_text.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6#include <glm/glm.hpp>
7
8#include "core/reflect.h"
9
10namespace Vkm::Engine {
11
15inline constexpr const char* DEFAULT_UI_FONT = "ui:roboto";
16
24struct UIText {
25 enum class Align : uint8_t { Left, Center, Right, Count };
26 enum class VAlign : uint8_t { Top, Middle, Bottom, Count };
27
29 std::string text;
31 std::string font = DEFAULT_UI_FONT;
32 float pixelSize = 32.0f;
33 glm::vec4 color = {1.0f, 1.0f, 1.0f, 1.0f};
34 Align align = Align::Left;
35 VAlign valign = VAlign::Top;
36
40 bool wrap = false;
41};
42
43} // namespace Vkm::Engine
44
45VKM_ENUM_NAMES(::Vkm::Engine::UIText::Align, "Left", "Center", "Right")
46
47VKM_ENUM_NAMES(::Vkm::Engine::UIText::VAlign, "Top", "Middle", "Bottom")
48
49VKM_REFLECT_BEGIN(::Vkm::Engine::UIText)
50 VKM_F(text)
51 VKM_F(font)
52 VKM_F(pixelSize)
53 VKM_F(color)
54 VKM_F(align)
55 VKM_F(valign)
56 VKM_F(wrap)
57VKM_REFLECT_END()
Text drawn within its element's rect, on as many lines as it breaks into.
Definition ui_text.h:24
std::string text
UTF-8; what the font does not cover draws nothing.
Definition ui_text.h:29
std::string font
Baked SDF font asset name; nothing draws if unresolved.
Definition ui_text.h:31
float pixelSize
Text height in canvas reference pixels.
Definition ui_text.h:32
Align align
Horizontal alignment within the element rect.
Definition ui_text.h:34
glm::vec4 color
Straight (non-premultiplied) RGBA.
Definition ui_text.h:33
VAlign valign
Vertical alignment within the element rect.
Definition ui_text.h:35
bool wrap
Whether a line too wide for the element rect breaks onto the next.
Definition ui_text.h:40