Add GetFontRuns and GetFontDescriptionRuns into ModelInterface
[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) 2022 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* const 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* const GetScriptRuns() const = 0;
139
140   /**
141    * @brief Retrieves the number of laid-out glyphs.
142    *
143    * @return The number of laid-out glyphs.
144    */
145   virtual Length GetNumberOfGlyphs() const = 0;
146
147   /**
148    * @brief Retrieves the start index of laid-out glyphs.
149    *
150    * @return The start index of laid-out glyphs.
151    */
152   virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
153
154   /**
155    * @brief Retrieves the end index of laid-out glyphs.
156    *
157    * @return The end index of laid-out glyphs.
158    */
159   virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
160
161   /**
162    * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
163    *
164    * @return The first middle index of elided glyphs, index before ellipsis of middle.
165    */
166   virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
167
168   /**
169    * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
170    *
171    * @return The second middle index of elided glyphs, index of ellipsis of middle.
172    */
173   virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
174
175   /**
176    * @brief Retrieves the laid-out glyphs.
177    *
178    * @return A pointer to the vector with the laid-out glyphs.
179    */
180   virtual const GlyphInfo* const GetGlyphs() const = 0;
181
182   /**
183    * @brief Retrieves the text layout.
184    *
185    * @return A pointer to the vector with the positions for each glyph.
186    */
187   virtual const Vector2* const GetLayout() const = 0;
188
189   /**
190    * @brief Retrieves the vector of colors.
191    *
192    * @return Pointer to the vector of colors.
193    */
194   virtual const Vector4* const GetColors() const = 0;
195
196   /**
197    * @brief Retrieves the vector of indices to the vector of colors.
198    *
199    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
200    */
201   virtual const ColorIndex* const GetColorIndices() const = 0;
202
203   /**
204    * @brief Retrieves the vector of background colors.
205    *
206    * @return Pointer to the vector of background colors.
207    */
208   virtual const Vector4* const GetBackgroundColors() const = 0;
209
210   /**
211    * @brief Retrieves the vector of indices to the vector of background colors.
212    *
213    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
214    */
215   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
216
217   /**
218    * @brief checks if there is background colors set using markup.
219    *
220    * @return boolean if there is background colors set using markup .
221    */
222   virtual bool const IsMarkupBackgroundColorSet() const = 0;
223
224   /**
225    * @brief Retrieves the text's default color.
226    *
227    * @return The default color.
228    */
229   virtual const Vector4& GetDefaultColor() const = 0;
230
231   /**
232    * @brief Retrieves the shadow offset, 0 indicates no shadow.
233    *
234    * @return The shadow offset.
235    */
236   virtual const Vector2& GetShadowOffset() const = 0;
237
238   /**
239    * @brief Retrieves the shadow color.
240    *
241    * @return The shadow color.
242    */
243   virtual const Vector4& GetShadowColor() const = 0;
244
245   /**
246    * @brief Retrieve the shadow blur radius.
247    *
248    * @return The shadow blur radius.
249    */
250   virtual const float& GetShadowBlurRadius() const = 0;
251
252   /**
253    * @brief Retrieves the underline color.
254    *
255    * @return The underline color.
256    */
257   virtual const Vector4& GetUnderlineColor() const = 0;
258
259   /**
260    * @brief Returns whether underline is enabled or not.
261    *
262    * @return The underline state.
263    */
264   virtual bool IsUnderlineEnabled() const = 0;
265
266   /**
267    * @brief checks if there is underline set using markup.
268    *
269    * @return boolean if there is underline set using markup.
270    */
271   virtual bool const IsMarkupUnderlineSet() const = 0;
272
273   /**
274    * @brief Retrieves the underline height override
275    *
276    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
277    */
278   virtual float GetUnderlineHeight() const = 0;
279
280   /**
281    * @brief Retrieves the underline type override.
282    *
283    * @return Returns the override type for an underline.
284    */
285   virtual Text::Underline::Type GetUnderlineType() const = 0;
286
287   /**
288    * @brief Retrieves the dashed underline width override
289    *
290    * @return Returns the override width for the dashed underline.
291    */
292   virtual float GetDashedUnderlineWidth() const = 0;
293
294   /**
295    * @brief Retrieves the dashed underline gap override
296    *
297    * @return Returns the override gap for the dashed underline.
298    */
299   virtual float GetDashedUnderlineGap() const = 0;
300
301   /**
302    * @brief Retrieves the number of underline runs.
303    *
304    * @return The number of underline runs.
305    */
306   virtual Length GetNumberOfUnderlineRuns() const = 0;
307
308   /**
309    * @brief Retrieves the underline runs.
310    *
311    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
312    * @param[in] index Index of the first underline run to be copied.
313    * @param[in] numberOfRuns Number of underline runs to be copied.
314    */
315   virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
316
317   /**
318    * @brief Retrieve the outline color.
319    *
320    * @return The outline color.
321    */
322   virtual const Vector4& GetOutlineColor() const = 0;
323
324   /**
325    * @brief Retrieves the width of an outline
326    *
327    * @return The width of the outline.
328    */
329   virtual uint16_t GetOutlineWidth() const = 0;
330
331   /**
332    * @brief Retrieves the background color.
333    *
334    * @return The background color.
335    */
336   virtual const Vector4& GetBackgroundColor() const = 0;
337
338   /**
339    * @brief Returns whether background is enabled or not.
340    *
341    * @return The background state.
342    */
343   virtual bool IsBackgroundEnabled() const = 0;
344
345   /**
346    * @brief Returns whether markup-processor is enabled or not.
347    *
348    * @return The markup-processor state.
349    */
350   virtual bool IsMarkupProcessorEnabled() const = 0;
351
352   /**
353    * @brief Returns the hyphens glyph info.
354    *
355    * @return hyphens glyph info.
356    */
357   virtual const GlyphInfo* GetHyphens() const = 0;
358
359   /**
360    * @brief Returns the indices of the hyphen in the text.
361    *
362    * @return the hyphen indices.
363    */
364   virtual const Length* GetHyphenIndices() const = 0;
365
366   /**
367    * @brief Returns number of hyphens to add in text.
368    *
369    * @return number of hyphens.
370    */
371   virtual Length GetHyphensCount() const = 0;
372
373   /**
374    * @brief Retrieves the strikethrough color.
375    *
376    * @return The strikethrough color.
377    */
378   virtual const Vector4& GetStrikethroughColor() const = 0;
379
380   /**
381    * @brief Returns whether strikethrough is enabled or not.
382    *
383    * @return The strikethrough state.
384    */
385   virtual bool IsStrikethroughEnabled() const = 0;
386
387   /**
388    * @brief checks if there is strikethrough set using markup.
389    *
390    * @return boolean if there is strikethrough set using markup.
391    */
392   virtual bool const IsMarkupStrikethroughSet() const = 0;
393
394   /**
395    * @brief Retrieves the strikethrough height override
396    *
397    * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
398    */
399   virtual float GetStrikethroughHeight() const = 0;
400
401   /**
402    * @brief Retrieves the number of strikethrough runs.
403    *
404    * @return The number of strikethrough runs.
405    */
406   virtual Length GetNumberOfStrikethroughRuns() const = 0;
407
408   /**
409    * @brief Retrieves the number of bounded paragraph runs.
410    *
411    * @return The number of bounded paragraph runs.
412    */
413   virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
414
415   /**
416    * @brief Retrieves the reference for bounded paragraph runs.
417    *
418    * @return The reference for bounded paragraph runs.
419    */
420   virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
421
422   /**
423    * @brief Retrieves the number of character-spacing glyph runs.
424    *
425    * @return The number of character-spacing glyph runs.
426    */
427   virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0;
428
429   /**
430    * @brief Retrieves the reference for character-spacing glyph runs.
431    *
432    * @return The reference for character-spacing glyph runs.
433    */
434   virtual const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const = 0;
435
436   /**
437    * @brief Retrieves the strikethrough runs.
438    *
439    * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
440    * @param[in] index Index of the first strikethrough run to be copied.
441    * @param[in] numberOfRuns Number of strikethrough runs to be copied.
442    */
443   virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
444
445   /**
446    * @brief Retrieves the character spacing.
447    *
448    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
449    *
450    * @return The character spacing.
451    */
452   virtual const float GetCharacterSpacing() const = 0;
453
454   /**
455    * @brief Retrieves the text buffer.
456    *
457    * @return The text buffer.
458    */
459   virtual const Character* GetTextBuffer() const = 0;
460
461   /**
462    * @brief Retrieves the Glyphs to Characters Array.
463    *
464    * @return The GlyphsToCharacters.
465    */
466   virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
467
468   /**
469    * @brief Retrieves the reference for font runs.
470    *
471    * @return The reference for font runs.
472    */
473   virtual const Vector<FontRun>& GetFontRuns() const = 0;
474
475   /**
476    * @brief Retrieves the reference for font description runs.
477    *
478    * @return The reference for font description runs.
479    */
480   virtual const Vector<FontDescriptionRun>& GetFontDescriptionRuns() const = 0;
481 };
482
483 } // namespace Text
484
485 } // namespace Toolkit
486
487 } // namespace Dali
488
489 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H