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 /**--------------------------------------------------------------------------------------------------
41 \brief Logic for inlining certain changes to the display properties of a string of text.
42 **/
43 enum TextControlSequence
44 {
45 e_set_font = 'f'
46 , e_set_color = 'c'
47 , e_set_bold = 'b'
48 , e_set_italic = 'i'
49 , e_set_underline = '_'
50 , e_set_overstrike = '-'
51 , e_set_alignment = 'a'
52 , e_set_font_size = 's'
53 , e_set_fixed_width = 'w'
54 , e_set_tab_advance = 't'
55 };
56 class TextConstructor;
57 /**--------------------------------------------------------------------------------------------------
58 \brief A Model which contains text in the form of one or more blocks of text data with each block
59 sharing a Font.
60 **/
61 class NDEVR_DESIGN_API Text : public Model
62 {
63 public:
64 Text();
65 Text(const Model& model);
66 Text(const Model& model, const Font& font);
67 Text(const Model& model, const DynamicPointer<TextConstructor>& font);
68 void setText(const TranslatedString& text, bool update_now = false);
69 void setText(const String& text, bool update_now = false);
70 void setText(const Buffer<TextBlock>& text, bool update_now = false);
71 void setAlignment(uint01 alignment, bool update_now = false);
72 void setInsertionAlignment(uint01 alignment, bool update_now = false);
73 Model textLayer();
74 Model textObject() const;
75 void setCursor(uint04 cursor_position);
76 void update();
77 bool needsUpdate() const;
78 void updateTranslation();
79 void setConstrainedSize(const Vector<2, fltp08>& size);
80 void setReferenceSize(const Vector<2, fltp08>& size);
81 void setForwardBias(fltp08 forward_bias);
82 const Material outlineMaterial() const;
83 Material outlineMaterial();
84 const Material fillMaterial() const;
85 Material fillMaterial();
86 void setLineSpaceFactor(fltp08 line_space);
87 fltp08 lineSpaceFactor() const;
88 void setFillMaterial(const Material& material);
89 void setOutlineMaterial(const Material& material);
90 String plainText() const;
91 const Buffer<TextBlock>& blocks() const { return m_text_blocks; };
92 Buffer<TextBlock> autoInsertNewLines() const;
93 void setFont(const Font& font, bool update_now = false);
94 Font font() const;
95 void saveBlockMetaData();
96 void readBlockMetaData();
97 Model getLetterAt(uint04 string_position) const;
98 static constexpr const char* TypeName() { return "text"; }
99 void setFaceCamera(bool face_camera);
100 void setScaleToCamera(bool face_camera);
101 void setFillBackground(bool fill_background);
102 static fltp04 DefaultScaler() { return .01f; }
103 private:
104 void init();
105 bool setupLetter(const DynamicPointer<TextConstructor>& printer, Model& letter, char value, fltp08 hor_advance, fltp08 scale, const Font& font);
106 bool setupLetter(const DynamicPointer<TextConstructor>& printer, Model& letter, wchar value, fltp08 hor_advance, fltp08 scale, const Font& font);
107 void setupCursor(const Matrix<fltp08>& matrix, const Vector<2, fltp08>& cursor_location, const Font& font);
108 void findCursor(bool create_if_not_exists);
109 void updateBackground();
110 void createCursor();
111 private:
112 mutable DynamicPointer<TextConstructor> m_printer;
113 Buffer<TextBlock> m_text_blocks;
114 Vector<2, fltp08> m_constrained_size;
115 Vector<2, fltp08> m_reference_size;
116 Model m_text_model;
117 uint04 m_cursor_index;
118 uint04 m_cursor_position;
119 uint01 m_alignment;
120 uint01 m_insertion_alignment;
121 mutable fltp08 m_line_space_factor;
122 fltp08 m_forward_bias = 0.0;
123 bool m_has_background = false;
124 };
125}
126#endif
127
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149