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