[dali_2.1.31] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-view-interface.h
1 #ifndef DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_VIEW_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/common/dali-vector.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/text-definitions.h>
29 #include <dali-toolkit/internal/text/underlined-glyph-run.h>
30 #include <dali-toolkit/public-api/text/text-enumerations.h>
31
32 namespace Dali
33 {
34 struct Vector2;
35 struct Vector4;
36
37 namespace Toolkit
38 {
39 namespace Text
40 {
41 struct GlyphRun;
42 struct StrikethroughGlyphRun;
43
44 /**
45  * @brief Abstract interface to provide the information necessary to display text.
46  *
47  * This includes:
48  * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
49  * - The visual position of each glyph within the layout
50  * - A window into the text layout e.g. which page of a document to view
51  */
52 class ViewInterface
53 {
54 public:
55   /**
56    * @brief Constructor.
57    */
58   ViewInterface();
59
60   /**
61    * @brief Virtual destructor
62    */
63   virtual ~ViewInterface();
64
65   /**
66    * @brief Retrieves the target size of the UI control.
67    *
68    * @return The control's size.
69    */
70   virtual const Vector2& GetControlSize() const = 0;
71
72   /**
73    * @brief Retrieves the text's layout size.
74    *
75    * @return The text's size. Note that this may be larger than the control size,
76    * in the case where text is scrolling/clipped.
77    */
78   virtual const Vector2& GetLayoutSize() const = 0;
79
80   /**
81    * Retrieves the number of glyphs.
82    *
83    * @return The number of glyphs.
84    */
85   virtual Length GetNumberOfGlyphs() const = 0;
86
87   /**
88    * @brief Retrieves glyphs and positions in the given buffers.
89    *
90    * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
91    * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
92    *
93    * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
94    * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
95    * @param[out] minLineOffset The minimum line offset.
96    * @param[in] glyphIndex Index to the first glyph.
97    * @param[in] numberOfGlyphs Number of glyphs to be copied.
98    *
99    * @return The number of glyphs.
100    */
101   virtual Length GetGlyphs(GlyphInfo* glyphs,
102                            Vector2*   glyphPositions,
103                            float&     minLineOffset,
104                            GlyphIndex glyphIndex,
105                            Length     numberOfGlyphs) const = 0;
106
107   /**
108    * @brief Retrieves the vector of colors.
109    *
110    * @return Pointer to the vector of colors.
111    */
112   virtual const Vector4* const GetColors() const = 0;
113
114   /**
115    * @brief Retrieves the vector of indices to the vector of colors.
116    *
117    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
118    */
119   virtual const ColorIndex* const GetColorIndices() const = 0;
120
121   /**
122    * @brief Retrieves the vector of background colors.
123    *
124    * @return Pointer to the vector of background colors.
125    */
126   virtual const Vector4* const GetBackgroundColors() const = 0;
127
128   /**
129    * @brief Retrieves the vector of indices to the vector of background colors.
130    *
131    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
132    */
133   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
134
135   /**
136    * @brief checks if there is background colors set using markup.
137    *
138    * @return boolean if there is background colors set using markup .
139    */
140   virtual bool const IsMarkupBackgroundColorSet() const = 0;
141
142   /**
143    * @brief Retrieves the text color
144    *
145    * @return The text color
146    */
147   virtual const Vector4& GetTextColor() const = 0;
148
149   /**
150    * @brief Retrieves the shadow offset, 0 indicates no shadow.
151    *
152    * @return The shadow offset.
153    */
154   virtual const Vector2& GetShadowOffset() const = 0;
155
156   /**
157    * @brief Retrieves the shadow color.
158    *
159    * @return The shadow color.
160    */
161   virtual const Vector4& GetShadowColor() const = 0;
162
163   /**
164    * @brief Retrieves the underline color.
165    *
166    * @return The underline color.
167    */
168   virtual const Vector4& GetUnderlineColor() const = 0;
169
170   /**
171    * @brief Returns whether underline is enabled or not.
172    *
173    * @return The underline state.
174    */
175   virtual bool IsUnderlineEnabled() const = 0;
176
177   /**
178    * @brief checks if there is underline set using markup.
179    *
180    * @return boolean if there is underline set using markup.
181    */
182   virtual bool const IsMarkupUnderlineSet() const = 0;
183
184   /**
185    * @brief Returns the hyphens glyph info.
186    *
187    * @return hyphens glyph info.
188    */
189   virtual const GlyphInfo* GetHyphens() const = 0;
190
191   /**
192    * @brief Returns the indices of the hyphen in the text.
193    *
194    * @return the hyphen indices.
195    */
196   virtual const Length* GetHyphenIndices() const = 0;
197
198   /**
199    * @brief Returns number of hyphens to add in text.
200    *
201    * @return number of hyphens.
202    */
203   virtual Length GetHyphensCount() const = 0;
204   /**
205    * @brief Retrieves the underline height override
206    *
207    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
208    */
209   virtual float GetUnderlineHeight() const = 0;
210
211   /**
212    * @brief Retrieves the underline type override
213    *
214    * @return Returns the override type for an underline.
215    */
216   virtual Text::Underline::Type GetUnderlineType() const = 0;
217
218   /**
219    * @brief Retrieves the dashed underline width override.
220    *
221    * @return Returns the override width for the dashed underline.
222    */
223   virtual float GetDashedUnderlineWidth() const = 0;
224
225   /**
226    * @brief Retrieves the dashed underline gap override.
227    *
228    * @return Returns the override gap for the dashed underline.
229    */
230   virtual float GetDashedUnderlineGap() const = 0;
231
232   /**
233    * @brief Retrieves the number of underline runs.
234    *
235    * @return The number of underline runs.
236    */
237   virtual Length GetNumberOfUnderlineRuns() const = 0;
238
239   /**
240    * @brief Retrieves the underline runs.
241    *
242    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
243    * @param[in] index Index of the first underline run to be copied.
244    * @param[in] numberOfRuns Number of underline runs to be copied.
245    */
246   virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
247                                 UnderlineRunIndex   index,
248                                 Length              numberOfRuns) const = 0;
249
250   /**
251    * @brief Retrieve the outline color.
252    *
253    * @return The outline color.
254    */
255   virtual const Vector4& GetOutlineColor() const = 0;
256
257   /**
258    * @brief Retrieves the width of an outline
259    *
260    * @return The width of the outline.
261    */
262   virtual uint16_t GetOutlineWidth() const = 0;
263
264   /**
265    * @brief Retrieves ellipsis position for text.
266    *
267    * @return The ellipsis position.
268    */
269   virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
270
271   /**
272    * @brief Whether the text elide property is enabled.
273    *
274    * @return @e true if the text elide property is enabled, @e false otherwise.
275    */
276   virtual bool IsTextElideEnabled() const = 0;
277
278   /**
279    * @brief Retrieves the start index of laid-out glyphs.
280    *
281    * @return The start index of laid-out glyphs.
282    */
283   virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
284
285   /**
286    * @brief Retrieves the end index of laid-out glyphs.
287    *
288    * @return The end index of laid-out glyphs.
289    */
290   virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
291
292   /**
293    * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
294    *
295    * @return The first middle index of elided glyphs, index before ellipsis of middle.
296    */
297   virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
298
299   /**
300    * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
301    *
302    * @return The second middle index of elided glyphs, index of ellipsis of middle.
303    */
304   virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
305
306   /**
307    * @brief Retrieves the strikethrough color.
308    *
309    * @return The strikethrough color.
310    */
311   virtual const Vector4& GetStrikethroughColor() const = 0;
312
313   /**
314    * @brief Returns whether strikethrough is enabled or not.
315    *
316    * @return The strikethrough state.
317    */
318   virtual bool IsStrikethroughEnabled() const = 0;
319
320   /**
321    * @brief checks if there is strikethrough set using markup.
322    *
323    * @return boolean if there is strikethrough set using markup.
324    */
325   virtual bool const IsMarkupStrikethroughSet() const = 0;
326
327   /**
328    * @brief Retrieves the strikethrough height override
329    *
330    * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
331    */
332   virtual float GetStrikethroughHeight() const = 0;
333
334   /**
335    * @brief Retrieves the number of strikethrough runs.
336    *
337    * @return The number of strikethrough runs.
338    */
339   virtual Length GetNumberOfStrikethroughRuns() const = 0;
340
341   /**
342    * @brief Retrieves the number of bounded paragraph runs.
343    *
344    * @return The number of bounded paragraph runs.
345    */
346   virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
347
348   /**
349    * @brief Retrieves the reference for bounded paragraph runs.
350    *
351    * @return The reference for bounded paragraph runs.
352    */
353   virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
354
355   /**
356    * @brief Retrieves the number of character-spacing glyph runs.
357    *
358    * @return The number of character-spacing glyph runs.
359    */
360   virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0;
361
362   /**
363    * @brief Retrieves the reference for character-spacing glyph runs.
364    *
365    * @return The reference for character-spacing glyph runs.
366    */
367   virtual const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const = 0;
368
369   /**
370    * @brief Retrieves the strikethrough runs.
371    *
372    * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
373    * @param[in] index Index of the first strikethrough run to be copied.
374    * @param[in] numberOfRuns Number of strikethrough runs to be copied.
375    */
376   virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
377                                     StrikethroughRunIndex  index,
378                                     Length                 numberOfRuns) const = 0;
379
380   /**
381    * @brief The spaces between characters in Pixels.
382    *
383    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
384    *
385    * @return characterSpacing.
386    */
387   virtual const float GetCharacterSpacing() const = 0;
388
389   /**
390    * @brief The text buffer.
391    *
392    * @return The text buffer.
393    */
394   virtual const Character* GetTextBuffer() const = 0;
395
396   /**
397    * @brief The text Glyph to Characters Array.
398    *
399    * @return GetGlyphsToCharacters.
400    */
401   virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
402 };
403
404 } // namespace Text
405
406 } // namespace Toolkit
407
408 } // namespace Dali
409
410 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H