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