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