[dali_2.3.20] Merge branch 'devel/master'
[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) 2023 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/bounded-paragraph-run.h>
27 #include <dali-toolkit/internal/text/character-spacing-glyph-run.h>
28 #include <dali-toolkit/internal/text/font-description-run.h>
29 #include <dali-toolkit/internal/text/font-run.h>
30 #include <dali-toolkit/internal/text/line-run.h>
31 #include <dali-toolkit/internal/text/script-run.h>
32 #include <dali-toolkit/internal/text/strikethrough-glyph-run.h>
33 #include <dali-toolkit/internal/text/text-definitions.h>
34 #include <dali-toolkit/internal/text/underlined-glyph-run.h>
35 #include <dali-toolkit/public-api/text/text-enumerations.h>
36
37 namespace Dali
38 {
39 namespace Toolkit
40 {
41 namespace Text
42 {
43 /**
44  * @brief Interface class used to retrieve the text's model from the text-controller.
45  */
46 class ModelInterface
47 {
48 public:
49   /**
50    * @brief Virtual destructor.
51    */
52   virtual ~ModelInterface()
53   {
54   }
55
56   /**
57    * @brief Retrives the control's size.
58    *
59    * @return The control's size.
60    */
61   virtual const Size& GetControlSize() const = 0;
62
63   /**
64    * @brief Retrives the layout's size.
65    *
66    * @return The layout's size.
67    */
68   virtual const Size& GetLayoutSize() const = 0;
69
70   /**
71    * @brief Retrieves the text's scroll position.
72    *
73    * @return The scroll position.
74    */
75   virtual const Vector2& GetScrollPosition() const = 0;
76
77   /**
78    * @brief Retrieves the text's horizontal alignment.
79    *
80    * @return The horizontal alignment.
81    */
82   virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
83
84   /**
85    * @brief Retrieves the text's vertical alignment.
86    *
87    * @return The vertical alignment.
88    */
89   virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
90
91   /**
92    * @brief Retrieves the text's vertical line alignment.
93    *
94    * @return The vertical line alignment.
95    */
96   virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
97
98   /**
99    * @brief Retrieves ellipsis position for text.
100    *
101    * @return The ellipsis position.
102    */
103   virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
104
105   /**
106    * @brief Whether the text elide property is enabled.
107    *
108    * @return @e true if the text elide property is enabled, @e false otherwise.
109    */
110   virtual bool IsTextElideEnabled() const = 0;
111
112   /**
113    * @brief Retrieves the number of laid-out lines.
114    *
115    * @return The number of laid-out lines.
116    */
117   virtual Length GetNumberOfLines() const = 0;
118
119   /**
120    * @brief Retrieves the laid-out lines.
121    *
122    * @return A pointer to the vector with the laid-out lines.
123    */
124   virtual const LineRun* GetLines() const = 0;
125
126   /**
127    * @brief Retrieves the number of script runs.
128    *
129    * @return The number of script runs.
130    */
131   virtual Length GetNumberOfScripts() const = 0;
132
133   /**
134    * @brief Retrieves the script runs.
135    *
136    * @return A pointer to the vector with the runs of characters with the same script..
137    */
138   virtual const ScriptRun* GetScriptRuns() const = 0;
139
140   /**
141    * @brief Retrieves number of characters.
142    *
143    * @return The number of characters.
144    */
145   virtual Length GetNumberOfCharacters() const = 0;
146
147   /**
148    * @brief Retrieves the number of laid-out glyphs.
149    *
150    * @return The number of laid-out glyphs.
151    */
152   virtual Length GetNumberOfGlyphs() const = 0;
153
154   /**
155    * @brief Retrieves the start index of laid-out glyphs.
156    *
157    * @return The start index of laid-out glyphs.
158    */
159   virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
160
161   /**
162    * @brief Retrieves the end index of laid-out glyphs.
163    *
164    * @return The end index of laid-out glyphs.
165    */
166   virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
167
168   /**
169    * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
170    *
171    * @return The first middle index of elided glyphs, index before ellipsis of middle.
172    */
173   virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
174
175   /**
176    * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
177    *
178    * @return The second middle index of elided glyphs, index of ellipsis of middle.
179    */
180   virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
181
182   /**
183    * @brief Retrieves the laid-out glyphs.
184    *
185    * @return A pointer to the vector with the laid-out glyphs.
186    */
187   virtual const GlyphInfo* GetGlyphs() const = 0;
188
189   /**
190    * @brief Retrieves the text layout.
191    *
192    * @return A pointer to the vector with the positions for each glyph.
193    */
194   virtual const Vector2* GetLayout() const = 0;
195
196   /**
197    * @brief Retrieves the vector of colors.
198    *
199    * @return Pointer to the vector of colors.
200    */
201   virtual const Vector4* GetColors() const = 0;
202
203   /**
204    * @brief Retrieves the vector of indices to the vector of colors.
205    *
206    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
207    */
208   virtual const ColorIndex* GetColorIndices() const = 0;
209
210   /**
211    * @brief Retrieves the vector of background colors.
212    *
213    * @return Pointer to the vector of background colors.
214    */
215   virtual const Vector4* GetBackgroundColors() const = 0;
216
217   /**
218    * @brief Retrieves the vector of indices to the vector of background colors.
219    *
220    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
221    */
222   virtual const ColorIndex* GetBackgroundColorIndices() const = 0;
223
224   /**
225    * @brief checks if there is background colors set using markup.
226    *
227    * @return boolean if there is background colors set using markup .
228    */
229   virtual bool IsMarkupBackgroundColorSet() const = 0;
230
231   /**
232    * @brief Retrieves the text's default color.
233    *
234    * @return The default color.
235    */
236   virtual const Vector4& GetDefaultColor() const = 0;
237
238   /**
239    * @brief Retrieves the shadow offset, 0 indicates no shadow.
240    *
241    * @return The shadow offset.
242    */
243   virtual const Vector2& GetShadowOffset() const = 0;
244
245   /**
246    * @brief Retrieves the shadow color.
247    *
248    * @return The shadow color.
249    */
250   virtual const Vector4& GetShadowColor() const = 0;
251
252   /**
253    * @brief Retrieve the shadow blur radius.
254    *
255    * @return The shadow blur radius.
256    */
257   virtual const float& GetShadowBlurRadius() const = 0;
258
259   /**
260    * @brief Retrieves the underline color.
261    *
262    * @return The underline color.
263    */
264   virtual const Vector4& GetUnderlineColor() const = 0;
265
266   /**
267    * @brief Returns whether underline is enabled or not.
268    *
269    * @return The underline state.
270    */
271   virtual bool IsUnderlineEnabled() const = 0;
272
273   /**
274    * @brief checks if there is underline set using markup.
275    *
276    * @return boolean if there is underline set using markup.
277    */
278   virtual bool IsMarkupUnderlineSet() const = 0;
279
280   /**
281    * @brief Retrieves the underline height override
282    *
283    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
284    */
285   virtual float GetUnderlineHeight() const = 0;
286
287   /**
288    * @brief Retrieves the underline type override.
289    *
290    * @return Returns the override type for an underline.
291    */
292   virtual Text::Underline::Type GetUnderlineType() const = 0;
293
294   /**
295    * @brief Retrieves the dashed underline width override
296    *
297    * @return Returns the override width for the dashed underline.
298    */
299   virtual float GetDashedUnderlineWidth() const = 0;
300
301   /**
302    * @brief Retrieves the dashed underline gap override
303    *
304    * @return Returns the override gap for the dashed underline.
305    */
306   virtual float GetDashedUnderlineGap() const = 0;
307
308   /**
309    * @brief Retrieves the number of underline runs.
310    *
311    * @return The number of underline runs.
312    */
313   virtual Length GetNumberOfUnderlineRuns() const = 0;
314
315   /**
316    * @brief Retrieves the underline runs.
317    *
318    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
319    * @param[in] index Index of the first underline run to be copied.
320    * @param[in] numberOfRuns Number of underline runs to be copied.
321    */
322   virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
323
324   /**
325    * @brief Retrieve the outline color.
326    *
327    * @return The outline color.
328    */
329   virtual const Vector4& GetOutlineColor() const = 0;
330
331   /**
332    * @brief Retrieves the width of an outline
333    *
334    * @return The width of the outline.
335    */
336   virtual uint16_t GetOutlineWidth() const = 0;
337
338   /**
339    * @brief Retrieves the background color.
340    *
341    * @return The background color.
342    */
343   virtual const Vector4& GetBackgroundColor() const = 0;
344
345   /**
346    * @brief Returns whether background is enabled or not.
347    *
348    * @return The background state.
349    */
350   virtual bool IsBackgroundEnabled() const = 0;
351
352   /**
353    * @brief Returns whether markup-processor is enabled or not.
354    *
355    * @return The markup-processor state.
356    */
357   virtual bool IsMarkupProcessorEnabled() const = 0;
358
359   /**
360    * @brief Retrieves whether the spanned-text is placed.
361    *
362    * By default is disabled.
363    *
364    * @return @e true if the spanned-text is placed, otherwise returns @e false.
365    */
366   virtual bool IsSpannedTextPlaced() const = 0;
367
368   /**
369    * @brief Returns the hyphens glyph info.
370    *
371    * @return hyphens glyph info.
372    */
373   virtual const GlyphInfo* GetHyphens() const = 0;
374
375   /**
376    * @brief Returns the indices of the hyphen in the text.
377    *
378    * @return the hyphen indices.
379    */
380   virtual const Length* GetHyphenIndices() const = 0;
381
382   /**
383    * @brief Returns number of hyphens to add in text.
384    *
385    * @return number of hyphens.
386    */
387   virtual Length GetHyphensCount() const = 0;
388
389   /**
390    * @brief Retrieves the strikethrough color.
391    *
392    * @return The strikethrough color.
393    */
394   virtual const Vector4& GetStrikethroughColor() const = 0;
395
396   /**
397    * @brief Returns whether strikethrough is enabled or not.
398    *
399    * @return The strikethrough state.
400    */
401   virtual bool IsStrikethroughEnabled() const = 0;
402
403   /**
404    * @brief checks if there is strikethrough set using markup.
405    *
406    * @return boolean if there is strikethrough set using markup.
407    */
408   virtual bool IsMarkupStrikethroughSet() const = 0;
409
410   /**
411    * @brief Retrieves the strikethrough height override
412    *
413    * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
414    */
415   virtual float GetStrikethroughHeight() const = 0;
416
417   /**
418    * @brief Retrieves the number of strikethrough runs.
419    *
420    * @return The number of strikethrough runs.
421    */
422   virtual Length GetNumberOfStrikethroughRuns() const = 0;
423
424   /**
425    * @brief Retrieves the number of bounded paragraph runs.
426    *
427    * @return The number of bounded paragraph runs.
428    */
429   virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
430
431   /**
432    * @brief Retrieves the reference for bounded paragraph runs.
433    *
434    * @return The reference for bounded paragraph runs.
435    */
436   virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
437
438   /**
439    * @brief Retrieves the number of character-spacing glyph runs.
440    *
441    * @return The number of character-spacing glyph runs.
442    */
443   virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0;
444
445   /**
446    * @brief Retrieves the reference for character-spacing glyph runs.
447    *
448    * @return The reference for character-spacing glyph runs.
449    */
450   virtual const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const = 0;
451
452   /**
453    * @brief Retrieves the strikethrough runs.
454    *
455    * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
456    * @param[in] index Index of the first strikethrough run to be copied.
457    * @param[in] numberOfRuns Number of strikethrough runs to be copied.
458    */
459   virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
460
461   /**
462    * @brief Retrieves the character spacing.
463    *
464    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
465    *
466    * @return The character spacing.
467    */
468   virtual float GetCharacterSpacing() const = 0;
469
470   /**
471    * @brief Retrieves the text buffer.
472    *
473    * @return The text buffer.
474    */
475   virtual const Character* GetTextBuffer() const = 0;
476
477   /**
478    * @brief Retrieves the Glyphs to Characters Array.
479    *
480    * @return The GlyphsToCharacters.
481    */
482   virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
483
484   /**
485    * @brief Retrieves the reference for font runs.
486    *
487    * @return The reference for font runs.
488    */
489   virtual const Vector<FontRun>& GetFontRuns() const = 0;
490
491   /**
492    * @brief Retrieves the reference for font description runs.
493    *
494    * @return The reference for font description runs.
495    */
496   virtual const Vector<FontDescriptionRun>& GetFontDescriptionRuns() const = 0;
497 };
498
499 } // namespace Text
500
501 } // namespace Toolkit
502
503 } // namespace Dali
504
505 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H