928c3f07211695074fef75eb786f8206d2f19208
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model-interface.h
1 #ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/math/vector2.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
26 #include <dali-toolkit/internal/text/line-run.h>
27 #include <dali-toolkit/internal/text/script-run.h>
28 #include <dali-toolkit/internal/text/text-definitions.h>
29 #include <dali-toolkit/public-api/text/text-enumerations.h>
30
31 namespace Dali
32 {
33 namespace Toolkit
34 {
35 namespace Text
36 {
37 /**
38  * @brief Interface class used to retrieve the text's model from the text-controller.
39  */
40 class ModelInterface
41 {
42 public:
43   /**
44    * @brief Virtual destructor.
45    */
46   virtual ~ModelInterface()
47   {
48   }
49
50   /**
51    * @brief Retrives the control's size.
52    *
53    * @return The control's size.
54    */
55   virtual const Size& GetControlSize() const = 0;
56
57   /**
58    * @brief Retrives the layout's size.
59    *
60    * @return The layout's size.
61    */
62   virtual const Size& GetLayoutSize() const = 0;
63
64   /**
65    * @brief Retrieves the text's scroll position.
66    *
67    * @return The scroll position.
68    */
69   virtual const Vector2& GetScrollPosition() const = 0;
70
71   /**
72    * @brief Retrieves the text's horizontal alignment.
73    *
74    * @return The horizontal alignment.
75    */
76   virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
77
78   /**
79    * @brief Retrieves the text's vertical alignment.
80    *
81    * @return The vertical alignment.
82    */
83   virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
84
85   /**
86    * @brief Retrieves the text's vertical line alignment.
87    *
88    * @return The vertical line alignment.
89    */
90   virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
91
92   /**
93    * @brief Whether the text elide property is enabled.
94    *
95    * @return @e true if the text elide property is enabled, @e false otherwise.
96    */
97   virtual bool IsTextElideEnabled() const = 0;
98
99   /**
100    * @brief Retrieves the number of laid-out lines.
101    *
102    * @return The number of laid-out lines.
103    */
104   virtual Length GetNumberOfLines() const = 0;
105
106   /**
107    * @brief Retrieves the laid-out lines.
108    *
109    * @return A pointer to the vector with the laid-out lines.
110    */
111   virtual const LineRun* const GetLines() const = 0;
112
113   /**
114    * @brief Retrieves the number of script runs.
115    *
116    * @return The number of script runs.
117    */
118   virtual Length GetNumberOfScripts() const = 0;
119
120   /**
121    * @brief Retrieves the script runs.
122    *
123    * @return A pointer to the vector with the runs of characters with the same script..
124    */
125   virtual const ScriptRun* const GetScriptRuns() const = 0;
126
127   /**
128    * @brief Retrieves the number of laid-out glyphs.
129    *
130    * @return The number of laid-out glyphs.
131    */
132   virtual Length GetNumberOfGlyphs() const = 0;
133
134   /**
135    * @brief Retrieves the laid-out glyphs.
136    *
137    * @return A pointer to the vector with the laid-out glyphs.
138    */
139   virtual const GlyphInfo* const GetGlyphs() const = 0;
140
141   /**
142    * @brief Retrieves the text layout.
143    *
144    * @return A pointer to the vector with the positions for each glyph.
145    */
146   virtual const Vector2* const GetLayout() const = 0;
147
148   /**
149    * @brief Retrieves the vector of colors.
150    *
151    * @return Pointer to the vector of colors.
152    */
153   virtual const Vector4* const GetColors() const = 0;
154
155   /**
156    * @brief Retrieves the vector of indices to the vector of colors.
157    *
158    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
159    */
160   virtual const ColorIndex* const GetColorIndices() const = 0;
161
162   /**
163    * @brief Retrieves the vector of background colors.
164    *
165    * @return Pointer to the vector of background colors.
166    */
167   virtual const Vector4* const GetBackgroundColors() const = 0;
168
169   /**
170    * @brief Retrieves the vector of indices to the vector of background colors.
171    *
172    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
173    */
174   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
175
176   /**
177    * @brief checks if there is background colors set using markup.
178    *
179    * @return boolean if there is background colors set using markup .
180    */
181   virtual bool const IsMarkupBackgroundColorSet() const = 0;
182
183   /**
184    * @brief Retrieves the text's default color.
185    *
186    * @return The default color.
187    */
188   virtual const Vector4& GetDefaultColor() const = 0;
189
190   /**
191    * @brief Retrieves the shadow offset, 0 indicates no shadow.
192    *
193    * @return The shadow offset.
194    */
195   virtual const Vector2& GetShadowOffset() const = 0;
196
197   /**
198    * @brief Retrieves the shadow color.
199    *
200    * @return The shadow color.
201    */
202   virtual const Vector4& GetShadowColor() const = 0;
203
204   /**
205    * @brief Retrieve the shadow blur radius.
206    *
207    * @return The shadow blur radius.
208    */
209   virtual const float& GetShadowBlurRadius() const = 0;
210
211   /**
212    * @brief Retrieves the underline color.
213    *
214    * @return The underline color.
215    */
216   virtual const Vector4& GetUnderlineColor() const = 0;
217
218   /**
219    * @brief Returns whether underline is enabled or not.
220    *
221    * @return The underline state.
222    */
223   virtual bool IsUnderlineEnabled() const = 0;
224
225   /**
226    * @brief Retrieves the underline height override
227    *
228    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
229    */
230   virtual float GetUnderlineHeight() const = 0;
231
232   /**
233    * @brief Retrieves the number of underline runs.
234    *
235    * @return The number of underline runs.
236    */
237   virtual Length GetNumberOfUnderlineRuns() const = 0;
238
239   /**
240    * @brief Retrieves the underline runs.
241    *
242    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
243    * @param[in] index Index of the first underline run to be copied.
244    * @param[in] numberOfRuns Number of underline runs to be copied.
245    */
246   virtual void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
247
248   /**
249    * @brief Retrieve the outline color.
250    *
251    * @return The outline color.
252    */
253   virtual const Vector4& GetOutlineColor() const = 0;
254
255   /**
256    * @brief Retrieves the width of an outline
257    *
258    * @return The width of the outline.
259    */
260   virtual uint16_t GetOutlineWidth() const = 0;
261
262   /**
263    * @brief Retrieves the background color.
264    *
265    * @return The background color.
266    */
267   virtual const Vector4& GetBackgroundColor() const = 0;
268
269   /**
270    * @brief Returns whether background is enabled or not.
271    *
272    * @return The background state.
273    */
274   virtual bool IsBackgroundEnabled() const = 0;
275
276   /**
277    * @brief Returns whether markup-processor is enabled or not.
278    *
279    * @return The markup-processor state.
280    */
281   virtual bool IsMarkupProcessorEnabled() const = 0;
282
283   /**
284    * @brief Returns the hyphens glyph info.
285    *
286    * @return hyphens glyph info.
287    */
288   virtual const GlyphInfo* GetHyphens() const = 0;
289
290   /**
291    * @brief Returns the indices of the hyphen in the text.
292    *
293    * @return the hyphen indices.
294    */
295   virtual const Length* GetHyphenIndices() const = 0;
296
297   /**
298    * @brief Returns number of hyphens to add in text.
299    *
300    * @return number of hyphens.
301    */
302   virtual Length GetHyphensCount() const = 0;
303 };
304
305 } // namespace Text
306
307 } // namespace Toolkit
308
309 } // namespace Dali
310
311 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H