vkmEngine 1.0.15
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 static constexpr float SHADOW_DROP = 1.0f / 16.0f;
30
32 std::string text;
34 std::string font = DEFAULT_UI_FONT;
35 float pixelSize = 32.0f;
36 glm::vec4 color = {1.0f, 1.0f, 1.0f, 1.0f};
37 Align align = Align::Left;
38 VAlign valign = VAlign::Top;
41 glm::vec4 shadow = {0.0f, 0.0f, 0.0f, 0.0f};
42
46 bool wrap = false;
47};
48
49} // namespace Vkm::Engine
50
51VKM_ENUM_NAMES(::Vkm::Engine::UIText::Align, "Left", "Center", "Right")
52
53VKM_ENUM_NAMES(::Vkm::Engine::UIText::VAlign, "Top", "Middle", "Bottom")
54
55VKM_REFLECT_BEGIN(::Vkm::Engine::UIText)
56 VKM_F(text)
57 VKM_F(font)
58 VKM_F(pixelSize)
59 VKM_F(color)
60 VKM_F(align)
61 VKM_F(valign)
62 VKM_F(shadow)
63 VKM_F(wrap)
64VKM_REFLECT_END()
Text drawn within its element's rect, on as many lines as it breaks into.
Definition ui_text.h:24
glm::vec4 shadow
Definition ui_text.h:41
std::string text
UTF-8; what the font does not cover draws nothing.
Definition ui_text.h:32
std::string font
Baked SDF font asset name; nothing draws if unresolved.
Definition ui_text.h:34
float pixelSize
Text height in canvas reference pixels.
Definition ui_text.h:35
Align align
Horizontal alignment within the element rect.
Definition ui_text.h:37
glm::vec4 color
Straight (non-premultiplied) RGBA.
Definition ui_text.h:36
static constexpr float SHADOW_DROP
How far the shadow falls, down and right, in the text's heights.
Definition ui_text.h:29
VAlign valign
Definition ui_text.h:38
bool wrap
Whether a line too wide for the element rect breaks onto the next.
Definition ui_text.h:46