API Documentation
Loading...
Searching...
No Matches
Text.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Text
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_TEXT_MODEL
35#include <NDEVR/Model.h>
36#include <NDEVR/TextConstructor.h>
37#include <NDEVR/Font.h>
38namespace NDEVR
39{
40 enum TextControlSequence
41 {
42 e_set_font = 'f'
43 , e_set_color = 'c'
44 , e_set_bold = 'b'
45 , e_set_italic = 'i'
46 , e_set_underline = '_'
47 , e_set_overstrike = '-'
48 , e_set_alignment = 'a'
49 , e_set_font_size = 's'
50 , e_set_fixed_width = 'w'
51 , e_set_tab_advance = 't'
52 };
53 class TextConstructor;
54 class NDEVR_DESIGN_API Text : public Model
55 {
56 public:
57 Text();
58 Text(const Model& model);
59 Text(const Model& model, const Font& font);
60 Text(const Model& model, const DynamicPointer<TextConstructor>& font);
61 void setText(const TranslatedString& text, bool update_now = false);
62 void setText(const String& text, bool update_now = false);
63 void setText(const Buffer<TextBlock>& text, bool update_now = false);
64 void setAlignment(uint01 alignment, bool update_now = false);
65 void setInsertionAlignment(uint01 alignment, bool update_now = false);
66 Model textLayer();
67 Model textObject() const;
68 void init();
69
70 void setCursor(uint04 cursor_position);
71 void update();
72 bool needsUpdate() const;
73 void updateTranslation();
74 void setConstrainedSize(const Vector<2, fltp08>& size);
75 void setReferenceSize(const Vector<2, fltp08>& size);
76 void setForwardBias(fltp08 forward_bias);
77 const Material outlineMaterial() const;
78 Material outlineMaterial();
79 const Material fillMaterial() const;
80 Material fillMaterial();
81 void setLineSpaceFactor(fltp08 line_space);
82 fltp08 lineSpaceFactor() const;
83 void setFillMaterial(const Material& material);
84 void setOutlineMaterial(const Material& material);
85 String plainText() const;
86 const Buffer<TextBlock>& blocks() const { return m_text_blocks; };
87 Buffer<TextBlock> autoInsertNewLines() const;
88 void setFont(const Font& font, bool update_now = false);
89 Font font() const;
90 void saveBlockMetaData();
91 void readBlockMetaData();
92 Model getLetterAt(uint04 string_position) const;
93 static constexpr const char* TypeName() { return "text"; }
94 void setFaceCamera(bool face_camera);
95 void setScaleToCamera(bool face_camera);
96 void setFillBackground(bool fill_background);
97 static fltp04 DefaultScaler() { return .01f; }
98 protected:
99 bool setupLetter(const DynamicPointer<TextConstructor>& printer, Model& letter, char value, fltp08 hor_advance, fltp08 scale, const Font& font);
100 bool setupLetter(const DynamicPointer<TextConstructor>& printer, Model& letter, wchar value, fltp08 hor_advance, fltp08 scale, const Font& font);
101 void setupCursor(const Matrix<fltp08>& matrix, const Vector<2, fltp08>& cursor_location, const Font& font);
102 void findCursor(bool create_if_not_exists);
103 void updateBackground();
104 void createCursor();
105
106 protected:
107 mutable DynamicPointer<TextConstructor> m_printer;
108 Buffer<TextBlock> m_text_blocks;
109 Vector<2, fltp08> m_constrained_size;
110 Vector<2, fltp08> m_reference_size;
111 Model m_text_model;
112 uint04 m_cursor_index;
113 uint04 m_cursor_position;
114 uint01 m_alignment;
115 uint01 m_insertion_alignment;
116 mutable fltp08 m_line_space_factor;
117 fltp08 m_forward_bias = 0.0;
118 bool m_has_background = false;
119 };
120}
121#endif
122
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181