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