Text class reference
Widget that allows to display text on the screen.
Window window(nullptr, "Text test", { {250,100}, {980,620}, WindowFlags::AutoInvokeRender});
Font font("fontname.ttf");
font.LoadFontSize(12)
Text text(&window, {{500, 250}, {0, 0}, Anchor::Left|Anchor::Bottom}, {12, Color{255,0,0,255}, &font}, L"My Text");
Functions
Functions documentation
Text(Window* window, constWidget2DProps& props =Widget2DProps({ 0,0 }, { 0,0 },Anchor::Left |Anchor::Top), constTextTheme& textProps =TextTheme(), std::wstring text = L"" );
Default constructor.
Text(Window* window, constWidget2DProps& props, constTheme& theme, std::wstring text);
Delegating constructor with theme application.
virtual ~Text();
Default destructor.
Text* Clone() const override;
Clones the object (usefull while making copy of object that is casted to its base).
const int GetFontSize() const;Returns the used font size by the widget.
void SetFontSize(int newSize);Sets new font size for the widget.
constColor& GetColor() const;
Returns text color data.
void SetColor(Colorcolor);
Sets text color.
void SetFont(Font* newFont);
Sets new font for the widget.
Font* GetFont() const;
Returns pointer to the font used by widget.
void SetText(std::wstring newText);Sets new text.
std::wstring GetText() const;Returns the text displayed by the widget in the form of std::wstring.
const std::wstring& GetTextRef() const;Returns the text displayed by the widget in the form of std::wstring&. (Reference wersion.)
void SetDisplayOffset(Point<float> newOffset);Sets text offset. Used mainly in SimpleInput widget.
const Point<float>& GetDisplayOffset() const;Returns the text offset. Used mailny in SimpleInput widget.
constDimension<float> GetTextRealWidth() const;
Returns the width of the widget (the size of the longest line displayed).
void Render() override;Renders the widget.
std::tuple<int, float> GetPromptPosition(Point<int> relClickPosition);Returns character identifier(position) and relative cursor position from the beggining in correlation to some specific point.
float GetPromptPosition(int idx);Returns the position of the promp at the place of the text character.
void GetNextPosition(int& charIdx, float& charPos);Returns the cursor position based on the previous position and size of the next character. (Specify the position of the next character.)
void GetPrevPosition(int& charIdx, float& charPos);Returns the cursor position based on the previous position and size of the previous character. (Specify the position of the previous character.)
void CalculateAnchorVec() override;Based on the m_iFlags from m_Widget2DProps, and true widget dimensions calculates the widget's shift vector.
const float GetKerning(int idxPrev, int idxCur) const;Returns the kerning value between two characters in the text.
void CreateBuffers();Creates OpenGL VAO and VBO.
void BindBuffers() override;Fills-in m_Vertexs and m_Uvs arrays with appropriate data, then binds them to their VBO.
void Cleanup();Deletes OpenGL VAO and VBO.
Variables documentation
TextThemem_TextTheme;
Stores information about widget theme and used font.
std::wstring m_Text;Actual text displayed by the widget.
Dimension<int> m_TrueDim;
Represents the true dimension of the widget.
GLuint m_VertexArrayId;OpenGL Vertex Array id.
GLuint m_VertexBufferId;OpenGL Vertex Buffer id.
GLuint m_UvBufferId;OpenGL UV Buffer id.
std::vector<float> m_Vertexs;Stores all vertices representing the text.
std::vector<float> m_UVs;Stores texture position for each vertex.
Point<float> m_Offset;Reserved.