summaryrefslogtreecommitdiff
path: root/Runtime/GUI/UITextMesh.h
blob: ea543f3e72bab6e4dafcaf3749ee3bbb767cd6fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include "../Graphics/VertexBuffer.h"
#include "Font.h"
#include "Runtime/Utilities/Exception.h"
#include "Runtime/Graphics/Color.h"

#include <unordered_map>

CustomException(TextMeshException);

enum ETextAnchor
{
    TextAnchor_UpperLeft,
    TextAnchor_UpperCenter,
    TextAnchor_UpperRight,
    TextAnchor_MiddleLeft,
    TextAnchor_MiddleCenter,
    TextAnchor_MiddleRight,
    TextAnchor_LowerLeft,
    TextAnchor_LowerCenter,
    TextAnchor_LowerRight,
};

enum ETextAlignment {
    TextAlignment_Left,
    TextAlignment_Center,
    TextAlignment_Right,
};

namespace TextHelper
{
}

class UITextMesh
{
public:
	void Draw() const;

private:
    friend class TextMeshGenerator;

    UITextMesh(const UnicodeString& str, Font* font, int pixelSize, int lineHeight, Color32 color32 = Color32::white, ETextAnchor anchor = TextAnchor_UpperLeft, ETextAlignment alignment = TextAlignment_Left, bool wordwrap = false, float preferred = 0)/*throw TextMeshException*/;
    ~UITextMesh();

    GET(const Font*, Font, m_Font);
    GET(int, PixelSize, m_PixelSize);
    GET(int, LineHeight, m_LineHeight);
    GET(Color32, Color, m_Color);
    GET(ETextAlignment, Alignment, m_Alignment);
    GET(ETextAnchor, Anchor, m_Anchor);
    GET(bool, Wordwrap, m_Wordwrap);
    GET(float, Preferred, m_Preferred);
    GET(const UnicodeString&, Content, m_Content);

    std::unordered_map<int, VertexBuffer*> m_VBOs;

	Font*          m_Font;
    UnicodeString  m_Content;
    int            m_PixelSize; 
    int            m_LineHeight;
    Color32        m_Color; 
    ETextAlignment m_Alignment; 
    ETextAnchor    m_Anchor;
    bool           m_Wordwrap; 
    float          m_Preferred;
	
};