f36c527d4fece71a2e9994cda43145c8fa3f042b
[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 Retrieves ellipsis position for text.
94    *
95    * @return The ellipsis position.
96    */
97   virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
98
99   /**
100    * @brief Whether the text elide property is enabled.
101    *
102    * @return @e true if the text elide property is enabled, @e false otherwise.
103    */
104   virtual bool IsTextElideEnabled() const = 0;
105
106   /**
107    * @brief Retrieves the number of laid-out lines.
108    *
109    * @return The number of laid-out lines.
110    */
111   virtual Length GetNumberOfLines() const = 0;
112
113   /**
114    * @brief Retrieves the laid-out lines.
115    *
116    * @return A pointer to the vector with the laid-out lines.
117    */
118   virtual const LineRun* const GetLines() const = 0;
119
120   /**
121    * @brief Retrieves the number of script runs.
122    *
123    * @return The number of script runs.
124    */
125   virtual Length GetNumberOfScripts() const = 0;
126
127   /**
128    * @brief Retrieves the script runs.
129    *
130    * @return A pointer to the vector with the runs of characters with the same script..
131    */
132   virtual const ScriptRun* const GetScriptRuns() const = 0;
133
134   /**
135    * @brief Retrieves the number of laid-out glyphs.
136    *
137    * @return The number of laid-out glyphs.
138    */
139   virtual Length GetNumberOfGlyphs() const = 0;
140
141   /**
142    * @brief Retrieves the start index of laid-out glyphs.
143    *
144    * @return The start index of laid-out glyphs.
145    */
146   virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
147
148   /**
149    * @brief Retrieves the end index of laid-out glyphs.
150    *
151    * @return The end index of laid-out glyphs.
152    */
153   virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
154
155   /**
156    * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
157    *
158    * @return The first middle index of elided glyphs, index before ellipsis of middle.
159    */
160   virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
161
162   /**
163    * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
164    *
165    * @return The second middle index of elided glyphs, index of ellipsis of middle.
166    */
167   virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
168
169   /**
170    * @brief Retrieves the laid-out glyphs.
171    *
172    * @return A pointer to the vector with the laid-out glyphs.
173    */
174   virtual const GlyphInfo* const GetGlyphs() const = 0;
175
176   /**
177    * @brief Retrieves the text layout.
178    *
179    * @return A pointer to the vector with the positions for each glyph.
180    */
181   virtual const Vector2* const GetLayout() const = 0;
182
183   /**
184    * @brief Retrieves the vector of colors.
185    *
186    * @return Pointer to the vector of colors.
187    */
188   virtual const Vector4* const GetColors() const = 0;
189
190   /**
191    * @brief Retrieves the vector of indices to the vector of colors.
192    *
193    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
194    */
195   virtual const ColorIndex* const GetColorIndices() const = 0;
196
197   /**
198    * @brief Retrieves the vector of background colors.
199    *
200    * @return Pointer to the vector of background colors.
201    */
202   virtual const Vector4* const GetBackgroundColors() const = 0;
203
204   /**
205    * @brief Retrieves the vector of indices to the vector of background colors.
206    *
207    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
208    */
209   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
210
211   /**
212    * @brief checks if there is background colors set using markup.
213    *
214    * @return boolean if there is background colors set using markup .
215    */
216   virtual bool const IsMarkupBackgroundColorSet() const = 0;
217
218   /**
219    * @brief Retrieves the text's default color.
220    *
221    * @return The default color.
222    */
223   virtual const Vector4& GetDefaultColor() const = 0;
224
225   /**
226    * @brief Retrieves the shadow offset, 0 indicates no shadow.
227    *
228    * @return The shadow offset.
229    */
230   virtual const Vector2& GetShadowOffset() const = 0;
231
232   /**
233    * @brief Retrieves the shadow color.
234    *
235    * @return The shadow color.
236    */
237   virtual const Vector4& GetShadowColor() const = 0;
238
239   /**
240    * @brief Retrieve the shadow blur radius.
241    *
242    * @return The shadow blur radius.
243    */
244   virtual const float& GetShadowBlurRadius() const = 0;
245
246   /**
247    * @brief Retrieves the underline color.
248    *
249    * @return The underline color.
250    */
251   virtual const Vector4& GetUnderlineColor() const = 0;
252
253   /**
254    * @brief Returns whether underline is enabled or not.
255    *
256    * @return The underline state.
257    */
258   virtual bool IsUnderlineEnabled() const = 0;
259
260   /**
261    * @brief Retrieves the underline height override
262    *
263    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
264    */
265   virtual float GetUnderlineHeight() const = 0;
266
267   /**
268    * @brief Retrieves the underline type override.
269    *
270    * @return Returns the override type for an underline.
271    */
272   virtual Text::Underline::Type GetUnderlineType() const = 0;
273
274   /**
275    * @brief Retrieves the dashed underline width override
276    *
277    * @return Returns the override width for the dashed underline.
278    */
279   virtual float GetDashedUnderlineWidth() const = 0;
280
281   /**
282    * @brief Retrieves the dashed underline gap override
283    *
284    * @return Returns the override gap for the dashed underline.
285    */
286   virtual float GetDashedUnderlineGap() const = 0;
287
288   /**
289    * @brief Retrieves the number of underline runs.
290    *
291    * @return The number of underline runs.
292    */
293   virtual Length GetNumberOfUnderlineRuns() const = 0;
294
295   /**
296    * @brief Retrieves the underline runs.
297    *
298    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
299    * @param[in] index Index of the first underline run to be copied.
300    * @param[in] numberOfRuns Number of underline runs to be copied.
301    */
302   virtual void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
303
304   /**
305    * @brief Retrieve the outline color.
306    *
307    * @return The outline color.
308    */
309   virtual const Vector4& GetOutlineColor() const = 0;
310
311   /**
312    * @brief Retrieves the width of an outline
313    *
314    * @return The width of the outline.
315    */
316   virtual uint16_t GetOutlineWidth() const = 0;
317
318   /**
319    * @brief Retrieves the background color.
320    *
321    * @return The background color.
322    */
323   virtual const Vector4& GetBackgroundColor() const = 0;
324
325   /**
326    * @brief Returns whether background is enabled or not.
327    *
328    * @return The background state.
329    */
330   virtual bool IsBackgroundEnabled() const = 0;
331
332   /**
333    * @brief Returns whether markup-processor is enabled or not.
334    *
335    * @return The markup-processor state.
336    */
337   virtual bool IsMarkupProcessorEnabled() const = 0;
338
339   /**
340    * @brief Returns the hyphens glyph info.
341    *
342    * @return hyphens glyph info.
343    */
344   virtual const GlyphInfo* GetHyphens() const = 0;
345
346   /**
347    * @brief Returns the indices of the hyphen in the text.
348    *
349    * @return the hyphen indices.
350    */
351   virtual const Length* GetHyphenIndices() const = 0;
352
353   /**
354    * @brief Returns number of hyphens to add in text.
355    *
356    * @return number of hyphens.
357    */
358   virtual Length GetHyphensCount() const = 0;
359
360   /**
361    * @brief Retrieves the strikethrough color.
362    *
363    * @return The strikethrough color.
364    */
365   virtual const Vector4& GetStrikethroughColor() const = 0;
366
367   /**
368    * @brief Returns whether strikethrough is enabled or not.
369    *
370    * @return The strikethrough state.
371    */
372   virtual bool IsStrikethroughEnabled() const = 0;
373
374   /**
375    * @brief Retrieves the strikethrough height override
376    *
377    * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
378    */
379   virtual float GetStrikethroughHeight() const = 0;
380 };
381
382 } // namespace Text
383
384 } // namespace Toolkit
385
386 } // namespace Dali
387
388 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H