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