[dali_2.1.5] 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) 2021 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
23 #include <dali-toolkit/internal/text/text-definitions.h>
24 #include <dali-toolkit/public-api/text/text-enumerations.h>
25
26 namespace Dali
27 {
28 struct Vector2;
29 struct Vector4;
30
31 namespace Toolkit
32 {
33 namespace Text
34 {
35 struct GlyphRun;
36
37 /**
38  * @brief Abstract interface to provide the information necessary to display text.
39  *
40  * This includes:
41  * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
42  * - The visual position of each glyph within the layout
43  * - A window into the text layout e.g. which page of a document to view
44  */
45 class ViewInterface
46 {
47 public:
48   /**
49    * @brief Constructor.
50    */
51   ViewInterface();
52
53   /**
54    * @brief Virtual destructor
55    */
56   virtual ~ViewInterface();
57
58   /**
59    * @brief Retrieves the target size of the UI control.
60    *
61    * @return The control's size.
62    */
63   virtual const Vector2& GetControlSize() const = 0;
64
65   /**
66    * @brief Retrieves the text's layout size.
67    *
68    * @return The text's size. Note that this may be larger than the control size,
69    * in the case where text is scrolling/clipped.
70    */
71   virtual const Vector2& GetLayoutSize() const = 0;
72
73   /**
74    * Retrieves the number of glyphs.
75    *
76    * @return The number of glyphs.
77    */
78   virtual Length GetNumberOfGlyphs() const = 0;
79
80   /**
81    * @brief Retrieves glyphs and positions in the given buffers.
82    *
83    * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
84    * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
85    *
86    * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
87    * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
88    * @param[out] minLineOffset The minimum line offset.
89    * @param[in] glyphIndex Index to the first glyph.
90    * @param[in] numberOfGlyphs Number of glyphs to be copied.
91    *
92    * @return The number of glyphs.
93    */
94   virtual Length GetGlyphs(GlyphInfo* glyphs,
95                            Vector2*   glyphPositions,
96                            float&     minLineOffset,
97                            GlyphIndex glyphIndex,
98                            Length     numberOfGlyphs) const = 0;
99
100   /**
101    * @brief Retrieves the vector of colors.
102    *
103    * @return Pointer to the vector of colors.
104    */
105   virtual const Vector4* const GetColors() const = 0;
106
107   /**
108    * @brief Retrieves the vector of indices to the vector of colors.
109    *
110    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
111    */
112   virtual const ColorIndex* const GetColorIndices() const = 0;
113
114   /**
115    * @brief Retrieves the vector of background colors.
116    *
117    * @return Pointer to the vector of background colors.
118    */
119   virtual const Vector4* const GetBackgroundColors() const = 0;
120
121   /**
122    * @brief Retrieves the vector of indices to the vector of background colors.
123    *
124    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
125    */
126   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
127
128   /**
129    * @brief checks if there is background colors set using markup.
130    *
131    * @return boolean if there is background colors set using markup .
132    */
133   virtual bool const IsMarkupBackgroundColorSet() const = 0;
134
135   /**
136    * @brief Retrieves the text color
137    *
138    * @return The text color
139    */
140   virtual const Vector4& GetTextColor() const = 0;
141
142   /**
143    * @brief Retrieves the shadow offset, 0 indicates no shadow.
144    *
145    * @return The shadow offset.
146    */
147   virtual const Vector2& GetShadowOffset() const = 0;
148
149   /**
150    * @brief Retrieves the shadow color.
151    *
152    * @return The shadow color.
153    */
154   virtual const Vector4& GetShadowColor() const = 0;
155
156   /**
157    * @brief Retrieves the underline color.
158    *
159    * @return The underline color.
160    */
161   virtual const Vector4& GetUnderlineColor() const = 0;
162
163   /**
164    * @brief Returns whether underline is enabled or not.
165    *
166    * @return The underline state.
167    */
168   virtual bool IsUnderlineEnabled() const = 0;
169
170   /**
171    * @brief Returns the hyphens glyph info.
172    *
173    * @return hyphens glyph info.
174    */
175   virtual const GlyphInfo* GetHyphens() const = 0;
176
177   /**
178    * @brief Returns the indices of the hyphen in the text.
179    *
180    * @return the hyphen indices.
181    */
182   virtual const Length* GetHyphenIndices() const = 0;
183
184   /**
185    * @brief Returns number of hyphens to add in text.
186    *
187    * @return number of hyphens.
188    */
189   virtual Length GetHyphensCount() const = 0;
190   /**
191    * @brief Retrieves the underline height override
192    *
193    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
194    */
195   virtual float GetUnderlineHeight() const = 0;
196
197   /**
198    * @brief Retrieves the underline type override
199    *
200    * @return Returns the override type for an underline.
201    */
202   virtual Text::Underline::Type GetUnderlineType() const = 0;
203
204   /**
205    * @brief Retrieves the dashed underline width override.
206    *
207    * @return Returns the override width for the dashed underline.
208    */
209   virtual float GetDashedUnderlineWidth() const = 0;
210
211   /**
212    * @brief Retrieves the dashed underline gap override.
213    *
214    * @return Returns the override gap for the dashed underline.
215    */
216   virtual float GetDashedUnderlineGap() const = 0;
217
218   /**
219    * @brief Retrieves the number of underline runs.
220    *
221    * @return The number of underline runs.
222    */
223   virtual Length GetNumberOfUnderlineRuns() const = 0;
224
225   /**
226    * @brief Retrieves the underline runs.
227    *
228    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
229    * @param[in] index Index of the first underline run to be copied.
230    * @param[in] numberOfRuns Number of underline runs to be copied.
231    */
232   virtual void GetUnderlineRuns(GlyphRun*         underlineRuns,
233                                 UnderlineRunIndex index,
234                                 Length            numberOfRuns) const = 0;
235
236   /**
237    * @brief Retrieve the outline color.
238    *
239    * @return The outline color.
240    */
241   virtual const Vector4& GetOutlineColor() const = 0;
242
243   /**
244    * @brief Retrieves the width of an outline
245    *
246    * @return The width of the outline.
247    */
248   virtual uint16_t GetOutlineWidth() const = 0;
249
250   /**
251    * @brief Retrieves ellipsis position for text.
252    *
253    * @return The ellipsis position.
254    */
255   virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
256
257   /**
258    * @brief Whether the text elide property is enabled.
259    *
260    * @return @e true if the text elide property is enabled, @e false otherwise.
261    */
262   virtual bool IsTextElideEnabled() const = 0;
263
264   /**
265    * @brief Retrieves the start index of laid-out glyphs.
266    *
267    * @return The start index of laid-out glyphs.
268    */
269   virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
270
271   /**
272    * @brief Retrieves the end index of laid-out glyphs.
273    *
274    * @return The end index of laid-out glyphs.
275    */
276   virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
277
278   /**
279    * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
280    *
281    * @return The first middle index of elided glyphs, index before ellipsis of middle.
282    */
283   virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
284
285   /**
286    * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
287    *
288    * @return The second middle index of elided glyphs, index of ellipsis of middle.
289    */
290   virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
291
292   /**
293    * @brief Retrieves the strikethrough color.
294    *
295    * @return The strikethrough color.
296    */
297   virtual const Vector4& GetStrikethroughColor() const = 0;
298
299   /**
300    * @brief Returns whether strikethrough is enabled or not.
301    *
302    * @return The strikethrough state.
303    */
304   virtual bool IsStrikethroughEnabled() const = 0;
305
306   /**
307    * @brief Retrieves the strikethrough height override
308    *
309    * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
310    */
311   virtual float GetStrikethroughHeight() const = 0;
312 };
313
314 } // namespace Text
315
316 } // namespace Toolkit
317
318 } // namespace Dali
319
320 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H