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